我开始使用mysqli,我让它在我的虚拟服务器上工作,但无法让它在我的真实服务器上工作。数据库是一样的。我试过了store和get_result。知道我做错了什么吗?
我尝试回显,打印或var_dump的所有内容都不会在执行后显示IF Place,但命令将被执行。它在UPDATE和INSERT上运行良好。
<?php
$mysqli = new mysqli("127.0.0.1", "user", "pass", "db", 3306);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
echo $mysqli->host_info . "\n";
$sam = 1;
$stmt = $mysqli->prepare("SELECT released FROM svers");
$stmt->execute();
echo "#";
var_dump($sam);
$res = $stmt->get_result();
var_dump($res);
$row = $res->fetch_assoc();
var_dump($row);
$mysqli->close();
host_info显示为“127.0.0.1 via TCP / IP”,然后#I在if()内部回显,但无法从我的数据库中获取任何内容。甚至$ row []信息之间的其他#也没有显示。这是我的代码:
<?php
$mysqli = new mysqli("127.0.0.1", "user", "password", "database", 3306);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
echo $mysqli->host_info . "\n";
$stmt = $mysqli->prepare("SELECT * FROM svers ORDER BY released DESC LIMIT 1");
if ($result = $stmt->execute()){
echo "#";
$result = $stmt->get_result();
$row = $result->fetch_array(MYSQLI_BOTH);
echo $row['version'] . "#" . $row['released'] . "#" . $row['note'];
$stmt->free_result();
}else {
echo "error";
}
$mysqli->close();
?>
答案 0 :(得分:1)
好的问题解决了。我真正的服务器不支持mysqlnd所以不能使用get_result()。谢谢你的帮助!
答案 1 :(得分:0)
您说got it working on my virtual server but can't get it working on my real server
。
然后检查真实服务器上的svers
表是否包含任何数据。