samerhannoun Posted September 4, 2011 Share Posted September 4, 2011 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 More sharing options...
Don E Posted September 4, 2011 Share Posted September 4, 2011 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 More sharing options...
samerhannoun Posted September 5, 2011 Author Share Posted September 5, 2011 Looks like you forgot 'FROM' between the * and timesheet...SELECT * FROM...yes yes thank you very much Link to comment Share on other sites More sharing options...
hatef Posted October 4, 2011 Share Posted October 4, 2011 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 More sharing options...
justsomeguy Posted October 4, 2011 Share Posted October 4, 2011 You're using backquotes around the values instead of single quotes. Backquotes are only used for quoting identifiers like column and table names. Link to comment Share on other sites More sharing options...
hatef Posted October 4, 2011 Share Posted October 4, 2011 i changed but it doesn't work yet!! Link to comment Share on other sites More sharing options...
thescientist Posted October 4, 2011 Share Posted October 4, 2011 changed it to what? Show us your updated code. you're also not doing any error checking. Link to comment Share on other sites More sharing options...
hatef Posted October 5, 2011 Share Posted October 5, 2011 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 More sharing options...
[dx] Posted October 5, 2011 Share Posted October 5, 2011 $squl = "INSERT INTO messages (name, email, subject, content) VALUES ('$name', '$mail', '$subject', '$content')"; Link to comment Share on other sites More sharing options...
Don E Posted October 5, 2011 Share Posted October 5, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.