我使用下面的代码传递数组值到MySQL查询,但数组字符串转换错误会阵列串皈依错误在PHP
$sql =mysql_query("SELECT userId from groupmembers where groupId='$groupId'");
$bjson = array();
$i = 0;
while($result=mysql_fetch_assoc($sql))
{
$bjson[$i]['userId'] = $result['userId'];
$i++;
}
$query = "SELECT firstName
FROM users
WHERE userId IN('" . implode("','", $bjson) ."')";
[你的脚本是在对SQL注入攻击的风险。(http://stackoverflow.com/questions/60174/how-可以防止SQL注入在PHP) –
请[停止使用'mysql_ *'功能](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-在-PHP)。 [这些扩展](http://php.net/manual/en/migration70.removed-exts-sapis.php)已在PHP 7中删除。了解[编写](http://en.wikipedia.org/ wiki/Prepared_statement)语句[PDO](http://php.net/manual/en/pdo.prepared-statements.php)和[MySQLi](http://php.net/manual/en/mysqli.quickstart .prepared-statements.php)并考虑使用PDO,[这真的很简单](http://jayblanchard.net/demystifying_php_pdo.html)。 –
该死的弃用和删除功能了! – rray