Connecting Tech Pros Worldwide Forums | Help | Site Map

php error

newbie
Guest
 
Posts: n/a
#1: Feb 11 '06
hi can anyone tell me why i am receiving error msg with this php script


<?php
require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");

$connection = mysql_connect($db_host,$db_user,$db_passwword) or
die
("no connection");
echo "connection established";

?>


// this is the error message i am receiving.

Parse error: syntax error, unexpected T_VARIABLE in
C:\webroot\config\db_config.php on line 2

// I am using apache webserver 2.0 and php version 4.0 thankyou very
much
for your help.
// i am trying to access mysql database.

anyhelp will be appreciated

Marcus


noone
Guest
 
Posts: n/a
#2: Feb 11 '06

re: php error


newbie wrote:[color=blue]
> hi can anyone tell me why i am receiving error msg with this php script
>
>
> <?php
> require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");
>
> $connection = mysql_connect($db_host,$db_user,$db_passwword) or
> die
> ("no connection");
> echo "connection established";
>
> ?>
>
>
> // this is the error message i am receiving.
>
> Parse error: syntax error, unexpected T_VARIABLE in
> C:\webroot\config\db_config.php on line 2
>
> // I am using apache webserver 2.0 and php version 4.0 thankyou very
> much
> for your help.
> // i am trying to access mysql database.
>
> anyhelp will be appreciated
>
> Marcus
>[/color]

