sql statemnet

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

sql statemnet

Post by pinehead18 »

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

What is wrong with this?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

what does the server say? what's the rendered text?
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Post by pinehead18 »

Parse error: parse error, unexpected T_DEFAULT in /home/pinehead/www/browse on line 12
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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";
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Post 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.
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

[php_man]var_export[/php_man] the string and post the result here. (not what the browser shows you.. the actual output.)
Post Reply