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
Share on other sites

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.
Link to comment
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.
Link to comment
Share on other sites

$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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.