运行php脚本时出现http 500错误

时间:2016-09-21 02:15:11

标签: php mysql mysqli

我在连接到MySQL数据库的网络服务器上运行PHP脚本,并且应该重定向到链接,但是,每当我的网站将我重定向到php脚本时,它都会出现http 500错误。我已经看了很多关于这个的其他帖子,似乎没有任何东西可以修复它。我已经确认文件权限是正确的,无法弄清楚它可能无法正常工作的原因。

如果有任何帮助,域名主机是x10 Hosting,这是php脚本:

<?php
$servername = "localhost";
$username = "nicx10m3_admin"; 

$password = "adminpass";

$dbname = "nicx10m3_nimble";

$var = $_POST['var'];

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

   die("Connection failed: " . $conn->connect_error);

}

$result = $conn->query("SELECT nimblecode, urlredirect, messageredirect  FROM linker WHERE nimblecode = '%s', $var);

if (!$result) {

   echo 'Could not run query: ' . mysql_error();      exit;

}

if ($result->num_rows > 0) {
   $row = $result->fetch_assoc();

   echo "id: " . $row["nimblecode"]. "
   //// URL: " . $row["urlredirect"]. "

   //// Message: " . $row["messageredirect"]. "
";

}
if ($row["messageredirect"] == "") {

   header('Location: ' . $row["urlredirect"]);

} else if ($row["nimblecode"] != "") {

   header('Location: http://nic.x10.mx/message?' . $row["nimblecode"]);

} else {
   header('Location: http://nic.x10.mx/');
   }
$conn->close();
  ?>

1 个答案:

答案 0 :(得分:-1)

尝试更改为此并告诉我结果:

if ($row["messageredirect"] == "") {

    echo "<script>alert('1');</script>";

} else if ($row["nimblecode"] != "") {

    echo "<script>alert('2');</script>";

} else {
    echo "<script>alert('3');</script>";
}