Page 1 of 1

error nuDebug

Posted: Thu Jun 18, 2020 11:01 am
by kknm
==PDO MESSAGE===

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `tabel_id` = '5ed551c1add280b'' at line 1

===SQL===========

UPDATE tabel SET WHERE `tabel_id` = '5ed551c1add280b';

===BACK TRACE====

/var/www/report/nudata.php - line 358 (nuRunQuery)

/var/www/report/nuapi.php - line 52 (nuUpdateDatabase)
There are several subordinate forms on the main form. When you change in one of the forms for 1 second, a message appears and disappears. It is not clear to me from the message in which request is this error located?

Re: error nuDebug

Posted: Thu Jun 18, 2020 11:07 am
by kev1n
I had a similar case just yesterday. I am using a subform that contains a calculated field, but the calculated field itself does not exist in the database table. nuBuilder then generates an invalid UPDATE statement. The solution (or rather workaround) for me was to create the calculated field in the table.

Re: error nuDebug

Posted: Thu Jun 18, 2020 12:19 pm
by kknm
kev1n wrote:I had a similar case just yesterday. I am using a subform that contains a calculated field, but the calculated field itself does not exist in the database table. nuBuilder then generates an invalid UPDATE statement. The solution (or rather workaround) for me was to create the calculated field in the table.
I also think that this is due to the calculated field, but this field exists in my database table. True, the table itself and the calculated field are filled with the php procedure. At what stage to catch the error and fix it?

Re: error nuDebug

Posted: Thu Jun 18, 2020 12:33 pm
by kev1n
This is a really ugly workaround, to handle the case when the update statement contains 'SET WHERE'

In this file,
https://github.com/steven-copley/nubuil ... a.php#L350

replace the code fragment

Code: Select all

	if($S != null){

		for($i = 0 ; $i < count($S) ; $i++){
			
			$sql			= $S[$i];
			$insert			= "INSERT INTO $nuMainTable";
			$length			= strlen($insert);
			
			if (strpos($sql, 'SET WHERE') == false) {
				
				nuRunQuery($sql);
				
				if(substr($sql, 0, $length) == $insert and $nuMainID == 'autoid'){
					
					$t			= nuRunQuery('SELECT LAST_INSERT_ID()');
					$nuMainID	= db_fetch_row($t)[0];
					
				}
			}
		}
		
	}

Re: error nuDebug

Posted: Tue Jun 23, 2020 3:59 pm
by kknm
So it works !