By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

function error

P: 2
Hi frnds,
I am new here......

the code i m posting here works good on php5
see the code...

file connection.inc

<?php

class DataBase
{

public $dbc;

public function myConnection()
{
$dbc=mysql_connect("localhost","root","");

if($dbc)
{
$db=mysql_select_db("abc");


if($db)
{
return "";


}

else
{
return "<h1><font color=red>DataBase Not Found</font></h1>";


}
}

else
{
return "<h1><font color=red>Eroor Connecting to mySql</font></h1>";


}

}
}
?>



but when i use it in my manage page and create the instance of the class it displays following error. The server i am using is php 4.4.4.

Parse error: syntax error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/alwang85/public_html/include/connection.inc on line 6

can u help me to solve this error.....
Dec 21 '07 #1
Share this Question
Share on Google+
3 Replies


nathj
Expert 100+
P: 938
Hi frnds,
I am new here......

the code i m posting here works good on php5
see the code...

file connection.inc

<?php

class DataBase
{

public $dbc;

public function myConnection()
{
$dbc=mysql_connect("localhost","root","");

if($dbc)
{
$db=mysql_select_db("abc");


if($db)
{
return "";


}

else
{
return "<h1><font color=red>DataBase Not Found</font></h1>";


}
}

else
{
return "<h1><font color=red>Eroor Connecting to mySql</font></h1>";


}

}
}
?>



but when i use it in my manage page and create the instance of the class it displays following error. The server i am using is php 4.4.4.

Parse error: syntax error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/alwang85/public_html/include/connection.inc on line 6

can u help me to solve this error.....

Hi,
First just as a tip on this forum, please use the code tags to submit your code - it makes it easier to read and therefore help.

So onto the solution. I had this issue when a server changed down from 5.

The trouble is that you can't define public functions on php4. If you change the function so that it is not public or upgrade the server to PHP5 - the better option I think.

Cheers
nathj
Dec 21 '07 #2

P: 2
Hi,
First just as a tip on this forum, please use the code tags to submit your code - it makes it easier to read and therefore help.

So onto the solution. I had this issue when a server changed down from 5.

The trouble is that you can't define public functions on php4. If you change the function so that it is not public or upgrade the server to PHP5 - the better option I think.

Cheers
nathj
thank you !

it is working now :)
Dec 24 '07 #3

nathj
Expert 100+
P: 938
thank you !

it is working now :)
Excellent, I'm glad to have helped out.

Cheers
nathj

Ps If there's ever anything else come back to The Scipts - people here lvoe to help.
Dec 24 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.