Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Mysql/PHP issues using WHERE

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
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
Close
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
Close
Thanks a bunch, rep added!
 
0
Close
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
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back