got this weird error after uploading files into webhost

A

Anonymous

Guest
ok,
this is the error message i got:
"Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `'{'' or `'$'' in .../htdocs/database.inc on line 11"

"Fatal error: Cannot instantiate non-existent class: database in .../htdocs/parentclient/parentlist.php on line 19"

i didn't get this in localhost, it's so weird...and frustrating.

what is in database.inc line 11?
Code:
<?php
  class Database
  {
     var $connection = null;
     var $result =  null;
     var $row = null;
  	
     function Database()
     {
        /*line11*/$this->connection = mysql_connect("localhost","user")
  	  or die("Could not connect: " .mysql_error());	
        mysql_select_db("db")  
  	  or die("Could not select database: " .mysql_error());
     }
......


what is in parentlist.php line 19?
Code:
....
<?php
    include("../database.inc");
    /*line19*/$database = new Database();
.....

what could be the reason that triggered this error message?
 
is there anyone out there can help me?
i'm totally clueless....
 
;

add one of them at line 11 of the class

then one at line 13
 
hi there,
thanks for the reply...

Code:
....
function Database() 
     { 
        $this->connection = mysql_connect("localhost","user") 
       or die("Could not connect: " .mysql_error());    
        mysql_select_db("db")  
       or die("Could not select database: " .mysql_error()); 
     } 
....

aren't these supposed to be a continuation of a statement?
like,
Code:
connection = mysql_connect("") or die("");

anyway, if i were missing ';', i would've got this error message in my localhost. it worked fine in my localhost, but after i uploaded it into my webhost, that error came up.
that's the weird part... :?
 
yeah oops - ignore that ; bit, didn't read the 'or die' lines (never use them myself)

maybe your host won't accept the mysql_connect without the third parameter "password"

other than that, it looks ok tome.
 
the db connection didn't use any password, but i tried with ("") or without password parameter. still didn't work...
what's really weird is that it seems it didn't recognise the database class at all.
well, thanks anyway for the reply....
 
I had this same problem with the fatal error. That means your class is returning false because of error (the expecting string or variable). Mine was returning false because it had a function which was too new for the PHP version on the server.

Try this, I'm just guessing here though.



Code:
  class Database 
  { 
     var $connection; 
     var $result; 
     var $row; 
      
     function Database() 
     { 
        /*line11*/$this->connection = mysql_connect("localhost","user") 
       or die("Could not connect: " .mysql_error());    
        mysql_select_db("db")  
       or die("Could not select database: " .mysql_error()); 
     }
 
thanks...
it's actually working...
i guess you're right about the php version. i have ver 4.3.1, while the server has ver 4.3.2.
that should be not much difference, is it?
 
The change from 4.3.1 to 4.3.2 shouldnt make any difference, only older versions. I was using functions not available in the version on the server.

You must have something a little wrong with your code, thats all. Either way, I guess it doesn't matter now.
 
if you take a look at the code joel's posted and compared to my code, what's different is the part of variables declaration whereby i set it as null initially.
i just deleted the 'null' thingie, and it worked.
that's why i'm still wondering how different is version 4.3.1 and version 4.3.2...

btw, i host it in tripod.lycos...and they also provide online tools for building websites (one of them is php4u) and i read it in their php configuration that their php4u is based on php version 4.3.2.
could it be the reason? i mean based on what they said, it's not really a real php, if you know what i mean...
 
It's probably just got somethings in the source code changed so people can only do so much. I'm not sure why it would be working on your home server but not on their server.
 
Back
Top