-1

I'm running a PHP script on a webserver that connects to a MySQL database and is supposed to redirect to a link, but instead, whenever my site redirects me to the php script, it gives a http 500 error. I've looked at numerous other posts about this and nothing is seeming to fix it. I've confirmed file permissions are correct and cannot figure out why it may not be working.

If it is any help, the domain host is x10 Hosting, and here is the php script:

<?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();
  ?>
Nic
  • 76
  • 1
  • 1
  • 7

1 Answers1

-1

Try to change into this and tell me the result:

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

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

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

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

} else {
    echo "<script>alert('3');</script>";
}
androidism
  • 88
  • 9