Jump to content

PHP Select doesn't work


MartinBing

Recommended Posts

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!!

 

Link to comment
Share on other sites

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...

 

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.