在 Php 中使用 Mysql 错误 500
Error 500 Using Mysql In Php
有人可以向我解释一下我的代码有什么问题吗?当我尝试访问该页面时,它只是给我一个 HTTP 错误 500。这是代码。
<?php
$conn = new mysqli("localhost","user","pass","db");
if(!empty($_GET['Info']))
{
$Info = $_GET['Info'];
$sql = "SELECT * FROM `Judges` WHERE `id` EQUALS $Info";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
while($rows = $result->fetch_assoc())
{
$PictureFile = Null
if(empty($rows["PictureFile"]))
{
$PictureFile = "MissingPicture.png";
}
else
{
$PictureFile = $rows["PictureFile"];
}
echo '<div><img src="' . $PictureFile . '" style="width=100px;height=100px;"> <p>This Is Just A Test Message!</p></div>';
}
}
else
{
echo "<p style='text-align: center;'>Your Search Came Back With 0 Results :(</p>";
}
}
$conn->close();
?>
在$PictureFile = Null
末尾添加;
你忘了一个;在这个命令行之后
$PictureFile = Null
我无法测试脚本,但它一定能解决您的问题。
将 EQUALS 更改为 =
并添加 ;在 $PictureFile = Null
之后
<?php
$conn = new mysqli("localhost","user","pass","db");
if(!empty($_GET['Info']))
{
$Info = $_GET['Info'];
$sql = "SELECT * FROM `Judges` WHERE `id`= $Info";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
while($rows = $result->fetch_assoc())
{
$PictureFile = Null;
if(empty($rows["PictureFile"]))
{
$PictureFile = "MissingPicture.png";
}
else
{
$PictureFile = $rows["PictureFile"];
}
echo '<div><img src="' . $PictureFile . '" style="width=100px;height=100px;"> <p>This Is Just A Test Message!</p></div>';
}
}
else
{
echo "<p style='text-align: center;'>Your Search Came Back With 0 Results :(</p>";
}
}
$conn->close();
?>
有人可以向我解释一下我的代码有什么问题吗?当我尝试访问该页面时,它只是给我一个 HTTP 错误 500。这是代码。
<?php
$conn = new mysqli("localhost","user","pass","db");
if(!empty($_GET['Info']))
{
$Info = $_GET['Info'];
$sql = "SELECT * FROM `Judges` WHERE `id` EQUALS $Info";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
while($rows = $result->fetch_assoc())
{
$PictureFile = Null
if(empty($rows["PictureFile"]))
{
$PictureFile = "MissingPicture.png";
}
else
{
$PictureFile = $rows["PictureFile"];
}
echo '<div><img src="' . $PictureFile . '" style="width=100px;height=100px;"> <p>This Is Just A Test Message!</p></div>';
}
}
else
{
echo "<p style='text-align: center;'>Your Search Came Back With 0 Results :(</p>";
}
}
$conn->close();
?>
在$PictureFile = Null
;
你忘了一个;在这个命令行之后
$PictureFile = Null
我无法测试脚本,但它一定能解决您的问题。
将 EQUALS 更改为 =
并添加 ;在 $PictureFile = Null
<?php
$conn = new mysqli("localhost","user","pass","db");
if(!empty($_GET['Info']))
{
$Info = $_GET['Info'];
$sql = "SELECT * FROM `Judges` WHERE `id`= $Info";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
while($rows = $result->fetch_assoc())
{
$PictureFile = Null;
if(empty($rows["PictureFile"]))
{
$PictureFile = "MissingPicture.png";
}
else
{
$PictureFile = $rows["PictureFile"];
}
echo '<div><img src="' . $PictureFile . '" style="width=100px;height=100px;"> <p>This Is Just A Test Message!</p></div>';
}
}
else
{
echo "<p style='text-align: center;'>Your Search Came Back With 0 Results :(</p>";
}
}
$conn->close();
?>