Mysql/PHP issues using WHERE

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

Camron

VIP Member
Impact
44
I'm currently using the following code to select and get info from the database:

(I am using mysql 5 and php 5)

PHP:
$result = mysql_query("SELECT * FROM order WHERE status='pending'") or die(mysql_error());  
while($row = mysql_fetch_array( $result )) {  

<outputs the data here>

}

Now on the page it displays:

Code:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order WHERE status='pending'' at line 1

This is really weird because I have never had such issue before. I have another script using almost identical code and it's working fine.

Any help is much appreciated :)
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Replace
PHP:
  $result = mysql_query("SELECT * FROM order WHERE status='pending'") or die(mysql_error());
with
PHP:
  $result = mysql_query( "SELECT * FROM `order` WHERE `status`='pending'" ) or die(mysql_error());
"order" is an SQL Keyword - "ORDER BY fieldname DESC/ASC"
 
1
•••
Thanks a bunch, rep added!
 
0
•••
Camron, it would be good pratice to put `` around your field names, the better you get at creating complex queries, the easier it be to make mistakes, or use "keywords" in your queries.

=)
 
0
•••
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back