
May 5th, 2003
10:31 PM
help wit my first OO script
Hi,
I have just started to learn OO php and i keep gettin these errors ....
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /usr/local/psa/home/vhosts/ichipnet.com/httpdocs/scripts/functions.php on line 15
Fatal error: Cannot instantiate non-existent class: sql in /usr/local/psa/home/vhosts/ichipnet.com/httpdocs/scripts/index.php on line 3
line 15 is
<?php
$this->title = '$sitename - Powered by iChipNews 1.0';
?>
but i don't understand the second error as in functions.php i have put
which i have obviously placed all my code in, could someone please help me
Regards
Chippo

May 5th, 2003
10:35 PM
I'm a Neverside Newbie?
Status: Offline!
we need to see the whole script, or alteast the lines around line 15.

May 6th, 2003
01:52 AM
Neverside Newbie
Status: Offline!
for one thing, that line 15 you gave us, if you want to have the value of $sitename put into the string you need to have double quotes not single quotes. Single quotes take a string literally, while double quotes will evaluate any variables in the string.
___________________
AJPRules23
[ http://aj.penninga.net ]

May 6th, 2003
05:45 AM
Also PHP will throw that second error at you everytime there is an error inside the class.
___________________
Why can't I put the recycle bin in the recycle bin?
brosner.com | coderforums.com

May 6th, 2003
04:43 PM
Here is the source for my functions.php which is where i get the first error
Click Here

May 6th, 2003
06:24 PM
28, Male & single, what else do you need to know?
Status: Offline!
Yeah, you'll get the Fatal error message till you fix the class and it can be parsed without problems.
Ok, looking at the code, it's obvious the first error is just because your code is out of the scope of any function. If you want that line to be executed for every object at creation time, then add a constructor function and put the code in it. Or simply set the default value for $title to that string on the var declaration. You can't have code in a class that's outside a function, apart from the variables declaration.
___________________
-~-~-~oO··Oo~-~-~-~-
I wish I was a messenger and all the news was good
I wish I was the full moon shining off your camaros hood
...

May 6th, 2003
07:30 PM
Neverside Newbie
Status: Offline!
i am fairly new to OOP try moving this into a function...
$this->title = '$sitename - Powered by iChipNews 1.0';
that maybe your problem.
___________________
Current status: Taken
Somethings Coming: 07/07/07
**stewis lubs Sarah
**

May 6th, 2003
08:13 PM
$this->title = "$sitename - Powered by iChipNews 1.0";
should be
var $title = "$sitename - Powered by iChipNews 1.0";

May 6th, 2003
10:39 PM
I'm a Neverside Newbie?
Status: Offline!
if line 15 is not in a function, trunks is right and stewis is wrong. otherwise, its vica versa.
and the function named the same as the class is always executed when the class is initiated.