我在 xampp 上运行以下代码(完美安装)。我已经用 mysqli 替换了 mysql 并重新排列了查询(先连接,稍后插入语句),但都无济于事。请帮忙。
错误:警告:mysql_query() 期望参数 2 是资源,第 19 行 C:\xampp\htdocs\test.php 中给出的字符串
<?php
$hname = "localhost";
$username = "root";
$password = "";
$db = "test";
$connect = mysql_connect($hname, $username, $password, $db);
if ($connect) {
echo "Connected to Database <br /> <br />";
$ins = "INSERT INTO 'test'.'testtable' (name) VALUES ('james')";
//mysql_select_db ($connect, "users");
if (mysql_query("INSERT INTO 'test'.'testtable' (name) VALUES ('james')", "mysql_connect($hname, $username, $password, $db)")) {
echo "Values Entered Successfully. Your Account was created";
} else {
echo "Your Account was not created";
}
} else {
echo "Failed to Connect :(";
}
?>