abigail Posted January 30, 2014 Share Posted January 30, 2014 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 More sharing options...
HartleySan Posted January 30, 2014 Share Posted January 30, 2014 It sounds like your $stmt variable is invalid. Is the $dbc variable valid? Link to comment Share on other sites More sharing options...
abigail Posted January 30, 2014 Author Share Posted January 30, 2014 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 More sharing options...
abigail Posted January 30, 2014 Author Share Posted January 30, 2014 Actually, the $dbc was not set correct, because of previous debugging. And it works now. Link to comment Share on other sites More sharing options...
HartleySan Posted January 30, 2014 Share Posted January 30, 2014 Glad you found the problem. Thanks for sharing. Link to comment Share on other sites More sharing options...
Recommended Posts