Honesty Rocks! truth rules.

Unexpected T_variable... Help

HOME      >>       Programming


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


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


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


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