SQL syntax Error

Status
Niet open voor verdere reacties.

Alicos

Gebruiker
Lid geworden
2 sep 2008
Berichten
9
De volgende foutmelding krijg ik nadat ik een occasion heb toegevoegd aan mijn database. zie: http://acem-autos.nl/occasions.php

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 '' at line 1

Zegt mij nietss???
 
Er is iets in de query wat niet klopt.

De pest is dat deze foutmelding te weinig informatie bevat om meteen een antwoord te geven.

Kun je de broncode van view.php plaatsen?
 
Er is iets in de query wat niet klopt.

De pest is dat deze foutmelding te weinig informatie bevat om meteen een antwoord te geven.

Kun je de broncode van view.php plaatsen?

oke zie alhier de view.php code.

<?php
include("include/config.php");

$query = "SELECT * FROM occasions WHERE id=$id";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result)){
$bouwjaar = $row['bouwjaar'];
$prijs = $row['prijs'];
$merk = $row['merk'];
$type = $row['type'];
$interieur = nl2br($row['interieur']);
$exterieur = nl2br($row['exterieur']);
$specs = nl2br($row['specs']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Acem Auto's</title>
<script type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<link href="sheet/hdsautos.css" rel="stylesheet" type="text/css" />
</head>

<body onload="MM_preloadImages('images/button-home-on.gif','images/button-occasions-on.gif','images/button-informatie-on.gif','images/button-contact-on.gif')">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30">&nbsp;</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="images/shade-top.gif"><img src="images/shade-top.gif" width="10" height="12" /></td>
</tr>
</table></td>
<td width="950"><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="30"><img src="images/grijseffect-topleft.gif" width="30" height="10" /></td>
<td background="images/grijseffect-top.gif"><img src="images/grijseffect-top.gif" width="10" height="10" /></td>
<td width="30"><img src="images/grijseffect-topright.gif" width="30" height="10" /></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10"><img src="images/rood-topleft.gif" width="10" height="10" /></td>
<td background="images/rood-top.gif"><img src="images/rood-top.gif" width="10" height="10" /></td>
<td width="10"><img src="images/rood-topright.gif" width="10" height="10" /></td>
</tr>
<tr>
<td background="images/rood-left.gif">&nbsp;</td>
<td background="images/rood-back.gif"><?php include("include/header.php"); ?></td>
<td background="images/rood-right.gif">&nbsp;</td>
</tr>
</table></td>
</tr>
</table></td>
<td valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="images/shade-top.gif"><img src="images/shade-top.gif" width="10" height="12" /></td>
</tr>
</table></td>
</tr>
<tr>
<td background="images/sideeffect-grijs.gif">&nbsp;</td>
<td width="950"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10" background="images/rood-left.gif">&nbsp;</td>
<td background="images/rood-back.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10" background="images/wit-left.gif">&nbsp;</td>
<td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="images/wit-back.gif" width="10" height="5" /></td>
</tr>
<tr>
<td class="common-text"><?php
//standaard waardes
$id = $_GET['id'];
if($_GET['img']){
$img = $_GET['img'];
} else {
$img = 1;
}
//array met de plaatjes
$files = "1";
$handle=opendir("occasions/".$id);
while ($file = readdir($handle)) {
if(!is_dir($path."/".$file) && $file != "." && $file!="..") {
$parts = explode (".", $file);
$p_count = (count($parts) - 1);
$ext = $parts[$p_count];
if($ext=="jpg"||$ext=="jpeg"||$ext=="JPG"||$ext=="JPEG") {
$images[$files] = $file;
$files++;
}
}
}
$aantal = count($images);
if($aantal>0){
//thumbnail maken voor eerste plaatje
$source = "occasions/".$id."/".$images[$img];
$tsource = "occasions/".$id."/large/".$images[$img];
$thumbnail_w = "908";
$quality = "100";
if(file_exists($source)&&!file_exists($tsource)) {
$size = getimagesize($source);
//index 0 = breedte, 1 = hoogte, 2 = flag, 3 = IMG string, mime = mime_type
$h = round($size[1]/($size[0]/$thumbnail_w));
//hier delen we hoogte door thumb hoogte dit geeft aspect ratio, voor breedte gebruiken we aspect ratio
$w = $thumbnail_w;
$resize = imagecreatetruecolor($w, $h);
//image container maken voor de thumb met breedte die aangegeven is, container is nog leeg
switch ($size['mime']) {
case 'image/jpeg':
$im = imagecreatefromjpeg($source);
//image container met inhoud van de source bestand
imagecopyresampled($resize, $im, 0, 0, 0, 0, $w, $h, $size[0], $size[1]);
//destionation, source, dst_x, dst_y, src_x, src_y, breedte_t, hoogte_t, breedte_orgineel, hoogte_origneel
//orginele container resampeld kopieren over thumb container
imagejpeg($resize, 'occasions/'.$id.'/large/'.$images[$img], $quality);
//thumb container uitschrijven
break;
case 'image/png':
$im = imagecreatefrompng($source);
imagecopyresampled($resize, $im, 0, 0, 0, 0, $w, $h, $size[0], $size[1]);
imagepng($resize, 'occasions/'.$id.'/thumbs/'.$images[$img], $quality);
break;
}
//source container dumpen niet meer nodig
imagedestroy($im);
}
echo "<img src=\"occasions/$id/large/{$images[$img]}\" class=\"occasion-thumbs\">";
} else {
echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"15\">&nbsp;</td><td height=\"30\">Helaas zijn er nog geen foto's beschikbaar. Onze excuses voor het ongemak.</td><td width=\"10\">&nbsp;</td></tr></table>";
}
?></td>
</tr>
<tr>
<td><img src="images/wit-back.gif" width="10" height="5" /></td>
</tr>
</table>
<?php
//thumbs komen hier
if($aantal>0){
//thumbs tabel beginnnen we hier
print "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td>";

echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
$column = 1;
for($i=1;$i<=$aantal;$i++){
$source = "occasions/".$id."/".$images[$i];
$tsource = "occasions/".$id."/thumbs/".$images[$i];
$thumbnail_w = "176";
$quality = "100";
if(file_exists($source)&&!file_exists($tsource)) {
$size = getimagesize($source);
//index 0 = breedte, 1 = hoogte, 2 = flag, 3 = IMG string, mime = mime_type
$h = round($size[1]/($size[0]/$thumbnail_w));
//hier delen we hoogte door thumb hoogte dit geeft aspect ratio, voor breedte gebruiken we aspect ratio
$w = $thumbnail_w;
$resize = imagecreatetruecolor($w, $h);
//image container maken voor de thumb met breedte die aangegeven is, container is nog leeg
switch ($size['mime']) {
case 'image/jpeg':
$im = imagecreatefromjpeg($source);
//image container met inhoud van de source bestand
imagecopyresampled($resize, $im, 0, 0, 0, 0, $w, $h, $size[0], $size[1]);
//destionation, source, dst_x, dst_y, src_x, src_y, breedte_t, hoogte_t, breedte_orgineel, hoogte_origneel
//orginele container resampeld kopieren over thumb container
imagejpeg($resize, 'occasions/'.$id.'/thumbs/'.$images[$i], $quality);
//thumb container uitschrijven
break;
case 'image/png':
$im = imagecreatefrompng($source);
imagecopyresampled($resize, $im, 0, 0, 0, 0, $w, $h, $size[0], $size[1]);
imagepng($resize, 'occasions/'.$id.'/thumbs/'.$images[$i], $quality);
break;
}
//source container dumpen niet meer nodig
imagedestroy($im);
}
if($column==6){
echo "</tr><tr><td><img src=\"images/wit-back.gif\" width=\"10\" height=\"5\"></td></tr><tr>";
$column = 0;
}
echo "<td><a href=\"{$_SERVER['PHP_SELF']}?action=view&id=$id&img=$i\"><img src=\"$tsource\" class=\"occasion-thumbs\"></a></td>";
if($column!=5){
echo "<td width=\"5\">&nbsp;</td>";
}
$column++;
}
echo "</tr></table>";

//thumbs tabel afsluiten
print "</td>
</tr>
</table>";
}
?></td>
</tr>

</table>
</td>
<td width="10" background="images/wit-right.gif">&nbsp;</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10"><img src="images/wit-bottomleft.gif" width="10" height="10" /></td>
<td background="images/wit-bottom.gif"><img src="images/wit-bottom.gif" width="10" height="10" /></td>
<td width="10"><img src="images/wit-bottomright.gif" width="10" height="10" /></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/rood-back.gif" width="10" height="10" /></td>
</tr>
</table>
<?php if($_SESSION['auth']){ ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="240"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10"><img src="images/admin-topleft.gif" width="10" height="10" /></td>
<td background="images/admin-top.gif"><img src="images/admin-top.gif" width="10" height="10" /></td>
<td width="10"><img src="images/admin-topright.gif" width="10" height="10" /></td>
</tr>
<tr>
<td background="images/admin-left.gif">&nbsp;</td>
<td height="30" background="images/admin-back.gif" class="admin-text"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form name="aanpassen" method="post" action="update.php?action=update&id=<?php echo $_GET['id']; ?>"><tr>
<td>
<input type="submit" class="admin-buttons" value="Aanpassen" />
</td>
</tr></form>
</table>
</td>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form name="delete" method="post" action="include/scripts.php?action=delete&id=<?php echo $_GET['id']; ?>"><tr>
<td>
<input type="submit" class="admin-buttons" value="Verwijderen" />
</td>
</tr></form>
</table>
</td>
</tr>
</table></td>
<td background="images/admin-right.gif">&nbsp;</td>
</tr>
<tr>
<td><img src="images/admin-bottomleft.gif" width="10" height="10" /></td>
<td background="images/admin-bottom.gif"><img src="images/admin-bottom.gif" width="10" height="10" /></td>
<td><img src="images/admin-bottomright.gif" width="10" height="10" /></td>
</tr>
</table></td>
<td width="10">&nbsp;</td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10"><img src="images/admin-topleft.gif" width="10" height="10" /></td>
<td background="images/admin-top.gif"><img src="images/admin-top.gif" width="10" height="10" /></td>
<td width="10"><img src="images/admin-topright.gif" width="10" height="10" /></td>
</tr>
<tr>
<td background="images/admin-left.gif">&nbsp;</td>
<td height="30" background="images/admin-back.gif" class="admin-text"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<form action="include/scripts.php?action=upload&id=<?php echo $_GET['id']; ?>" method="post" enctype="multipart/form-data">
<tr>
<td><input name="file" type="file" class="admin-buttons" size="28" />
<input type="submit" class="admin-buttons" value="Uploaden" />
</td>
</tr>
</form>
</table></td>
<td class="admin-text">Uploaden kan lang duren! </td>
</tr>
</table></td>
<td background="images/admin-right.gif">&nbsp;</td>
</tr>
<tr>
<td><img src="images/admin-bottomleft.gif" width="10" height="10" /></td>
<td background="images/admin-bottom.gif"><img src="images/admin-bottom.gif" width="10" height="10" /></td>
<td><img src="images/admin-bottomright.gif" width="10" height="10" /></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/rood-back.gif" width="10" height="10" /></td>
</tr>
</table>
<?php } ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10"><img src="images/wit-topleft.gif" width="10" height="10" /></td>
<td background="images/wit-top.gif"><img src="images/wit-top.gif" width="10" height="10" /></td>
<td width="10"><img src="images/wit-topright.gif" width="10" height="10" /></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10" background="images/wit-left.gif">&nbsp;</td>
<td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="15">&nbsp;</td>
<td class="common-text"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="common-text">Merk en type </td>
<td width="10" class="common-text" background="images/occasions-div.gif">&nbsp;</td>
<td width="160" class="common-text">Prijs</td>
<td width="10" class="common-text" background="images/occasions-div.gif">&nbsp;</td>
<td width="100" class="common-text">Bouwjaar</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" class="occasions-view"><?php echo "$merk, $type"; ?></td>
<td width="10" class="occasions-view" background="images/occasions-div.gif">&nbsp;</td>
<td width="160" class="occasions-view"><?php echo "€ $prijs"; ?></td>
<td width="10" class="occasions-view" background="images/occasions-div.gif">&nbsp;</td>
<td width="100" class="occasions-view"><?php echo "$bouwjaar"; ?></td>
</tr>
</table></td>
<td width="15">&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="images/wit-back.gif" width="10" height="10" /></td>
</tr>
</table>
<?php
if($interieur!=""){
print "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"10\"><img src=\"images/header-left.gif\" width=\"10\" height=\"30\" /></td>
<td background=\"images/header-back.gif\"><img src=\"images/header-interieur.gif\" width=\"115\" height=\"30\" /></td>
<td width=\"10\"><img src=\"images/header-right.gif\" width=\"10\" height=\"30\" /></td>
</tr>
</table>
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td><img src=\"images/wit-back.gif\" width=\"10\" height=\"10\" /></td>
</tr>
<tr>
<td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"15\">&nbsp;</td>
<td class=\"common-text\">$interieur</td>
<td width=\"15\">&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td><img src=\"images/wit-back.gif\" width=\"10\" height=\"10\" /></td>
</tr>
</table>";
}
if($exterieur!=""){
print "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"10\"><img src=\"images/header-left.gif\" width=\"10\" height=\"30\" /></td>
<td background=\"images/header-back.gif\"><img src=\"images/header-exterieur.gif\" width=\"115\" height=\"30\" /></td>
<td width=\"10\"><img src=\"images/header-right.gif\" width=\"10\" height=\"30\" /></td>
</tr>
</table>
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td><img src=\"images/wit-back.gif\" width=\"10\" height=\"10\" /></td>
</tr>
<tr>
<td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"15\">&nbsp;</td>
<td class=\"common-text\">$exterieur</td>
<td width=\"15\">&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td><img src=\"images/wit-back.gif\" width=\"10\" height=\"10\" /></td>
</tr>
</table>";
}
if($specs!=""){
print "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"10\"><img src=\"images/header-left.gif\" width=\"10\" height=\"30\" /></td>
<td background=\"images/header-back.gif\"><img src=\"images/header-specs.gif\" width=\"239\" height=\"30\" /></td>
<td width=\"10\"><img src=\"images/header-right.gif\" width=\"10\" height=\"30\" /></td>
</tr>
</table>
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td><img src=\"images/wit-back.gif\" width=\"10\" height=\"10\" /></td>
</tr>
<tr>
<td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"15\">&nbsp;</td>
<td class=\"common-text\">$specs</td>
<td width=\"15\">&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td><img src=\"images/wit-back.gif\" width=\"10\" height=\"10\" /></td>
</tr>
</table>";
}
?></td>
<td width="10" background="images/wit-right.gif">&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10"><img src="images/wit-bottomleft.gif" width="10" height="10" /></td>
<td background="images/wit-bottom.gif"><img src="images/wit-bottom.gif" width="10" height="10" /></td>
<td width="10"><img src="images/wit-bottomright.gif" width="10" height="10" /></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="10" background="images/rood-right.gif">&nbsp;</td>
</tr>
</table></td>
<td background="images/sideeffect-grijs.gif">&nbsp;</td>
</tr>
<tr>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="images/shade-bottom.gif"><img src="images/shade-bottom.gif" width="10" height="10" /></td>
</tr>
</table></td>
<td width="950"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10" background="images/rood-left.gif">&nbsp;</td>
<td background="images/rood-back.gif"><?php include("include/bottom.php"); ?></td>
<td width="10" background="images/rood-right.gif">&nbsp;</td>
</tr>
<tr>
<td><img src="images/rood-bottomleft.gif" width="10" height="10" /></td>
<td background="images/rood-bottom.gif"><img src="images/rood-bottom.gif" width="10" height="10" /></td>
<td><img src="images/rood-bottomright.gif" width="10" height="10" /></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="30"><img src="images/grijseffect-bottomleft.gif" width="30" height="10" /></td>
<td background="images/grijseffect-top.gif"><img src="images/grijseffect-top.gif" width="10" height="10" /></td>
<td width="30"><img src="images/grijseffect-bottomright.gif" width="30" height="10" /></td>
</tr>
</table>
</td>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="images/shade-bottom.gif"><img src="images/shade-bottom.gif" width="10" height="10" /></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30">&nbsp;</td>
</tr>
</table>
</body>
</html>
 
Wijzig deze regel
PHP:
$query = "SELECT * FROM occasions WHERE id=$id";
eens in
PHP:
$query = "SELECT * FROM occasions WHERE id='". $_GET['id'] ."'";

Hopelijk is dat voldoende :)
 
Wijzig deze regel
PHP:
$query = "SELECT * FROM occasions WHERE id=$id";
eens in
PHP:
$query = "SELECT * FROM occasions WHERE id='". $_GET['id'] ."'";

Hopelijk is dat voldoende :)

Hey, Buiten 1 puntje (letterlijk) was het voldoende:)) :thumb::thumb:
gracias.. voor jouw een klein moetje voor mij een kopzorg minder:D
 
Wat was er fout aan dan? Ik zie er niets verkeerds aan :(
 
Ohw oke, ik meende dat je het over mijn regel code had. Vond het al zo vreemd :)

Zet je de status ook op "Opgelost"? Alvast bedankt :thumb:
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan