zero-perfoliate
zero-perfoliate

Author Topic: I've inherited a site.. joy!  (Read 262 times)

Offline tequilaprince

  • New PHP Members
  • Posts: 3
  • Karma: +0/-0
I've inherited a site.. joy!
« on: March 23, 2010, 06:21:41 AM »
Hi All,

I've just inherited a site with the task of fixing a few bits and adding a few new bits as well.  I've used PHP for a couple of years but have always written it from scratch myself and am having trouble trying to get the site to work on my local machine.  Here's the specific problem..

User enters their username and password which are submitted to:-

/*adminlogin.php*/

session_start();
session_register('auth');
session_register('logname');
session_register('IsAdmin');
session_register('MemberName');
   echo("1");
   include("include/MSEngine.php");
   echo("2");
   $db = new Database();

/* Database class found in another file, code below.... */
class Database
{

   function Database()
   {
   

       $db_server = "localhost";
      $db_user = "**MY USER**";
      $db_password = "**MY PASS **";
      $db_database = "**MY DB**";      

      echo("3");
      $this->connection = @mysql_connect($db_server, $db_user, $db_password);
      echo("4");

      mysql_select_db($db_database) or die(mysql_error());
      echo("5");
   }


   function close()
   {
      @mysql_close($this->connection);
   }
}
/* back to calling page */

   $IsAdmin = '0';
   echo("6");

I put the echo's in to trace where the problem lies and I'm getting 123 then nothing, tried mysql_error and also turning E_ALL errors on but nothing.  Without the echo's I just get the blank page so I'm a little stuck.. the annoying thing is it works on the live site fine!

My PHP is 5.2.13 the site is on 5.2.12, the database connection variables are definitely OK.

Anyone spot the no-doubt simple problem??

Cheers

Offline ben_carroll89

  • PHP Workers
  • **
  • Posts: 6
  • Karma: +0/-0
Re: I've inherited a site.. joy!
« Reply #1 on: March 24, 2010, 01:27:42 PM »
I don't see anything off the bat.  Does a simple mysql_connect('a','b'c') or die(mysql_error()); work?

E.g. without the variable setting (take out $this->connection =) and with INCORRECT user/pass -- you should see the mySQL error.  Let's see if that works?  If not, there is a problem with your mySQL lib.

If you get the error, replace the correct mysql_connect that you have now, just without the variable setting.  If it stops working then obviously it's the $this->connection =

I also notice that you do not have $connection defined in the class, so maybe you need to add:
private $connection; in your class {} definition.

I'm curious to know about the results of those tests if it's not the simple $connection missing thing


Thanks,
Ben Carroll
http://www.ntertech.com

Offline tequilaprince

  • New PHP Members
  • Posts: 3
  • Karma: +0/-0
Re: I've inherited a site.. joy!
« Reply #2 on: March 25, 2010, 06:46:55 AM »
Hi Ben,

Thanks for the reply!  I've taken away the this->connection and also removed the @ infront of mysql_connection.. this gave me an unknown function call?!  If I leave the @ then I get the same 'blank' output showing just 123.  Have added or die(mysql_error()) as well but nothing.

      /*Gives me' Call to undefined function mysql_connect()*/
      echo("3");
      mysql_connect($db_server, $db_user, $db_password);
      echo("4");

      /*Gives me 123*/
      echo("3");
      @mysql_connect($db_server, $db_user, $db_password);
      echo("4");

I copied libmysql.dll over to the PHP folder again.

Would my version of MySQL (5.1.30) have anything to do with it possibly?

Glad I'm not the only one stumped!!

 

zero-perfoliate