printeero when It can not connect to database

Posted on 2013-09-03
Medium Priority
Last Modified: 2013-09-05
how can I put code to  check error when connect to my sql database of this code below

header('Content-Type: text/html; charset=utf-8');
include "./common_db.inc";
$register_script = "./register.php";

function auth_user($userid, $userpassword) {
   global $default_dbname1, $user_tablename;
   $link_id = db_connect1($default_dbname1);
   $query = "SELECT nickname FROM $user_tablename
                             WHERE nickname = '$userid'
                             AND password = '$userpassword' AND stockad = 'y' ";
   $result = mysql_query($query);
   if(!mysql_num_rows($result)) return 0;
   else {
      $query_data = mysql_fetch_row($result);
      return $query_data[0];
Question by:teera
1 Comment
LVL 36

Accepted Solution

Loganathan Natarajan earned 2000 total points
ID: 39462539
you need to work around in this function , db_connect1() ...

also in your query, you should handle like this,

   $result = mysql_query($query) or die(mysql_error("error occured"));

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question