Korte uitleg: Er zijn 2 tabellen. Eentje is Adverteerder en bevat alléén wat contactgegevens(velden) over de adverteerder. Aan de adverteerder hangen advertenties. De advertenties zijn terug te vinden in de tabel Advertenties. Op de pagina kan ik een advertentie bewerken en opslaan.
Met onderstaande php script krijg ik steeds de volgende 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 'WHERE id = "3" AND Adid = "546"' at line 1
Volgens mij is het een kleine aanpassing maar goed,…........als ik momenteel daadwerkelijk iets wil aanpassen in de advertentie dan kom ik dus op die syntax error. Anybody een idee wat er mis gaat ?
<?PHP
session_start();
$con = mysql_connect("***","***","***");
mysql_select_db("***", $con);
if(!isset($_SESSION['login-adverteerder']) || $_SESSION['login-adverteerder'] == false)
{
header('Location: inloggen-adverteerder.php');
exit();
}
else
{
if(isset($_POST['submit']))
{
$_POST['Status'] = trim($_POST['Status']);
$_POST['Emailreceiver'] = trim($_POST['Emailreceiver']);
$_POST['Advertsoort'] = trim($_POST['Advertsoort']);
$_POST['Adlandvacature'] = trim($_POST['Adlandvacature']);
$_POST['Adwerktype'] = trim($_POST['Adwerktype']);
$_POST['Adsoortwerk'] = trim($_POST['Adsoortwerk']);
// Bedrijfsgegevens
$qry = 'SELECT * FROM Adverteerder WHERE Gebruikersnaam = "'.$_SESSION['gebruikersnaam-adverteerder'].'" AND Wachtwoord = "'.$_SESSION['wachtwoord-adverteerder'].'"';
$res = mysql_query($qry);
$resultaat = mysql_fetch_assoc($res);
// Controleer of die bestaat
$qry = 'SELECT id FROM Advertenties WHERE id = "'.$_GET['id'].'" AND Adid = "'.$resultaat['id'].'"';
$res = mysql_query($qry);
if(mysql_num_rows($res) == 1)
{
$qry = 'UPDATE Advertenties SET ';
if($_POST['Status'] == '')
{
$qry .= ' Status = NULL,';
}
else
{
$qry .= ' Status = "'.$_POST['Status'].'",';
}
if($_POST['Emailreceiver'] == '')
{
$qry .= ' Emailreceiver = NULL,';
}
else
{
$qry .= ' Emailreceiver = "'.$_POST['Emailreceiver'].'",';
}
if($_POST['Advertsoort'] == '')
{
$qry .= ' Advertsoort = NULL,';
}
else
{
$qry .= ' Advertsoort = "'.$_POST['Advertsoort'].'",';
}
if($_POST['Adlandvacature'] == '')
{
$qry .= ' Adlandvacature = NULL,';
}
else
{
$qry .= ' Adlandvacature = "'.$_POST['Adlandvacature'].'",';
}
if($_POST['Adwerktype'] == '')
{
$qry .= ' Adwerktype = NULL,';
}
else
{
$qry .= ' Adwerktype = "'.$_POST['Adwerktype'].'",';
}
if($_POST['Adsoortwerk'] == '')
{
$qry .= ' Adsoortwerk = NULL,';
}
else
{
$qry .= ' Adsoortwerk = "'.$_POST['Adsoortwerk'].'"';
}
$qry .= ' WHERE id = "'.$_GET['id'].'" AND Adid = "'.$resultaat['id'].'"';
$res = mysql_query($qry) or die(mysql_error());
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <LINK REL="shortcut icon" href="http://www.***/***.ico">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>***</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style2 {font-size: 24px}
.style8 {
font-size: 10px;
font-family: Tahoma;
color: #000000;
}
#Layer1 {
position:absolute;
width:200px;
height:115px;
z-index:1;
left: 46px;
top: 186px;
}
#Layer2 {
position:absolute;
width:225px;
height:51px;
z-index:1;
left: 141px;
top: 143px;
}
.style13 {font-size: 10px}
.style14 {font-size: 13px}
.style2 {font-size: 24px}
.style1 {color: #8BD80E}
.style4 {color: #FFFFFF}
.style5 {
font-size: 13px;
font-weight: bold;
}
.style6 {font-size: 14px}
.style7 {color: #000000}
.style8 {
font-size: 10px;
font-family: Tahoma;
}
.style9 {font-size: 13px}
.style131 {
font-weight: bold;
font-family: Tahoma;
}
.style174 {
font-weight: bold;
font-family: Tahoma;
}
.style176 {
font-weight: bold;
font-family: Tahoma;
}
.style179 {font-family: Tahoma}
.style180 {
font-weight: bold;
color: #8BD80E;
}
.style181 {font-family: Tahoma; color: #8BD80E; }
.style182 {font-family: Tahoma; color: #8BD80E; font-weight: bold; }
.style183 {
font-family: Tahoma;
color: #FFFFFF;
font-weight: bold;
font-size: 9px;
}
.style184 {font-family: Tahoma; color: #FFFFFF; font-weight: normal; font-size: 10px;}
.style10 { font-family: Tahoma;
font-size: 10px;
color: #000000;
}
-->
</style>
</head>
<body>
<!-- start header -->
<div id="logo"><span class="post"><span class="title style2"><a href="http://www.***.nl"><img src="logo.JPG" alt="" /></a></span></span></div>
<div id="header">
<div id="menu">
<ul>
<li class="current_page_item"><a href="http://www.***.com/overzicht-adverteerder.php">Terug</a></li>
<li></li>
<li></li>
<li></li>
<li class="last"></li>
</ul>
</div>
</div>
<!-- end header -->
<div id="wrapper">
<!-- start page -->
<div id="page">
<!-- start content --><!-- end content -->
<!-- start sidebar -->
<!-- end sidebar -->
<div style="clear: both;"><br />
<span class="title style2"><h1>Advertentie bewerken</h1></span>
<p class="entry"> </p>
<?php
// Bedrijfsgegevens
$qry = "SELECT * FROM Adverteerder WHERE Gebruikersnaam = '" .$_SESSION['gebruikersnaam-adverteerder']."' AND Wachtwoord = '" . $_SESSION['wachtwoord-adverteerder'] . "'";
$res = mysql_query($qry);
$resultaat = mysql_fetch_assoc($res);
// Controleer of die bestaat
$qry = 'SELECT * FROM Advertenties WHERE id = "'.$_GET['id'].'" AND Adid = "'.$resultaat['id'].'"';
$res = mysql_query($qry);
if(mysql_num_rows($res) == 1)
{
$advertentie = mysql_fetch_assoc($res);
}
?>
<form action="advertentie-bewerken.php?id=<?php echo $_GET['id'];?>" method="post" enctype="multipart/form-data">
<table width="169">
<tr>
<td width="154" class="style182">Status van de advertentie:</td>
<td width="10" class="style179"> </td>
</tr>
<?php
$aStatus = array('' => '(geen voorkeur)',
'Active' => 'Actief',
'Inactive' => 'Inactief');
?>
<tr>
<td class="style179"><span class="style176"><span class="style4">
<select name="Status" id="Status">
<?php
foreach($aStatus As $vKey => $vVal)
{
if($vKey == $advertentie['Status'])
{
echo '<option value="'.$vKey.'" selected>'.$vVal.'</option>';
}
else
{
echo '<option value="'.$vKey.'">'.$vVal.'</option>';
}
}
<p class="subHeader style179"> </p>
<p class="style179 subHeader style1"><strong>Emailadres noteren:</strong>
<label></label>
</p>
<p class="subHeader style179">
<label>
<input name="Emailreceiver" type="text" id="Emailreceiver" size="63" maxlength="100" value="<?php echo $vacature['Emailreceiver'];?>" />
</label>
</p>
<?php
$aAdvertsoort = array('' => 'N.v.t.',
'Infohuisvesting' => 'Informatie aanvragen over Huisvesting in het buitenland >>',
'Infotaal' => 'Informatie aanvragen m.b.t. een Taalcursus >>',
'Infoverzekering' => 'Informatie aanvragen over verzekeren in het buitenland >>',
'Werk' => 'Inschrijving van iemand die werk, stage of vakantiewerk zoekt >>');
?>
<p class="style1 style179 subHeader"><strong> Dit is de eerste vraag ?</strong></p>
<p class="style174">
<select name="Advertsoort" id="Advertsoort">
<?php
foreach($aAdvertsoort As $vKey => $vVal)
{
if($vKey == $vacature['Advertsoort'])
{
echo '<option value="'.$vKey.'" selected>'.$vVal.'</option>';
}
else
{
echo '<option value="'.$vKey.'">'.$vVal.'</option>';
}
}
?>
</select>
</p>
<p class="style174"><span class="style1"><strong> Dit is de tweede vraag ?</strong></span>
<?php
$aAdlandvacature = array('' => 'N.v.t.',
'Afghanistan' => 'Afghanistan',
'Albania' => 'Albanië',
'Algeria' => 'Algerije',
'Andorra' => 'Andorra',
'Angola' => 'Angola',
'Antarctica' => 'Antarctica',
'Argentina' => 'Argentinië',
'Armenia' => 'Armenië',
'Australia' => 'Australië',
'Azerbaijan' => 'Azerbeidzjan',
'Bahamas' => 'Bahamas',
'Bahrain' => 'Bahrein',
'Bangladesh' => 'Bangladesh',
'Barbados' => 'Barbados',
'Belgium' => 'België',
'Belize' => 'Belize',
'Benin' => 'Benin',
'Bermuda' => 'Bermuda',
'Bhutan' => 'Bhutan',
'Burundi' => 'Boeroendi',
'Bolivia' => 'Bolivia',
'Bosnia-Herzegovina' => 'Bosnië-en-Herzegovina',
'Botswana' => 'Botswana',
'Brazil' => 'Brazilië',
'Bulgaria' => 'Bulgarije',
'Cambodia' => 'Cambodja',
'Canada' => 'Canada',
'Cape-Verde' => 'Cape-Verde',
'Central-African-Republic' => 'Centraal-Afrikaanse Republiek',
'Chile' => 'Chili',
'China' => 'China',
'Colombia' => 'Colombia',
'Congo' => 'Congo',
'Costa-Rica' => 'Costa-Rica',
'Cuba' => 'Cuba',
'Cyprus' => 'Cyprus',
'Denmark' => 'Denemarken',
'Dominican-Republic' => 'Dominicaanse-Republiek',
'Germany' => 'Duitsland',
'Ecuador' => 'Ecuador',
'Egypt' => 'Egypte',
'Eritrea' => 'Eritrea',
'Estonia' => 'Estland',
'Ethiopia' => 'Ethiopië',
'Philippines' => 'Filipijnen',
'Finland' => 'Finland',
'France' => 'Frankrijk',
'Gambia' => 'Gambia',
'Georgia' => 'Georgië',
'Ghana' => 'Ghana',
'Gibraltar' => 'Gibraltar',
'Grenada' => 'Grenada',
'Greece' => 'Griekenland',
'Greenland' => 'Groenland',
'Guadeloupe' => 'Guadeloupe',
'Guatemala' => 'Guatemala',
'Haiti' => 'Haïti',
'Honduras' => 'Honduras',
'Hungary' => 'Hongarije',
'Hong-Kong' => 'Hong-Kong',
'Ireland' => 'Ierland',
'Iceland' => 'IJsland',
'India' => 'India',
'Indonesia' => 'Indonesië',
'Iraq' => 'Irak',
'Iran' => 'Iran',
'Israel' => 'Israël',
'Italy' => 'Italië',
'Jamaica' => 'Jamaica',
'Japan' => 'Japan',
'Yemen' => 'Jemen',
'Yugoslavia' => 'Joegoslavië',
'Jordan' => 'Jordanië',
'Cameroon' => 'Kameroen',
'Qatar' => 'Katar',
'Kazakhstan' => 'Kazachstan',
'Kenya' => 'Kenia',
'Kiribati' => 'Kiribati',
'Kuwait' => 'Koeweit',
'Croatia' => 'Kroatië',
'Laos' => 'Laos',
'Lebanon' => 'Libanon',
'Liberia' => 'Liberia',
'Libya' => 'Libië',
'Liechtenstein' => 'Liechtenstein',
'Luxembourg' => 'Luxemburg',
'Macedonia' => 'Macedonië',
'Madagascar' => 'Madagascar',
'Malawi' => 'Malawi',
'Maldives' => 'Maldiven',
'Malaysia' => 'Maleisië',
'Mali' => 'Mali',
'Malta' => 'Malta',
'Morocco' => 'Marokko',
'Martinique' => 'Martinique',
'Mauritania' => 'Mauritanië',
'Mauritius' => 'Mauritius',
'Mexico' => 'Mexico',
'Moldova' => 'Moldavië',
'Monaco' => 'Monaco',
'Mongolia' => 'Mongolië',
'Mozambique' => 'Mozambique',
'Myanmar' => 'Myanmar',
'Namibia' => 'Namibië',
'Netherlands' => 'Nederland',
'Netherlands-Antilles' => 'Nederlandse-Antillen',
'Nepal' => 'Nepal',
'Nicaragua' => 'Nicaragua',
'New-Zealand' => 'Nieuw-Zeeland',
'Nigeria' => 'Nigeria',
'Korea-North' => 'Noord-Korea',
'Norway' => 'Noorwegen',
'Uganda' => 'Oeganda',
'Ukraine' => 'Oekraïne',
'Uzbekistan' => 'Oezbekistan',
'Austria' => 'Oostenrijk',
'East-Timor' => 'Oost-Timor',
'Pakistan' => 'Pakistan',
'Panama' => 'Panama',
'Paraguay' => 'Paraguay',
'Peru' => 'Peru',
'Poland' => 'Polen',
'Portugal' => 'Portugal',
'Puerto-Rico' => 'Puerto-Rico',
'Romania' => 'Roemenië',
'Russia' => 'Rusland',
'Rwanda' => 'Rwanda',
'Saudi-Arabia' => 'Saudi-Arabië',
'Senegal' => 'Senegal',
'Sierra-Leone' => 'Sierra-Leone',
'Singapore' => 'Singapore',
'Slovenia' => 'Slovenië',
'Slovakia' => 'Slowakije',
'Somalia' => 'Somalië',
'Spain' => 'Spanje',
'Sri-Lanka' => 'Sri-Lanka',
'Sudan' => 'Sudan',
'Suriname' => 'Suriname',
'Swaziland' => 'Swaziland',
'Syria' => 'Syrië',
'Taiwan' => 'Taiwan',
'Tanzania' => 'Tanzania',
'Thailand' => 'Thailand',
'Czech-Republic' => 'Tsjechische-Republiek',
'Tunisia' => 'Tunesië',
'Turkey' => 'Turkije',
'UAE' => 'UAE',
'Uruguay' => 'Uruguay',
'USA' => 'USA',
'Venezuela' => 'Venezuela',
'United-Kingdom' => 'Verenigd-Koninkrijk',
'Vietnam' => 'Vietnam',
'Zaire' => 'Zaïre',
'Zambia' => 'Zambia',
'Zimbabwe' => 'Zimbabwe',
'South-Africa' => 'Zuid-Afrika',
'Korea-South' => 'Zuid-Korea',
'Sweden' => 'Zweden',
'Switzerland' => 'Zwitserland');
?>
<p class="style1 style179 subHeader"><strong> Dit is de derde vraag ?</strong></p>
<p class="style174">
<select name="Adlandvacature" id="Adlandvacature">
<?php
foreach($aAdlandvacature As $vKey => $vVal)
{
if($vKey == $vacature['Adlandvacature'])
{
echo '<option value="'.$vKey.'" selected>'.$vVal.'</option>';
}
else
{
echo '<option value="'.$vKey.'">'.$vVal.'</option>';
}
}
?>
</select>
</p>
<?php
$aAdwerktype = array('' => 'N.v.t.',
'Winterjob' => 'Vakantiewerk (winter) >>',
'Summerjob' => 'Vakantiewerk (zomer) >>',
'Fulltime/parttime' => 'Fulltime/parttime >>',
'Internship' => 'Stage >>');
?>
<p class="style1 style179 subHeader"><strong> Dit is de vierde vraag ?</strong></p>
<p class="style174">
<select name="Adwerktype" id="Adwerktype">
<?php
foreach($aAdwerktype As $vKey => $vVal)
{
if($vKey == $vacature['Adwerktype'])
{
echo '<option value="'.$vKey.'" selected>'.$vVal.'</option>';
}
else
{
echo '<option value="'.$vKey.'">'.$vVal.'</option>';
}
}
?>
</select>
</p>
<?php
$aAdsoortwerk = array('' => '(Geen voorkeur)',
'Financial' => 'Accounting / Financieel',
'Administrative' => 'Administratief / Secretarieel',
'Aupair' => 'Au pair / Huishoudelijk',
'BuildingConstruction' => 'Bouw',
'Creative/DesignJobs' => 'Creatief / Design',
'Medical' => 'Gezondheidszorg / Medisch',
'Hotel/Restaurant/Bar' => 'Horeca',
'Installation/Maintenance/Repair' => 'Installatie / Onderhoud / Reparatie',
'IT/SoftwareDevelopment' => 'IT / Software Development',
'Legal' => 'Juridisch',
'CustomerService' => 'Klantenservice',
'Quality' => 'Kwaliteitscontrole / Veiligheid',
'Logistics/Transportation' => 'Logistiek / Transport / Inkoop',
'Marketing' => 'Marketing / Product / PR / Reclame',
'Education' => 'Onderwijs / Training / Vertaling',
'R&D/Science' => 'Onderzoek (R&D) / Wetenschap',
'Other' => 'Overige',
'HumanResources' => 'Personeelszaken / HRM',
'Production/Manufacturing' => 'Productie / Fabricage',
'Editorial/Journalism' => 'Redactie / Journalistiek',
'Sales' => 'Sales / Verkoop',
'Technical' => 'Technisch',
'Allround' => 'Toerisme / Recreatie / Camping / Animatie',
'Safety/Security' => 'Veiligheid / Beveiliging');
?>
<p class="style1 style179 subHeader"><strong>Dit is de vijfde vraag ?</strong></p>
<p class="style174">
<select name="Adsoortwerk" id="Adsoortwerk">
<?php
foreach($aAdsoortwerk As $vKey => $vVal)
{
if($vKey == $vacature['Adsoortwerk'])
{
echo '<option value="'.$vKey.'" selected>'.$vVal.'</option>';
}
else
{
echo '<option value="'.$vKey.'">'.$vVal.'</option>';
}
}
?>
</select>
</p>
<p><input type="submit" name="submit" value="Opslaan" /></p>
</form>
<blockquote>
<blockquote>
<p class="style1">******</span></p>
</blockquote>
</blockquote>
</div>
</div>
</div>
<!-- end page -->
<!-- start footer -->
<div id="footer">
<div align="center"><span class="style8">Copyright © 2010. [*** KvK: *** BTW: NL ***]. All rights reserved. Designed by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</span></div>
</div>
<!-- end footer -->
</body>
</html>
<?PHP
}
?>