eits Posted September 6, 2007 Share Posted September 6, 2007 Hi I am using: $query_conn = "SELECT * FROM tblcustomer WHERE clientname = 'zoe'"; It works to get user zoe details out of DB - however, if I try and get data from a selectbox using: $query_conn = "SELECT * FROM 'tblcustomer' WHERE 'clientname' = " . $_POST['clientdd']; I get the error: 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 '' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/68215-solved-sql-quickie/ Share on other sites More sharing options...
beboo002 Posted September 6, 2007 Share Posted September 6, 2007 $query_conn = "SELECT * FROM 'tblcustomer' WHERE 'clientname' = " . $_POST['clientdd']; code some thing like $query_conn = "SELECT * FROM 'tblcustomer' WHERE 'clientname' = ' ". $_POST['clientdd']." ' "; Quote Link to comment https://forums.phpfreaks.com/topic/68215-solved-sql-quickie/#findComment-342930 Share on other sites More sharing options...
eits Posted September 6, 2007 Author Share Posted September 6, 2007 This still gives me: 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 ''tblcustomer' WHERE 'clientname' = ' '' at line 1 It may be worth noting that the code that works: //$query_conn = "SELECT * FROM tblcustomer WHERE clientname = 'zoe'"; doesn't work if i put ' and ' either side of tblcustomer. Quote Link to comment https://forums.phpfreaks.com/topic/68215-solved-sql-quickie/#findComment-342935 Share on other sites More sharing options...
beboo002 Posted September 6, 2007 Share Posted September 6, 2007 put this $query_conn = "SELECT * FROM tblcustomer WHERE clientname = ' ". $_POST['clientdd']." ' "; Quote Link to comment https://forums.phpfreaks.com/topic/68215-solved-sql-quickie/#findComment-342943 Share on other sites More sharing options...
Yesideez Posted September 6, 2007 Share Posted September 6, 2007 The error in the syntax was having ' surrounding the field names instead of ` $query_conn="SELECT * FROM `tblcustomer` WHERE `clientname`='".$_POST['clientdd']."'"; Quote Link to comment https://forums.phpfreaks.com/topic/68215-solved-sql-quickie/#findComment-342966 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.