MartinBing Posted April 2, 2009 Share Posted April 2, 2009 Hello everybody I've been using PHP and MySQL for a little while now and I've noticed that sometimes my codes work and don't work on another page (they sometimes give an error message and on another page they don't...) Last I've done this coding and it worked fine: $result = mysql_query("SELECT * FROM ".$table." WHERE email= '".$email."'",$DBConn) or die("error in SELECT Query Mails Application: " . mysql_error()); the meaning of this was to be able to use variables for the table and email which is given in with a flash form. This worked, i repeat THIS WORKED!!! But now I want something like this and I keep getting an error message when I've uploaded it to work. $result = mysql_query("SELECT email FROM ".$table." WHERE subscribed= '".$submit."'",$DBConn) or die("error in SELECT Query Mails Application: " . mysql_error()); email is a colomn in the table which is given from the flash file, the variables work fine!! the connection is established and the variables work, but still I keep getting this error message: error in SELECT Query Mails Application: 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 'WHERE subscribed= 'YES'' at line 1 I've tried everything, to change the variable YES, the upper brackets and so on, but nothing seemed to help.. Can anyone help me please??? Thanks already!! Quote Link to comment Share on other sites More sharing options...
rhodesa Posted April 2, 2009 Share Posted April 2, 2009 what field type is Subscribed? INT, CHAR, etc? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 2, 2009 Share Posted April 2, 2009 Based on the error message, $table is probably empty. How about forming your query string in a variable so that you can echo it out to see what it actually is. Quote Link to comment Share on other sites More sharing options...
fenway Posted April 2, 2009 Share Posted April 2, 2009 Yes, let's see the actual statment. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 2, 2009 Share Posted April 2, 2009 I'm kind of hoping that once the OP sees it he can solve it himself without us actually needing to see it. Quote Link to comment Share on other sites More sharing options...
MartinBing Posted April 2, 2009 Author Share Posted April 2, 2009 what field type is Subscribed? INT, CHAR, etc? subscribed is a char type of field Quote Link to comment Share on other sites More sharing options...
MartinBing Posted April 2, 2009 Author Share Posted April 2, 2009 Hello everybody I've been using PHP and MySQL for a little while now and I've noticed that sometimes my codes work and don't work on another page (they sometimes give an error message and on another page they don't...) Last I've done this coding and it worked fine: $result = mysql_query("SELECT * FROM ".$table." WHERE email= '".$email."'",$DBConn) or die("error in SELECT Query Mails Application: " . mysql_error()); the meaning of this was to be able to use variables for the table and email which is given in with a flash form. This worked, i repeat THIS WORKED!!! But now I want something like this and I keep getting an error message when I've uploaded it to work. $result = mysql_query("SELECT email FROM ".$table." WHERE subscribed= '".$submit."'",$DBConn) or die("error in SELECT Query Mails Application: " . mysql_error()); email is a colomn in the table which is given from the flash file, the variables work fine!! the connection is established and the variables work, but still I keep getting this error message: error in SELECT Query Mails Application: 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 'WHERE subscribed= 'YES'' at line 1 I've tried everything, to change the variable YES, the upper brackets and so on, but nothing seemed to help.. Can anyone help me please??? Thanks already!! Sorry, the meaning of this code is, that a person can provide a name of a table in a flash swf and that this table is chosen from the db which is given in the php document above (this is all correct and tested out) I want to select all the emailadresses out of the table to put them in an array later on the code. But the select query can't seem to get any data and I just got that error message above mentionned, It is the PHPMyAdmin 2.6.2 which I'm using... Quote Link to comment Share on other sites More sharing options...
MartinBing Posted April 2, 2009 Author Share Posted April 2, 2009 Hello everybody I've been using PHP and MySQL for a little while now and I've noticed that sometimes my codes work and don't work on another page (they sometimes give an error message and on another page they don't...) Last I've done this coding and it worked fine: $result = mysql_query("SELECT * FROM ".$table." WHERE email= '".$email."'",$DBConn) or die("error in SELECT Query Mails Application: " . mysql_error()); the meaning of this was to be able to use variables for the table and email which is given in with a flash form. This worked, i repeat THIS WORKED!!! But now I want something like this and I keep getting an error message when I've uploaded it to work. $result = mysql_query("SELECT email FROM ".$table." WHERE subscribed= '".$submit."'",$DBConn) or die("error in SELECT Query Mails Application: " . mysql_error()); email is a colomn in the table which is given from the flash file, the variables work fine!! the connection is established and the variables work, but still I keep getting this error message: error in SELECT Query Mails Application: 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 'WHERE subscribed= 'YES'' at line 1 I've tried everything, to change the variable YES, the upper brackets and so on, but nothing seemed to help.. Can anyone help me please??? Thanks already!! Sorry, the meaning of this code is, that a person can provide a name of a table in a flash swf and that this table is chosen from the db which is given in the php document above (this is all correct and tested out) I want to select all the emailadresses out of the table to put them in an array later on the code. But the select query can't seem to get any data and I just got that error message above mentionned, It is the PHPMyAdmin 2.6.2 which I'm using... MySQL 4.0.24_Debian-10-log is the MySQL version it runs on... Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 2, 2009 Share Posted April 2, 2009 Quit quoting your own posts. We have already seen them. Just use the "reply" menu link and not the "quote" button. Quote Link to comment Share on other sites More sharing options...
MartinBing Posted April 2, 2009 Author Share Posted April 2, 2009 Based on the error message, $table is probably empty. How about forming your query string in a variable so that you can echo it out to see what it actually is. You were right, I was testing it without giving anything in the boxes, but when I did give anything in the boxes, it didn't changed anything on my page, it didn't echo the value of the vars.. My other page worked, because there was an 'if' statement. Therefore I never saw an error message, but it does select the query. Do you know how that is? Thanks Quote Link to comment Share on other sites More sharing options...
fenway Posted April 3, 2009 Share Posted April 3, 2009 Therefore I never saw an error message, but it does select the query. Do you know how that is? Thanks What? Quote Link to comment 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.