Error running locally but runs fine on website :(

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Error running locally but runs fine on website :(

Postby Angahran » 17. January 2010 02:48

Hi,
I'm having an issue with Xampp 1.7.2 and I can't put my finger on what the problem is.
I have the following snippet of code on my guilds everquest website and it runs fine.
However, when I run the same code on my local installation of Xampp I get these errors:

Failed to execute query.
Warning: Cannot modify header information - headers already sent by (output started at G:\htdocs\eqdkp\common.php:68) in G:\htdocs\eqdkp\includes\functions.php on line 430


Code: Select all
/**
* Part for checking black listed IP-s.
*/

   $con = mysql_connect($dbhost, $dbuser, $dbpass);
   mysql_select_db($dbname);

   while (true) {
      $sql = "SELECT *"
      . " FROM `blacklist`"
      . " WHERE `ip` = '" . mysql_real_escape_string($_SERVER['REMOTE_ADDR']) . "'";

      if (($mysqlRez = mysql_query($sql)) === false) {
      echo 'Failed to execute query.';
      break;
      }

      if (mysql_num_rows($mysqlRez) > 0) {
//      die('Your IP is on our blacklist');
      header("location: http://www.google.com/");
      exit();
      break;
      }
   break;

   }
Angahran
 
Posts: 10
Joined: 17. July 2009 19:45

Re: Error running locally but runs fine on website :(

Postby newbtophp » 17. January 2010 02:58

This is not an xampp related issue, its a php code issue.

Use this code:
Code: Select all
/**
* Part for checking black listed IP-s.
*/
ob_start();
   $con = mysql_connect($dbhost, $dbuser, $dbpass);
   mysql_select_db($dbname);

   while (true) {
      $sql = "SELECT *"
      . " FROM `blacklist`"
      . " WHERE `ip` = '" . mysql_real_escape_string($_SERVER['REMOTE_ADDR']) . "'";

      if (($mysqlRez = mysql_query($sql)) === false) {
      echo 'Failed to execute query.';
      break;
      }

      if (mysql_num_rows($mysqlRez) > 0) {
//      die('Your IP is on our blacklist');
      header("location: http://www.google.com/");
      exit();
      break;
      }
   break;

   }
ob_flush();
newbtophp
 
Posts: 12
Joined: 21. December 2009 18:12

Re: Error running locally but runs fine on website :(

Postby Angahran » 17. January 2010 03:07

Thanks for the reply.
Wouldn't that just simply hide the warning message ?

I've found my mistake.
Apparently I was using an older dump of the database and it didn't actually have the 'blacklist' table in it :oops:

Thanks
Angahran
 
Posts: 10
Joined: 17. July 2009 19:45


Return to XAMPP for Windows

Who is online

Users browsing this forum: ben.mansuk, JJ_Tagy and 57 guests