0

when i try to update my table i get the following error:
Error : 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 'Beste witte wijnmaker van de wereld' door het toonaangevende Engelse Wine Magazi' at line 1

this is my code:

<?php
include "../connect.php";
$id = $_POST['id'];
$naam = $_POST['naam'];
$land = $_POST['land'];
$domein = $_POST['domein'];
$streek = $_POST['streek'];
$substreek = $_POST['substreek'];
$jaar = $_POST['jaar'];
$type = $_POST['type'];
$smaak = $_POST['smaak'];
$formaat = $_POST['formaat'];
$prijsnormaal = $_POST['prijsnormaal'];
$prijs6 = $_POST['prijs6'];
$prijs12 = $_POST['prijs12'];
$prijs24 = $_POST['prijs24'];
$kleur = $_POST['kleur'];
$info = $_POST['info'];
$info = addslashes($info);

$query = "UPDATE wijen SET naam = $naam, land = $land, domein = $domein, streek = $streek, substreek = $substreek, jaar = $jaar, type = $type, smaak = $smaak, formaat = $formaat, prijsnormaal = $prijsnormaal, prijs6 = $prijs6, prijs12 = $prijs12, prijs24 = $prijs24, info = $info, kleur = $kleur WHERE id = '$id'";
mysql_query($query) or die('Error : ' . mysql_error());
echo $query;
echo "<br>";
echo "Product is aangepast";
?>

i know i have to remove the ' but i realy have no idea how, i read some things but nothing i try seems to be working maby anyone here knows a simple solution or a link where i can read about it, that would realy help me out here :)

Edited by thijscream: n/a

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by happytogether
0

also see i made a litle mistake already :P
used insert instead of update but still have the problem, will look @ your link :)
thanks

0

just create a simple function to refine youre string...
ex.

function refine($str) {

	$str = trim($str);

	$str = str_replace("'","",$str);
 //optional..do this if you want something to replase example if you want to remove '..
	$str = stripslashes($str);

	$str = strip_tags($str);

	return $str;

}

to use

$naam = refine($_POST['naam']);

hope this help

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.