Page 1 of 1

sql statemnet

Posted: Mon Sep 06, 2004 5:35 pm
by pinehead18
$sql = "SELECT * FROM $table WHERE pic1 <> "default.gif" ORDER BY id
DESC LIMIT $page,$limit";

What is wrong with this?

Posted: Mon Sep 06, 2004 5:37 pm
by feyd
what does the server say? what's the rendered text?

Posted: Mon Sep 06, 2004 5:39 pm
by pinehead18
Parse error: parse error, unexpected T_DEFAULT in /home/pinehead/www/browse on line 12

Posted: Mon Sep 06, 2004 5:41 pm
by feyd
you need to escape the quotes you have in that string, as evidenced here:

Code: Select all

$sql = "SELECT * FROM $table WHERE pic1 <> "default.gif" ORDER BY id
DESC LIMIT $page,$limit";

Posted: Mon Sep 06, 2004 5:41 pm
by pinehead18
i know it is that statement becuase i added the where pic1 <> "default.gif" and that is when i started getting the errors.

Posted: Mon Sep 06, 2004 5:45 pm
by pinehead18
bah, here is what i need to to.
I need the sql statement to list all the rows in the table. But i want it to list the ones where mainpic <> default.gif FIRST BY id then all the other ones by id that don't have a pic.
I'm clueless on how to go about that any ideas?

thank you
Anthony

Posted: Mon Sep 06, 2004 5:51 pm
by feyd
Basic Strings 101:

Code: Select all

$string = "blahblah"; // a simple string
$string = "blahblah "secondary string" blahblha"; // double quotes inside a double quote string. Variables inside the string are transformed.
$string = 'blahblah'; // another simple string
$string = 'blahblah "secondary string" blabhlah'; // double quotes inside a single quote string do not need escaping. Variables inside the string are [u]not[/u] transformed.

Posted: Mon Sep 06, 2004 7:04 pm
by pinehead18
Right the parse error is no longer a problem. It is the actual statement above where i'm trying to accomplish the whole select statement. Its all above. Any suggestions?

Posted: Mon Sep 06, 2004 7:14 pm
by feyd
[php_man]var_export[/php_man] the string and post the result here. (not what the browser shows you.. the actual output.)