I noticed something today and thought that it could cause huge problems in the future. Let me explain;
Example; I have a like this
$query1 = "INSERT INTO table1(col1,col2,col3) VALUES('$col1','$col2','$col3')";
$query2 = "INSERT INTO table2(col1,col2,col3) VALUES('$col1','$col2','$col3')";
$query3 = "UPDATE table3 SET col1 = '$col1' WHERE id='$id'";
if (mysql_query($query1) && mysql_query($query2) && mysql_query($query3)) {
echo "successful message";
}
else {
echo mysql_error();
}
When this happens, non-error queries are processed. So if one of them fails, the statistics screen is wrong.
What I want to do;
If there is an error in one of the queries, none should be processed. How can i do that?
(Im sorry for my english.)
What you want to achieve can't be done using the mysql_
driver (another reason to update). With PDO
or mysqli
you can use a transaction to achieve this behavior. You also should take advantage of their prepared statements as well.
Then once you have that done, with whichever driver you choose (PDO is preferable, IMO), See:
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
Want to improve this question? Add details and clarify the problem by editing this post
I'm trying to set up my code so it can detect if a certain section of my HTML is at the top of the viewportI'm getting the error:
Here is an example: https://wwwmsdmanuals