Jump to content
Larry Ullman's Book Forums

Insert Date Works In Mysql But Not Prepared Statement


Recommended Posts

When I run this query from PhpMyAdmin it works but when it's a prepared statement it doesn't work.
The problem is with the date and the column type is date because I want only one row for each date in this table.
 

$q = "INSERT INTO I_Counts (count_date, morning_1,  morning_2,  morning_3) VALUES (NOW(), ?, ?, ?)";
 $stmt = mysqli_prepare($dbc, $q);
 mysqli_stmt_bind_param($stmt, 'iii', $mb1, $mb2, $mb3);
 
Warning: mysqli_prepare() expects parameter 1 to be mysqli, null given in /home/advice10/public_html/astuff/enter-morning.php on line 92
A system error occurred. We apologize for the inconvenience.

Notice: Query: INSERT INTO I_Counts (count_date, morning_1, morning_2, morning_3) VALUES (NOW(), ?, ?, ?)
MySQL Error: in /home/advice10/public_html/astuff/enter-morning.php on line 94

Link to comment
Share on other sites

I believe the $dbc is valid because I Select from a different table successfully.

 

There are these additional errors but I didn't think you need them all.

Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, null given in /home/advice10/public_html/astuff/enter-morning.php on line 93

A system error occurred. We apologize for the inconvenience.

Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, null given in /home/advice10/public_html/astuff/enter-morning.php on line 94

A system error occurred. We apologize for the inconvenience.

Warning: mysqli_error() expects parameter 1 to be mysqli, null given in /home/advice10/public_html/astuff/enter-morning.php on line 94

A system error occurred. We apologize for the inconvenience.
 
Maybe I have to do it not prepared, but I forgot the syntax.
Link to comment
Share on other sites

 Share

×
×
  • Create New...