Jump to content
xisto Community
nightfox1405241487

PHP Script Problem - Parse Error

Recommended Posts

I've been coding my own forum software and I'm almost finished to release a public preview BUT there's just one problem:

My connect.php file! Every script that refrences it gives this error:

Parse error: syntax error, unexpected T_VARIABLE in /home/startech/public_html/moonbursttech/beta/forums/source/connect.php on line 23

Here's my connect.php file:
<?php/*+|   Codename: Summer Breeze Alpha 1|   ========================================|   |   (c) 2006 Moonburst Technologies|   http://forums.xisto.com/no_longer_exists/|   ========================================|   License Info: http://forums.xisto.com/no_longer_exists/+|	THIS SOFTWARE IS AN INTERNAL COPY AND IS NOT |	LICENSED FOR USE. THIS SOFTWARE IS *HIGHLY*|	UNSTABLE AND COMES WITH NO WARRANTY. THIS |	SOFTWARE IS NOT STABLE!+|	FILE: connect.php+*/#Enter your MySQL Database details below:$server = 'localhost'			//This is usually "localhost". If you're not sure, leave it as is.$user = 'startech_summer'		//This is the USER who has access to the database$sqlpass = 'REMOVED'			//This is the PASSWORD for the MySQL user above$db = 'startech_sb1'	//This is the DATABASE to store data###DO NOT EDIT BELOW THIS LINE!###$connect = mysql_connect($server, $user, $sqlpass)	or die("Could not connect to the database!");mysql_select_db($db, $connect)	or die("Could not select database! Does it exist?");?>

For some reason, it has a complaint about this line:
$user = 'startech_summer' //This is the USER who has access to the database

I'm not sure what is wrong with it! Can anyone else tell? I even modified the variable from $sqluser to $user but it didn't help.

Thanks for any help!

[N]F

Share this post


Link to post
Share on other sites

$server = 'localhost'			//This is usually "localhost". If you're not sure, leave it as is.$user = 'startech_summer'		//This is the USER who has access to the database$sqlpass = 'REMOVED'			//This is the PASSWORD for the MySQL user above$db = 'startech_sb1'	//This is the DATABASE to store data
Looks pretty simple to fix.

After EVERY statement in php, you MUST end the statement with a semi-colon!

Replace the section of code above with this:
$server = 'localhost';			//This is usually "localhost". If you're not sure, leave it as is.$user = 'startech_summer';		//This is the USER who has access to the database$sqlpass = 'REMOVED';			//This is the PASSWORD for the MySQL user above$db = 'startech_sb1';	//This is the DATABASE to store data


This should solve your problems.

If you continue to have difficulties, let me know.

Most error code provide a line number. The error is usually in the line just before that. in this case, you didn't use a semi-colon in line 22 to end your statement.

Hope this helps. :(

vujsa

Share this post


Link to post
Share on other sites

Hi, i agree with the post of vujsa, you forgot to finish your statements with a semicolon, thats your problem, also your connect variable is not strictly necessary, you can decide to use it or not.

A suggestion, always include in your database functions the mysql error number and string like this:

$connect = mysql_connect($server, $user, $sqlpass)	or die("Could not connect to the database!" . mysql_errno() . ": " . mysql_error() );mysql_select_db($db, $connect)	or die("Could not select database! Does it exist?" . mysql_errno() . ": " . mysql_error() );

Are very helpful to solve a lots of problems.

Best regards,

Share this post


Link to post
Share on other sites

Did you write the code or is it from a ready made package because normally all those semicolons whould have been there and all you would have had to do is enter the proper parameters. The reason the code falieed on the second line is because PHP didnot see where the first assignment was closed;

$server = 'localhost';            //This is usually "localhost". If you're not sure, leave it as is.$user = 'startech_summer';        //This is the USER who has access to the database$sqlpass = 'REMOVED';            //This is the PASSWORD for the MySQL user above$db = 'startech_sb1';    //This is the DATABASE to store data

Now this is how the code should be and when you enter the proper parameters inside the single quotes then the code should work with no errors provided that you don't have a typo in any of the parameters.

Share this post


Link to post
Share on other sites

Did you write the code or is it from a ready made package because normally all those semicolons whould have been there and all you would have had to do is enter the proper parameters.

Yeah I wrote it... hence the missing semicolons! :(

Looks like I need to bring back Mr. Post-It with the large giant semicolon drawn on it. Well, actually since I do a lot of programming on my laptop, I'll just use one of the smaller versions and tape it to the top of the screen.

I don't know why, but I ALWAYS seem to forget the stupid semicolons. I guess it is the Visual Basic programming getting to me.

Thanks for the help of a stupid semicolon!!

[N]F
Edited by nightfox (see edit history)

Share this post


Link to post
Share on other sites

Thanks for the help of a stupid semicolon!!

[N]F

Glad we could help. I was a little surprised that you got the same answer three times in a row. Might be nice for people to read the entire topic before replying. :(

Anyway, we all leave a semicolon out here and there everyonce in a while. At least PHP will tell you where the problem is generally. In CSS, the browser just does it's best to parse the data giving an undisirable result and no indication where the problem is.

Just remember, the error is alway before the line that was given in the error message. The line number usually refers to the right after the line with the error but occasionally the error will be several lines above depending on your code.

Hope this helps :(

vujsa

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.