Page 1 of 1

Can't find the error!

Posted: Mon Mar 05, 2007 5:03 pm
by andym01480

Code: Select all

$query1="INSERT INTO 'calevent' (title,description,location,postcode) VALUES('$clean['title']','$clean['description']','$clean['location']','$clean['postcode']')";
is producing this error

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\xampp\htdocs\secure\calendar\add.php on line 100

It must be so obvious, but I can't see it!

What's wrong?

Posted: Mon Mar 05, 2007 5:13 pm
by hawleyjr
Try this:

Code: Select all

$query1="INSERT INTO 'calevent' (title,description,location,postcode) VALUES('" . $clean['title'] . "','" . $clean['description'] . "','" . $clean['location'] . "','" . $clean['postcode'] . "')";

Posted: Mon Mar 05, 2007 5:30 pm
by RobertGonzalez
Or this...

Code: Select all

<?php
$sql ="INSERT 
        INTO `calevent` (`title`, `description`, `location`, `postcode`) 
        VALUES ('{$clean['title']}', '{$clean['description']}', '{$clean['location']}', '{$clean['postcode']}')";
?>
Notice that I changed the single quotes around the table name to backticks. That could have been causing a problem also. And remember to run some error checking on the query itself, using mysql_error() for failures on mysql_query().

Posted: Tue Mar 06, 2007 1:25 am
by andym01480
Thanks guys. I'd never seen the backstick way before!
I always use error checking on the query in development, but had never had a script fail on the query string itself!

Posted: Tue Mar 06, 2007 1:33 am
by volka