Reputation: 2815
I try to insert a row to my DB table as follows:
$selected = mysqli_select_db($link, $db_name);
if(!$selected){
$mail_Subject = 'Error in selecting DB: ' . mysqli_error($link);
mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
mysqli_close($link);
exit;
}
// Add the line to the database!
if(!mysqli_query("INSERT INTO tokens (user_id, user_name, transaction_id, token_type, token_meta, date) VALUES ('-3', 'nisui2', 'blabla2', '111', '111 meta', '');")){
$mail_Subject = 'Error in insertion: ' . mysqli_error($link);
mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
mysqli_close($link);
exit;
}
From some reason I get an email with the subject "Error in insertion:", with no error details.
Can you spot what am I doing wrong?
Also, can you tell me a way to debug this? (how can I know what the problem was?)
Upvotes: 0
Views: 61
Reputation: 7868
Add $link
as first parameter to your call:
mysqli_query($link, "INSERT …");
Upvotes: 1
Reputation: 79
You'r selecting the Database with "mysql_select_db" but you'r querying with msqli
try
$selected = mysqli_select_db($db_name, $link);
Upvotes: 2