代码工作到昨天......然后wamp崩溃了......我重新安装了wamp并抛出错误
尝试获取非对象的属性
$con=mysqli_connect('localhost' ,'root' ,'' ,'images');
$result="SELECT * from images";
$stmt=$con->query($result);
if ($stmt->num_rows>0)
{
while ($row=mysqli_fetch_array($stmt))
{
echo '<img height="300" width="300" src="data:image;base64,'.$row[2].' "> ';
}
答案 0 :(得分:0)
首先检查天气,你的$ stmt在访问其孩子之前有内容。
的var_dump($语句);
答案 1 :(得分:0)
您尝试使用属性的代码中的两个对象是$stmt->num_rows
。
db中似乎有问题。
你能检查连接和数据库吗?
也许当你重新安装时,你清理数据库。
答案 2 :(得分:0)
根据您的代码,错误似乎是正确的,因为您只需使用
以对象的形式获得输出$con=mysqli_connect('localhost' ,'root' ,'' ,'images');
$result="SELECT * from images";
$stmt=$con->query($result);
if ($stmt->num_rows>0)
{
while ($row=mysqli_fetch_array->($stmt))
{
echo '<img height="300" width="300" src="data:image;base64,'.$row[2].' "> ';
}
答案 3 :(得分:0)
我希望您重新安装时不会重新创建/恢复images
数据库。但是,添加本应存在的错误检查应该可以确定问题。
此外,你应该坚持使用Proceedural或面向对象的mysqli,而不是像你一样混合2。
$con = new mysqli_connect('localhost' ,'root' ,'' ,'images');
if ($con->connect_error) {
die('Connect Error (' . $mysqli->connect_errno . ') '
. $mysqli->connect_error);
}
$sql = "SELECT * from images";
// $con->query returns a result object
$result = $con->query($result);
if ( ! $result ) {
die("Error: %s.\n", $stmt->error);
}
if ($result->num_rows > 0)
{
while ($row = $result->fetch_assoc())
{
echo '<img height="300" width="300" src="data:image;base64,'.$row[2].' "> ';
}
现在至少会向您显示在处理数据库期间发生的任何错误。