这有效:
$row = mysql_fetch_array($result);
$accountID = $row['accountID'];
queryMysql('INSERT INTO accounts (accountID, password) VALUES (' .
"'$accountID'" . ', \'a\')');
但这不是:
$row = mysql_fetch_array($result);
queryMysql('INSERT INTO accounts (accountID, password) VALUES (' .
$row['accountID'] . ', \'a\')');
为什么?
最佳答案
因为您在 $row['accountId'] 之前和之后缺少另一个 '
$row = mysql_fetch_array($result);
queryMysql('INSERT INTO accounts (accountID, password) VALUES (\'' .
$row['accountID'] . '\', \'a\')');
如果您刚开始使用 PHP 并拥有所需的 PHP 版本(5.1.0),我强烈建议您开始使用 PDO
而不是标准的 mysql_*
关于PHP/MySQL 查询和 mysql_fetch_array() 行的字符串连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6887700/