MySQL Forums
Forum List  »  PHP

Re: 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 **
Posted by: Peter Brawley
Date: August 23, 2014 09:33PM

> $result=mysql_query("select max(e_id)+1 as m from exam_master" );

> $id_=mysql_result($result,0,"m");

Your code assumes that your query returned the expected result, but the error report you got ... near ''exam_master' values(,'BT0092 ... says otherwise: the value in $id_ is empty. Always check query results vefore trying to use them, eg minimally ...

$result=mysql_query(...) or exit( mysql_error() ); 
if( mysql_num_rows($result) == 1 ) {
  $id_ = mysql_result($result,0,"m"); 
  ...

And, the mysql PHP API is deprecated, you need to switch to the mysqli API.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.