To what does $_SERVER["DOCUMENT_ROOT"] translate? (should really be
$_SERVER['DOCUMENT_ROOT']

before the above require statement add the following to see...
echo $_SERVER['DOCUMENT_ROOT']."/config/db_config.php\n";
echo $_SERVER["DOCUMENT_ROOT"]."/config/db_config.php\n";
flush();
newbie
Guest
 
Posts: n/a
#3: Feb 11 '06

re: php error


when i added those statements, the root folder and the paths were
displayed...could it be that there is something wrong with the
db_config.php file?

thanks

Jerry Stuckle
Guest
 
Posts: n/a
#4: Feb 11 '06

re: php error


noone wrote:[color=blue]
>
> To what does $_SERVER["DOCUMENT_ROOT"] translate? (should really be
> $_SERVER['DOCUMENT_ROOT']
>
> before the above require statement add the following to see...
> echo $_SERVER['DOCUMENT_ROOT']."/config/db_config.php\n";
> echo $_SERVER["DOCUMENT_ROOT"]."/config/db_config.php\n";
> flush();[/color]

No, the way he has it will work. It may be a little slower - but
there's no problem with it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Jerry Stuckle
Guest
 
Posts: n/a
#5: Feb 11 '06

re: php error


newbie wrote:[color=blue]
> hi can anyone tell me why i am receiving error msg with this php script
>
>
> <?php
> require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");
>
> $connection = mysql_connect($db_host,$db_user,$db_passwword) or
> die
> ("no connection");
> echo "connection established";
>
> ?>
>
>
> // this is the error message i am receiving.
>
> Parse error: syntax error, unexpected T_VARIABLE in
> C:\webroot\config\db_config.php on line 2
>
> // I am using apache webserver 2.0 and php version 4.0 thankyou very
> much
> for your help.
> // i am trying to access mysql database.
>
> anyhelp will be appreciated
>
> Marcus
>[/color]

Marcus,

It this file included by another one, perchance? If so, you may have
mis-matched quotes in that file.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
newbie
Guest
 
Posts: n/a
#6: Feb 11 '06

re: php error


now i am getting a different error..but i think we getting close, this
is the new error msg:


Fatal error: Call to undefined function mysql_connect() in
C:\webroot\temp_con.php on line 9


this is the code:

<?php

echo $_SERVER['DOCUMENT_ROOT']."/db_config.php\n";
echo $_SERVER["DOCUMENT_ROOT"]."/db_config.php\n";
flush();
require($_SERVER['DOCUMENT_ROOT']."/db_config.php");


$connection = mysql_connect($db_host,$db_user,$db_password) or
die ("no connection");
echo "connection established";

?>

i appreciate all of your help

Marcus

Kim André Akerĝ
Guest
 
Posts: n/a
#7: Feb 11 '06

re: php error


newbie wrote:
[color=blue]
> now i am getting a different error..but i think we getting close, this
> is the new error msg:
>
>
> Fatal error: Call to undefined function mysql_connect() in
> C:\webroot\temp_con.php on line 9
>
>
> this is the code:
>
> <?php
>
> echo $_SERVER['DOCUMENT_ROOT']."/db_config.php\n";
> echo $_SERVER["DOCUMENT_ROOT"]."/db_config.php\n";
> flush();
> require($_SERVER['DOCUMENT_ROOT']."/db_config.php");
>
>
> $connection = mysql_connect($db_host,$db_user,$db_password) or
> die ("no connection");
> echo "connection established";
>
> ?>
>
> i appreciate all of your help[/color]

I'm guessing that you're using a PHP version for Windows that doesn't
have MySQL builtin, and the MySQL extension DLL hasn't been loaded.
Check your php.ini configuration file and enable it there.

You'll probably find php.ini either in c:\php or in your Windows
directory.

--
Kim André Akerĝ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Jim Michaels
Guest
 
Posts: n/a
#8: Feb 12 '06

re: php error



"newbie" <markcollins12@hotmail.com> wrote in message
news:1139687352.889919.238800@g14g2000cwa.googlegr oups.com...[color=blue]
> when i added those statements, the root folder and the paths were
> displayed...could it be that there is something wrong with the
> db_config.php file?[/color]

looked like it to me. missing semicolon? missing quote in a string?

[color=blue]
>
> thanks
>[/color]


Jim Michaels
Guest
 
Posts: n/a
#9: Feb 12 '06

re: php error



"noone" <noone@nowhere.com> wrote in message
news:InqHf.27272$Jd.15753@newssvr25.news.prodigy.n et...[color=blue]
> newbie wrote:[color=green]
>> hi can anyone tell me why i am receiving error msg with this php script
>>
>>
>> <?php
>> require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");
>>
>> $connection = mysql_connect($db_host,$db_user,$db_passwword) or
>> die
>> ("no connection");
>> echo "connection established";
>>
>> ?>
>>
>>
>> // this is the error message i am receiving.
>>
>> Parse error: syntax error, unexpected T_VARIABLE in
>> C:\webroot\config\db_config.php on line 2
>>
>> // I am using apache webserver 2.0 and php version 4.0 thankyou very
>> much
>> for your help.
>> // i am trying to access mysql database.
>>
>> anyhelp will be appreciated
>>
>> Marcus
>>[/color]
>
> To what does $_SERVER["DOCUMENT_ROOT"] translate? (should really be
> $_SERVER['DOCUMENT_ROOT'][/color]

doesn't matter which. PHP interprets both as a string just fine. nothing
special about it. Just depends on your style.
only thing that could make a difference is if that variable has a trailing /
in it. (echo it and find out) then you would want to remove the leading /
from "/config/db_config.php");
[color=blue]
>
> before the above require statement add the following to see...
> echo $_SERVER['DOCUMENT_ROOT']."/config/db_config.php\n";
> echo $_SERVER["DOCUMENT_ROOT"]."/config/db_config.php\n";
> flush();[/color]


Jasen Betts
Guest
 
Posts: n/a
#10: Feb 12 '06

re: php error


On 2006-02-11, noone <noone@nowhere.com> wrote:
[color=blue]
> To what does $_SERVER["DOCUMENT_ROOT"] translate?[/color]
[color=blue][color=green]
>> Parse error: syntax error, unexpected T_VARIABLE in
>> C:\webroot\config\db_config.php on line 2[/color][/color]

looks like it translates to

C:\webroot
[color=blue]
> (should really be $_SERVER['DOCUMENT_ROOT'][/color]

I don't see that the style of qoutes makes any differeence in that case
except possibly saving a few microseconds execution time.
[color=blue][color=green]
>> Parse error: syntax error, unexpected T_VARIABLE in
>> C:\webroot\config\db_config.php on line 2[/color][/color]

looks like the error is in the file mentioned above.
which I suspect is not the one newbie posted

--

Bye.
Jasen
newbie
Guest
 
Posts: n/a
#11: Feb 12 '06

re: php error


just run the command phpinfo() and mysql is not connected to php.
i cant seem to find the php.ini file. can you tell me where exactly i
can access this file. the only php.ini i found is not a text file and
cannot be opened.
can you pls help....thanks for the help so far

Marcus

Kim André Akerĝ
Guest
 
Posts: n/a
#12: Feb 12 '06

re: php error


newbie wrote:
[color=blue]
> just run the command phpinfo() and mysql is not connected to php.
> i cant seem to find the php.ini file. can you tell me where exactly i
> can access this file. the only php.ini i found is not a text file and
> cannot be opened.
> can you pls help....thanks for the help so far[/color]

What do you mean, it "is not a text file"? The php.ini file should be a
text configuration file, and you should be able to open it using
Notepad or your favorite text editor.

--
Kim André Akerĝ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Closed Thread