Jump to content

SQL Query not working


samerhannoun

Recommended Posts

Looks like you forgot 'FROM' between the * and timesheet...SELECT * FROM...

HI guys... why this code not working "SELECT * timesheet WHERE YEAR(date) = YEAR(CURDATE()) AND MONTH(date) = MONTH(CURDATE()) ";this SQL statment working fine on the database engine direct, but not working when run it via PHP page???Please any help Thank you in advance.
Link to comment
Share on other sites

  • 5 weeks later...

i have a problem with sqli'm using this code:

                //sql guery         $squl="INSERT INTO 'messages' ('id','name' ,'email' ,'subject' ,'content','userid' )VALUES ( null,'$name',  '$mail',  '$subject',  '$content','');";           //myql query         $quuery=mysql_query($squl) or die("message query problem: ".  mysql_error()); 

the result is : "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 ''messages' ('id','name' ,'email' ,'subject' ,'content','userid' )VALUES ( null,'' at line 1" what is the problem?! please help me!

Link to comment
Share on other sites

i changed it to this : "

		 //sql guery	  //sql guery	 $squl="INSERT INTO 'messages' ('id','name' ,'email' ,'subject' ,'content','userid' )VALUES ( null,'".$name."',  '".$mail."',  '".$subject."',  '".$content."','');";	  //myql query	 $quuery=mysql_query($squl) or die("message query problem: ".  mysql_error());

Link to comment
Share on other sites

Just to add: If one of your values is going to be a number(s), you don't have to have any quotes around that value. For example:

$sql = "INSERT INTO messages (name, email, subject, content, phone) VALUES ('$name', '$mail', '$subject', '$content', $phone)";

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...