implode in where class

hi friends
I am having a problem with array while using it in “select” statement
that array contains the following strings
Array
(
[0] => M.A.JINNA
[1] => K.DHANA RAJU
[2] => B.EPHRIM
)
now I am getting error like this: 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 ‘‘M.A.JINNA,K.DHANA RAJU,B.EPHRIM’’ at line 1
please give me any suggestions, thanks in advance
NOTE: I cannot use employee id instead of employee name due to client request

the code is

[php]<?php
$emp = implode( ‘,’, $employee );
echo ‘

’; print_r($emp); echo ‘
’;

$sql = “SELECT * FROM securitystaffdetails WHERE employeename IN '” . $emp . “’”;
$result = mysql_query($sql) or die(mysql_error());

echo “

”;
echo “”;
echo “
”;
	echo "<td>Address</td>";

	echo "<td>DOB</td>";
	
	echo "<td>Age</td>";
            
            echo "<td>SEx</td>";
	
	echo "<td>Mobile Number</td>";

	echo "<td>Blood Group</td>";

	echo "<td>ID Card</td>";

	echo "<td>Ex Army Idcard</td>";

	echo "<td>Police Clearence</td>";

	echo "<td>ESI Card</td>";

	echo "<td>PF Account</td>";

	echo "<td>PAN Card</td>";

	echo "<td>Voter ID</td>";

	echo "<td>Ration/Family</td>";
	
	echo "</b></tr>";

$employee = array();

while($record = mysql_fetch_object($result))
{
echo “

”;
echo ("");
echo ("");
echo ("");
echo ("");
echo ("");
echo ("");
echo ("");
echo ("");
echo ("");
echo ("");
echo ("");
echo ("");
echo ("");
echo ("");
echo ("");
echo ("");
echo"";
}


echo"</table>";

?> [/php]

Employee Name
$record[employeename]$record[address]$record[dob]$record[age]$record[sex]$record[mobn]$record[bg]$record[icard]$record[exarmycard]$record[policeclearence]$record[esicard]$record[pfa]$record[pancard]$record[acard]$record[vcard]$record[rcard]

I think you are just missing the parenthesis…

Change:

[php]$sql = “SELECT * FROM securitystaffdetails WHERE employeename IN '” . $emp . “’”;[/php]

To:

[php]$sql = “SELECT * FROM securitystaffdetails WHERE employeename IN (’” . $emp . “)’”;[/php]

You also might need to change…

[php]$emp = implode( ‘,’, $employee );[/php]

To

[php]$emp = “’” . implode( “’,’”, $employee ) . “’”;[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service