Hi all,
I'm having problems passing my variables using thru the url. Here's the code.
$connection = mysql_connect($dbhost, $dbusername, $dbpassword) or die (mysql_error());
mysql_select_db($dbname, $connection);
//i use this line to test that variable id has been passed.
//this also happens to be the error point
$test = "select * from jobpost where id=".$_GET['id'];
echo $test;
$run = mysql_query($test) or die(mysql_error());
$row = mysql_fetch_assoc($run);
if ($_SERVER['REQUEST_METHOD'] == 'GET'){
?>
<form method="post" enctype="application/x-www-form-urlencoded" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<fieldset>
<legend>Edit Vacancy</legend>
<label for="jobtitle">Job Title</label>
<input type="text" name="jobtitle" value="<?php echo htmlentities($row['jobtitle']); ?>"/><br />
<label for="jobdescription">Job Desription</label>
<textarea name="jobdescription" cols="50" rows="10" ><?php echo strip_tags( nl2br (($row['jobdescription']))); ?></textarea><br />
<label for="jobqualifications">Job Qualifications</label>
<textarea name="jobqualifications" cols="50" rows="10" ><?php echo strip_tags(nl2br(($row['jobqualifications']))); ?></textarea>
<input type="hidden" name="id2" value="<?php echo $_GET['id']; ?>" />
</fieldset>
<input name="Submit" type="submit" value="Update" />
</form>
<?php } else {
$jobtitle = $_POST['jobtitle'];
$jobdescription = $_POST['jobdescription'];
$jobqualifications = $_POST['jobqualifications'];
$query = "UPDATE jobpost SET jobtitle= '$jobtitle', jobdescription= '$jobdescription', jobqualifications= '$jobqualifications' WHERE id=$_GET['id']";
$result = mysql_query($query) or die (mysql_error());
running this code give the following error:
Notice: Undefined index: id in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\pmd\edit_vacancies.php on line 17
select * from jobpost where id=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
Can someone please help!!!!!