Tuesday, 15 May 2012

php - INSERT in MySQL doesn't work for second time -



php - INSERT in MySQL doesn't work for second time -

i have problem mysql request. insertion doesn't work overnight. don't know why. sec time doing this.

i getting next mysqli_error:

erreur :you have error in sql syntax; check manual corresponds mysql server version right syntax utilize near '1 ,'ljhb', '5456', '0-aveerylr-fruits-et-legumes-bio-' @ line 1

$connect = mysqli_connect("localhost","root","","db"); $name = mysqli_query($connect,"select name fruitandvegetable name='".mysqli_real_escape_string($connect,stripcslashes($_post['name']))."'") or die('erreur :'.mysqli_error()); $nombre = mysqli_query($connect,"select nombre fruitandvegetable nombre='".mysqli_real_escape_string($connect,stripcslashes($_post['nombre']))."'") or die('erreur :'.mysqli_error()); if(mysqli_num_rows($name) != 0) { $doublonname = "the name exists"; } if(mysqli_num_rows($nombre) != 0) { $doublonnombre = "the number exists"; } elseif(mysqli_num_rows($name) == 0 && mysqli_num_rows($nombre) == 0) { $query = mysqli_query($connect,"insert fruitandvegetable(id, name, color,description, nombre, type, image_name) values('', '".mysqli_real_escape_string($connect,$_post['name'])."', '".mysqli_real_escape_string($connect,$color)." , '".mysqli_real_escape_string($connect,$type)." ,'".mysqli_real_escape_string($connect,$description)."', '".mysqli_real_escape_string($connect,$_post['nombre'])."', '".mysqli_real_escape_string($connect,$image_name)."')") or die('erreur :'.mysqli_error($connect)); $erreur = "votre fruit et legume bien été pris en compte"; }

missing 's.

'".mysqli_real_escape_string($connect,$color)." , '".mysqli_real_escape_string($connect,$type)." ,

try -

$query = mysqli_query($connect,"insert fruitandvegetable(id, name, color,description, nombre, type, image_name) values('', '".mysqli_real_escape_string($connect,$_post['name'])."', '".mysqli_real_escape_string($connect,$color)."' , '".mysqli_real_escape_string($connect,$type)."' ,'".mysqli_real_escape_string($connect,$description)."', '".mysqli_real_escape_string($connect,$_post['nombre'])."', '".mysqli_real_escape_string($connect,$image_name)."')");

php mysql

No comments:

Post a Comment