Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

98 users online



help wit my first OO script

help wit my first OO script

Currently viewing this thread: 1 (0 members and 1 guests)


Chippo

Chippo

Status: Offline!

help wit my first OO script

Hi,
I have just started to learn OO php and i keep gettin these errors ....

Quote:

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:

<?php
$this
->title '$sitename - Powered by iChipNews 1.0';
?>

but i don't understand the second error as in functions.php i have put

PHP:

<?php
class sql {
?>


which i have obviously placed all my code in, could someone please help me
Regards
Chippo

amplify

amplify

I'm a Neverside Newbie?
Status: Offline!

we need to see the whole script, or alteast the lines around line 15.

ajprules23

ajprules23

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 ]

php_brian

php_brian

Status: Offline!

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

Chippo

Chippo

Status: Offline!

Here is the source for my functions.php which is where i get the first error
Click Here

midsummerstorm

midsummerstorm

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
...

stewis

stewis

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 Smile**

trunks

trunks

asdf
Status: Offline!

$this->title = "$sitename - Powered by iChipNews 1.0";

should be
var $title = "$sitename - Powered by iChipNews 1.0";

amplify

amplify

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.

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0081 seconds.