Re: Problem with implode() function

From: Date: Thu, 18 Jul 2002 23:15:03 +0000
Subject: Re: Problem with implode() function
Groups: php.general 
Request: Send a blank email to php-general+get-108375@lists.php.net to get a copy of this message
>Hi, > I have an array of elements which are separated with the operator >comma(,). > >================================================== > $array = implode(",", $checkb); > > echo $array.'\n'; > > $result = mysql_query("DELETE FROM temp WHERE inv_tag IN >($array)") or die('Error in query'.mysql_error()); >==================================================== > > >PTX526_P_1,SIM_1 > >Error in query Unknown column 'PTX526_P_1' in 'where clause'. Do this: $query = "DELETE FROM temp WHERE inv_tag IN ($array)"; echo $query."<BR>\n"; $result = mysql_query($query) ... What's happening is that you are telling MySQL this: delete from temp where inv_tag in (PTX526_P_1,SIM_1) Since there are no apostrophes on PTX526_P_1, MySQL figures they must be COLUMN names. You need it to look like this: delete from temp where inv_tag in (PTX526_P_1,SIM_1) which means you need: $array = implode("','", $checkb); and then: $query = "DELETE FROM temp WHERE inv_tag IN ('$array')"; -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#108375) next »