Jump to content

mysql_error


reisve
Go to solution Solved by reisve,

Recommended Posts

Hi

I have this piece of code part of a larger code block:
 

$page = '../../register.php';      
$msg = $error['register'];        
$msg .= mysql_error($link);      
header("Location: templates/frontend/error.php?msg=$msg&page=$page"); 

 


everything works if I remove the  "$msg .=  mysql_error($link);" line. the line bellow comes from a language, file and if the Mysql_error is not on the line, it shows up. with the mysql_error, just get  ablank line

Any help please?

 

Link to comment
Share on other sites

If there was no error mysql_error returns and empty string. Are you sure that the database returned an error?

Returns the error text from the last MySQL function, or '' (empty string) if no error occurred.

http://php.net/manual/en/function.mysql-error.php]

 

Also:

 

Do a view source and see if there is something returned that you are not seeing.

Edited by davidannis
Link to comment
Share on other sites

according the code flow, there was an error, and if the error line is not there I got my error message. Just would like to add the MySQL error itself:

    $query = "INSERT INTO users (first_name, last_name, email, c_user, c_pass, c_type) VALUES ('$f_fname', '$f_lname', '$f_email', '$f_user', '$cryptpass', '$f_type')";
    if (mysqli_query($link, $query)){
      $page = '../../index.php';
      $msg = $info['register'];
      header("Location: templates/frontend/info.php?msg=$msg&page=$page");

    } else {
      $page = '../../register.php';
      $msg = $error['register'];  
      $msg .= mysql_error($link);
      header("Location: templates/frontend/error.php?msg=$msg&page=$page"); 
    }

Edited by reisve
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.