pontypete Posted January 7, 2012 Share Posted January 7, 2012 $query_rsGetOrderDetails = "SELECT * FROM hd_order WHERE order_by = '$usernameLoggedin' ORDER BY order_id DESC LIMIT 3"; Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/254558-sql-statement-not-working/ Share on other sites More sharing options...
Pikachu2000 Posted January 7, 2012 Share Posted January 7, 2012 What errors are returned when it's executed? Quote Link to comment https://forums.phpfreaks.com/topic/254558-sql-statement-not-working/#findComment-1305326 Share on other sites More sharing options...
SergeiSS Posted January 7, 2012 Share Posted January 7, 2012 I bet you don't use function mysql_query() You statement is not a real statement. It's just a string now. Quote Link to comment https://forums.phpfreaks.com/topic/254558-sql-statement-not-working/#findComment-1305338 Share on other sites More sharing options...
Twister1004 Posted January 7, 2012 Share Posted January 7, 2012 Your statement is not going to work. It will put inside the database '$thisvariable'. But even then, it wont do that and return an error. Your Statement: $query_rsGetOrderDetails = "SELECT * FROM hd_order WHERE order_by = '$usernameLoggedin' ORDER BY order_id DESC LIMIT 3" Fixed Statement $query_rsGetOrderDetails = "SELECT * FROM hd_order WHERE order_by = '{$usernameLoggedin}' ORDER BY order_id DESC LIMIT 3" However as SergeiSS said, you have to use the mysql_query function for it to run. Quote Link to comment https://forums.phpfreaks.com/topic/254558-sql-statement-not-working/#findComment-1305340 Share on other sites More sharing options...
Pikachu2000 Posted January 7, 2012 Share Posted January 7, 2012 Your statement is not going to work. It will put inside the database '$thisvariable'. But even then, it wont do that and return an error. Your Statement: $query_rsGetOrderDetails = "SELECT * FROM hd_order WHERE order_by = '$usernameLoggedin' ORDER BY order_id DESC LIMIT 3" Fixed Statement $query_rsGetOrderDetails = "SELECT * FROM hd_order WHERE order_by = '{$usernameLoggedin}' ORDER BY order_id DESC LIMIT 3" However as SergeiSS said, you have to use the mysql_query function for it to run. There is nothing syntactically wrong with the query string the way the OP has it written. The curly braces aren't needed. Quote Link to comment https://forums.phpfreaks.com/topic/254558-sql-statement-not-working/#findComment-1305341 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.