php - Uncaught exception 'mysqli_sql_exception' with message 'No data supplied for parameters in prepared statement' -
i trying write query using prepared statement.
mysqli_report(mysqli_report_all); $query = $conn->prepare("insert notification(messageid,topicarn,subject,message,timestamp,signatureversion,signature,signingcerturl,unsubscribeurl,topicid) values (?, ?, ?, ?, ?,?, ?, ?, ?, ?)");
this throws following exception
fatal error: uncaught exception 'mysqli_sql_exception' message 'no data supplied parameters in prepared statement'
where following query works
$query = $conn->prepare("insert notification(messageid,topicarn,subject,message,timestamp,signatureversion,signature,signingcerturl,unsubscribeurl,topicid) values (".$message['messageid'].", '".$message['topicarn']."', '".$message['subject']."', '".$message['message']."', '".$message['timestamp']."',".$message['signatureversion'].", '".$message['signature']."', '".$message['signingcerturl']."', '".$message['unsubscribeurl']."', ".$topic.")");
i want use prepared statement bind_param() function. wrong first query? please help.
as suggested - need bind parameters values before can execute sql ~ perhaps:
mysqli_report(mysqli_report_all); $sql='insert notification (messageid,topicarn,subject,message,timestamp,signatureversion,signature,signingcerturl,unsubscribeurl,topicid) values (?, ?, ?, ?, ?,?, ?, ?, ?, ?)'; $stmt = $conn->prepare( sql ); if( $stmt ){ /* assumed strings other `id` in column name */ $stmt->bind_param('issssssssi', $message['messageid'], $message['topicarn'], $message['subject'], $message['message'], $message['timestamp'], $message['signatureversion'], $message['signature'], $message['signingcerturl'], $message['unsubscribeurl'], $topic ); $result=$stmt->execute(); /* other code */ } else { /* investigate why "prepare" method failed */ echo "error:"; }
Comments
Post a Comment