parse error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tralyn
Forum Newbie
Posts: 2
Joined: Thu Jun 12, 2003 6:40 pm

parse error

Post by tralyn »

Greetings, I've been looking at this piece of code I've been trying to get to work for a couple of days.
Here is the error: "Parse error: parse error, unexpected T_STRING in /home/spiralwe/public_html/add.php on line 8"
I have looked up the token T_STRING but can't find any references or syntax on it, looked on php.net.
I have tried using .= and all kinds of semicolons and quotes. I am very new at php, just starting actually and this is my first attempt at a guestbook. Passwords and such removed. I had removed lines between the code just to see if I could get the error to change line numbers, was doubting that it was really reading it.

Here is the code I've written

Code: Select all

if (isset($_POST['name' and 'email' and 'comments']) ) {
$connect=mysql_connect("localhost","","") OR 
DIE('Unable to connect because:' mysql_error());
$db_select = @mysql_select_db("") OR DIE('Unable to select database' mysql_error());
$query = "insert into gbook (ID,name,email,comments) "; 
$query .= "VALUES('','$name','$email','$comments')";
mysql_query($query) or die("Insert Failed");

}
Thanks for any suggestions, I know from reading other forums and such that parse errors are generally user errors and highly annoying but this one just has me beat.

Traci'
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

Try
DIE('Unable to select database'.mysql_error());
instead of
DIE('Unable to select database' mysql_error());


Notice the dot. Hope it helps.
tralyn
Forum Newbie
Posts: 2
Joined: Thu Jun 12, 2003 6:40 pm

thanks

Post by tralyn »

Well, I didn't get an error when it ran, no data either but that is progress, thank you about the .
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

You arn't selecting a database, hence why you won't see any results from your query, also remove the @, its probably suppressing the error message.

Regards,

Addtion: Erm, have you removed the database name because you were posting your code on this site?
Post Reply