HOME       >>       Programming

Unexpected T_variable... Help


alex1985

I did construct the database connection file which is called "config.php". But, I got some mistake that has to be solved to continue with working.

This is the code itself:

$confg['db_paswd']="" //Your database user's password
$confg['db_host']="localhost" //Your host
$confg['db_dbase']="books" //Your database name
//Create the function to log into the DB
function db_login() {
global $confg;
$link = @mysql_connect($confg['db_host'], $confg['db_uname'], $confg['db_paswd']) or die("Error connecting linenums:0'><?//Set the database values$confg['db_uname']="alex1985_admin" //Your database username$confg['db_paswd']="" //Your database user's password$confg['db_host']="localhost" //Your host$confg['db_dbase']="books" //Your database name//Create the function to log into the DBfunction db_login() {global $confg;$link = @mysql_connect($confg['db_host'], $confg['db_uname'], $confg['db_paswd']) or die("Error connecting: " . mysql_error());@mysql_select_db($confg['db_dbase'], $link);}//Create the function for logging out from the DBfunction db_logout() {@mysql_close($link);}?>
But, this is the message the browser gives me when I am trying to initiate that constructed file.

"Parse error: syntax error, unexpected T_VARIABLE in /home/alex1985/public_html/mulhim/library_project/test_dir/test1/config.php on line 4"

If I am not mistaken there is the mistake with the entry: "$confg['db_paswd']="userpw", for instance.

I'm sure that I entered it correctly.

What should I do?

Notice from truefusion:
Removed password for your security.


jlhaslip

Couple of things, first of all, while you are developing the scripts, remove the "at" signs from the front of the mysql commands. Having the "at" signs in front reduces the Error Messages, which might be useful to you while debugging. They can be put back later, when the site is "live".Secondly, I believe the DB-name requires the Cpanel user name as a Prefix. Assuming you are using your Xisto account...$confg['db_dbase']="alex1985_books" //Your database name and Cpanel name prefixAnd there seem to be ";" missing... as statement terminators... on all the assignment statements


roooss

yeah its saying line 4 because you never terminated the command on line 3 so it thinks its just one whole command. start using ';'


alex1985

Thanks. I should pay more attention when do coding. Such simple mistakes!!!



VIEW DESKTOP VERSION REGISTERGET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.