Jump to content

[SOLVED] pares error in mysql


dansk

Recommended Posts

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 get

Parse error: parse error, unexpected T_VARIABLE in C:\Program Files\xampp\htdocs\Posts.php on line 15

i tried

$sql=mysql_query("SELECT * FROM Announ . Articles WHERE Post_Status = " "Yes" "ORDER BY ID DESC LIMIT 0, 30 ")

and i get this

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\Program Files\xampp\htdocs\Posts.php on line 15

can someone please explain it to me? and tell me how to fix it
Link to comment
https://forums.phpfreaks.com/topic/31896-solved-pares-error-in-mysql/
Share on other sites

Thank you very much

It 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.
$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.

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.