chrisfane Posted August 30, 2007 Share Posted August 30, 2007 i seem to be constantly falling over hurdles with my use's of " and ' . Im currently trying to write a mysql query which uses the result of a previous query, for one of its parameters. i have previously always used ... ". $row2['SeatVers'] ." to insert the result of a mysql query, but obviously this doesnt worked when encased in the double quotes used for the sql text string, and if im not mistaken if u use a single quote it refers to it as a static value rather than dynamic. $result2 = mysql_query("select count(success) , SeatVers , ISAVers from SeatPub where success='1' and SeatVers=". $row['SeatVers'] ." group by ISAVers") or die(mysql_error()); when using the code above i get the following error message, which i assume is because i am terminating the quotes before the end of the sql query, how should i go about modifying the above code to work correctly ? "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 '9.005 group by ISAVers' at line 1" Thanks for helping out a newbie Link to comment https://forums.phpfreaks.com/topic/67306-solved-i-really-need-to-learn-about-and/ Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 Your use is right by PHP - it's MySQL that has a problem. SeatVers=". $row['SeatVers'] ." group Needs to be: SeatVers='". $row['SeatVers'] ."' group Note the single quotes surrounding the variable. That makes it a string in SQL. Even though you close the PHP string, you're starting a MySQL string and then closing it around the variable. Link to comment https://forums.phpfreaks.com/topic/67306-solved-i-really-need-to-learn-about-and/#findComment-337694 Share on other sites More sharing options...
chrisfane Posted August 30, 2007 Author Share Posted August 30, 2007 thankyou very much for your help Link to comment https://forums.phpfreaks.com/topic/67306-solved-i-really-need-to-learn-about-and/#findComment-337697 Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 No problem. Link to comment https://forums.phpfreaks.com/topic/67306-solved-i-really-need-to-learn-about-and/#findComment-337714 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.