I’ve verified all variables below and am now attempting to insert them into my mysql database using prepared statements, but the data is not inserting even though I am not receiving any system errors. $insert_stmt->affected_rows>0 returns false, and thus displays my custom warning message:
$insert_stmt = $db->prepare("INSERT INTO users (id,timestamp,externalid,password,authentication,email) VALUES(NULL,NOW(),?,?,?,?)");
$insert_stmt->bind_param("ssss",$userid,$hash,$authenticate,$email);
$insert_stmt->execute();
if ($insert_stmt->affected_rows>0)
I’m somewhat new to PHP (and the community) and can’t figure out why nothing would be inserting and my custom warning message always displays? Again, no system errors are generated. Thanks!
I figured out the issue. I was testing with an externalid that was already in the database, and my check for preventing duplicate external ids was not working correctly, so my code was reaching the insertion line and trying to put the externalid again into MySQL when it already existed in the database. I had set the externalid as a unique field, so it wouldn’t allow it to be entered. MySQL though didn’t return any noticeable errors when I had set E_ALL | E_STRICT. Good to know in the future.
I didn’t realize I was testing with a duplicate entry, so sorry to the community for adding that nugget of info.