Jump to content

mysql_error


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
https://forums.phpfreaks.com/topic/277622-mysql_error/
Share on other sites

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

  Quote

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.

Link to comment
https://forums.phpfreaks.com/topic/277622-mysql_error/#findComment-1428178
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"); 
    }
Link to comment
https://forums.phpfreaks.com/topic/277622-mysql_error/#findComment-1428214
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.