dansk Posted December 26, 2006 Share Posted December 26, 2006 hello everyone, i have this$pub='Yes';$sql=mysql_query('SELECT * FROM Announ . Articles WHERE Post_Status =' $pub 'ORDER BY ID DESC LIMIT 0, 30 ')and i getParse error: parse error, unexpected T_VARIABLE in C:\Program Files\xampp\htdocs\Posts.php on line 15i tried$sql=mysql_query("SELECT * FROM Announ . Articles WHERE Post_Status = " "Yes" "ORDER BY ID DESC LIMIT 0, 30 ")and i get thisParse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\Program Files\xampp\htdocs\Posts.php on line 15can someone please explain it to me? and tell me how to fix it Quote Link to comment Share on other sites More sharing options...
AndyB Posted December 26, 2006 Share Posted December 26, 2006 Try this:$sql=mysql_query("SELECT * FROM Announ.Articles WHERE Post_Status = '$pub' ORDER BY ID DESC LIMIT 0, 30 ");And showing a bit more code to us wouldn't hurt. Quite possibly the [b]source[/b] of the error is in the preceding lines. Quote Link to comment Share on other sites More sharing options...
dansk Posted December 26, 2006 Author Share Posted December 26, 2006 Thank you very muchIt actually worked, but can you please explain how it worked. Because i can't find enough explaination behind mysql quotetions. I usually, just keep trying until it works. What should i do in the case if i need to put just a number instead of $pub or if I just wanted to put the string Yes instead of creating a variable called $pub and assigning the string Yes to it.Once again, Thank you for your help. Quote Link to comment Share on other sites More sharing options...
AndyB Posted December 27, 2006 Share Posted December 27, 2006 $sql=mysql_query("SELECT * FROM Announ.Articles WHERE Post_Status = 'Yes' ORDER BY ID DESC LIMIT 0, 30 ");$sql=mysql_query("SELECT * FROM Announ.Articles WHERE Post_Status = '5' ORDER BY ID DESC LIMIT 0, 30 ");$sql=mysql_query("SELECT * FROM Announ.Articles WHERE Post_Status = 'First Class' ORDER BY ID DESC LIMIT 0, 30 ");etc., etc. Watch that the double and single quotes are not mis-matched. Notice the lack of spaces between the database name and table name in the (working) example. 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.