Page 1 of 1

need help with MySQl Statement for insert

Posted: Tue Dec 13, 2005 4:28 pm
by vincenzobar
Quick help on this any one

no matter what i try i error at the @ symbol

I wrote with set to make sure all values match to columns i already tried with VALUES() too

Code: Select all

$sql = "INSERT INTO ".$table."  SET name=$name, name2=$name2, email=".mysql_real_escape_string($email).", zip=$zip, create_date=$date";
Email comes from a form and i use extract($_POST)

no matter what i do even in as a variable like

$email = addslashes($email); It errors out
$email = addslashes($_REQUEST['email']); It errors out too

I even tried str_replace and it just errors at \@

Any one got any ideas?

Posted: Tue Dec 13, 2005 4:37 pm
by Charles256
try putting quotes around it? i.e. '$email' ?

Posted: Tue Dec 13, 2005 4:45 pm
by vincenzobar
almost worked now it messing up with the insert

I even changed back to

Code: Select all

$sql = "INSERT INTO ".$table." (name, name2, email, zip, create_date)  VALUES($name, $name2, ".mysql_real_escape_string('$email').", $zip, $date)";
my error is

Unknown column 'vincenzo' in 'field list'

soooo close!

Posted: Tue Dec 13, 2005 5:00 pm
by vincenzobar

Code: Select all

$email = mysql_real_escape_string($email);

$sql = "INSERT INTO ".$table." VALUES('', '$name', '$name2', '$email', '$zip', '$date')";
FINALLY!!!!

thanks for the inspiration!