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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
chrisfane Posted August 30, 2007 Author Share Posted August 30, 2007 thankyou very much for your help Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 No problem. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.