Page 1 of 1

MYSQL INSERT ERROR

Posted: Thu Apr 29, 2010 6:55 am
by hari4php
Hi,I was trying to insert values for a table in mysql,When inserting ..the follwing error occurs
Insertion Failed:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''full_name','user_name','user_email','pwd','address','tel','date','users_ip','ac' at line 1
My insert query is :

Code: Select all

$sql_insert = "INSERT into users ('full_name','user_name','user_email','pwd','address','tel','date','users_ip','activation_code') 
          VALUES ('full_name','$user_name','$usr_email','$md5pass','address','tel',now(),'$user_ip','$active_code')";
where $date is

Code: Select all

function filter($data) {
	$data = trim(htmlentities(strip_tags($data)));
	
	if (get_magic_quotes_gpc())
		$data = stripslashes($data);
	
	$data = mysql_real_escape_string($data);
	
	return $data;
}
Wat What will be the problem

Re: MYSQL INSERT ERROR

Posted: Thu Apr 29, 2010 9:02 am
by Darhazer
The fieldnames should not be enclosed with ', but with `
$sql_insert = "INSERT into `users` (`full_name`,`user_name`,`user_email`,`pwd`,`address`,`tel`,`date`,`users_ip`,`activation_code`)
VALUES ('full_name','$user_name','$usr_email','$md5pass','address','tel',now(),'$user_ip','$active_code')";