I am having problems which the following code:
if(mysql_num_rows(mysql_query("SELECT user_id FROM myTable WHERE user_id = '$user_id'"))){
mysql_query("UPDATE myTable SET
id='',
user_id='$user_id',
title='$title',
WHERE user_id='$user_id'
")
} else {
mysql_query("INSERT INTO myTable (id, user_id, title)
VALUES ('', $user_id, $title) ");
}
The update part seems to work but after the else it doesn’t insert the record into the table.
Can anyone spot what could be the problem please?
no wonder, as this code is just horrible. four nested operators!
even if you’d get some error messages, you’ll be unable to tell what operator it belongs to
you didn’t ask for any
make your code more consistent and add error reporting to it:
and you will always be informed of the any error occurred