Page 1 of 1

parse error

Posted: Thu Jun 12, 2003 6:40 pm
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'

Posted: Thu Jun 12, 2003 7:22 pm
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.

thanks

Posted: Fri Jun 13, 2003 8:34 am
by tralyn
Well, I didn't get an error when it ran, no data either but that is progress, thank you about the .

Posted: Fri Jun 13, 2003 8:58 am
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?