gpt4 book ai didi

PHP/MySQL 查询和 mysql_fetch_array() 行的字符串连接

转载 作者:行者123 更新时间:2023-11-29 09:06:35 25 4
gpt4 key购买 nike

这有效:

$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

http://php.net/pdo

而不是标准的 mysql_*

关于PHP/MySQL 查询和 mysql_fetch_array() 行的字符串连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6887700/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com