PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have the following code which i thought would carry out the $update query and if that didn't work (because the row matching the sql WHERE statement can't be found) the $insert query would be run. But the $insert is never carried out. What am i doing wrong?
mysql_query will only return FALSE on an error with an update query. Since the query itself is fine, it still runs through and executes, but since the row cannot be found to update, nothing is updated (this is NOT an error). What you should try doing is checking mysql_affected_rows() to see if it's more than 0 (an update occurred), and then continue on to insert if the affected rows is 0.