Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

got this weird error after uploading files into webhost

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

got this weird error after uploading files into webhost

Postby iso-latte-d » Sun Jul 27, 2003 7:54 am

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: Select all
<?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: Select all
....
<?php
    include("../database.inc");
    /*line19*/$database = new Database();
.....


what could be the reason that triggered this error message?
User avatar
iso-latte-d
New php-forum User
New php-forum User
 
Posts: 14
Joined: Tue Jul 22, 2003 5:38 pm
Location: Melbourne, Australia

Postby iso-latte-d » Sun Jul 27, 2003 9:45 pm

is there anyone out there can help me?
i'm totally clueless....
User avatar
iso-latte-d
New php-forum User
New php-forum User
 
Posts: 14
Joined: Tue Jul 22, 2003 5:38 pm
Location: Melbourne, Australia

Postby pootergeist » Mon Jul 28, 2003 1:11 am

;

add one of them at line 11 of the class

then one at line 13
pootergeist
New php-forum User
New php-forum User
 
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK

Postby iso-latte-d » Mon Jul 28, 2003 2:18 am

hi there,
thanks for the reply...

Code: Select all
....
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: Select all
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... :?
User avatar
iso-latte-d
New php-forum User
New php-forum User
 
Posts: 14
Joined: Tue Jul 22, 2003 5:38 pm
Location: Melbourne, Australia

Postby pootergeist » Mon Jul 28, 2003 6:38 am

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.
pootergeist
New php-forum User
New php-forum User
 
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK

Postby iso-latte-d » Mon Jul 28, 2003 8:22 am

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....
User avatar
iso-latte-d
New php-forum User
New php-forum User
 
Posts: 14
Joined: Tue Jul 22, 2003 5:38 pm
Location: Melbourne, Australia

Postby Joel » Mon Jul 28, 2003 1:41 pm

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: Select all
  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());
     }
Joel
New php-forum User
New php-forum User
 
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand

Postby iso-latte-d » Tue Jul 29, 2003 6:06 pm

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?
User avatar
iso-latte-d
New php-forum User
New php-forum User
 
Posts: 14
Joined: Tue Jul 22, 2003 5:38 pm
Location: Melbourne, Australia

Postby Joel » Tue Jul 29, 2003 11:32 pm

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.
Joel
New php-forum User
New php-forum User
 
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand

Postby Redcircle » Wed Jul 30, 2003 11:52 am

did it fix itself...?
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

what i did

Postby iso-latte-d » Thu Jul 31, 2003 4:26 am

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...
User avatar
iso-latte-d
New php-forum User
New php-forum User
 
Posts: 14
Joined: Tue Jul 22, 2003 5:38 pm
Location: Melbourne, Australia

Postby Joel » Thu Jul 31, 2003 9:25 pm

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.
Joel
New php-forum User
New php-forum User
 
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron