Error updating multiple MySQL tables in one update statement

Hi,

I have

The request is empty.

when updating data.

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE client,release SET client.`client_name`=%s, release.`client_name`=%s WHERE client.`client_id`=%s AND release.`client_id`=%s", GetSQLValueString($_POST['newcust'], "text"), GetSQLValueString($_POST['select'], "int")); mysql_select_db($database_trackntrace, $trackntrace); $Result1 = mysql_query($updateSQL, $trackntrace) or die(mysql_error()); } 

I think there is a problem with asking if anyone can determine where the problem is.

Yours faithfully

+4
source share
2 answers

The problem is the sprintf function. You will tell sprintf that you are going to pass 4 lines to it, but you only skip 2.

Since you only pass 2 parameters, and this requires 4, it will return false.

Try adding this above your code:

 error_reporting(E_ALL); ini_set('display_errors', '1'); 

This is the error you should get with the above settings:

 Warning: sprintf() [<a href='function.sprintf'>function.sprintf</a>]: Too few arguments 

What do you want to change to fix this problem:

 if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE client,release SET client.`client_name`=%s, release.`client_name`=%s WHERE client.`client_id`=%s AND release.`client_id`=%s", GetSQLValueString($_POST['newcust'], "text"), GetSQLValueString($_POST['newcust'], "text"), GetSQLValueString($_POST['select'], "int"), GetSQLValueString($_POST['select'], "int")); mysql_select_db($database_trackntrace, $trackntrace); $Result1 = mysql_query($updateSQL, $trackntrace) or die(mysql_error()); } 
+4
source

Release is a reserved word, use backlinks.

 UPDATE client,`release` SET client.`client_name`=%s, `release`.`client_name`=%s WHERE client.`client_id`=%s AND `release`.`client_id`=%s", GetSQLValueString($_POST['newcust'], "text"), GetSQLValueString($_POST['select'], "int")); 

http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-version-reference-reservedwords-5-5.html

+2
source

Source: https://habr.com/ru/post/1502794/


All Articles