Jump to content

SELECT....WHERE.....IN - unknown column in 'where' clause


RLJ

Recommended Posts

Hi all,

 

I have the following code, and it's not working, and I can't work out why not:

$transcheck = $_POST['transcheck'];  //is an array
$IDs        = implode (',',$transcheck);
echo $IDs;

$link = mysql_connect  ('localhost', 'root');
if (!$link) {die('Could not connect: ' . mysql_error());}

$selectDB = mysql_select_db ('database', $link);
if (!$selectDB) {die('Could not select database: ' . mysql_error());}
    
$result= mysql_query 
(" 
    SELECT email FROM sometable WHERE ID IN(".$IDs.")
");
if (!$result) {die('Could not search database: ' . mysql_error());}

 

I get the following error message:

 

Unknown column 'c5a2bca6' in 'where clause'

 

where c5a2bca6 is one of the IDs from $transcheck.

 

if it's any help, the echo statement gives $IDs as:

c5a2bca6,493f6710,87004d13

 

Help pls! 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.