PHP, how to re-submit an edited form php code help PLEASE!?

Max

New member
Hi, i'm recently been making a website, and i'd like to add an edit feature. I got to the point where i was recalling all the info in the post, and echoing it out back into a form, this was all going swimmingly, but now i've tried to write the re-submit part, which i thought would be easy, just post it back into my DB and use the UPDATE funtion in my mysql statement, however now i'm getting a T_Logical error at my while loop. Which was previously working fine, i dont understand what i've done. :(
I've been using the get variable to bring the 'id' of my post across to be edited (encase you were wondering), can anyone help me please :(


$connect = mysql_connect("********************") or die ("Couldn't connect");
mysql_select_db("********************") or die (mysql_error());

$id = $_GET['id'];




$edits = mysql_query("SELECT * FROM ads WHERE id='$id'");


while($row = mysql_fetch_assoc($edits)) or die (mysql_error());


{
$title = $row['title'];
$category = $row['category'];
$ads = $row['ads'];
$location = $row['location'];
$body = $row['body'];
$contact = $row['contact'];
$email = $row['email'];
$telephone = $row['telephone'];
$date = $row['date'];
$author = $row['author'];





}




$id = $_GET['id'];


If ($_POST['post'])

{

$title = $_POST['title'];
$category = $_POST['category'];
$ads = $_POST['ads'];
$location = $_POST['location'];
$body = $_POST['body'];
$contact = $_POST['contact'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$end = date("Y-m-d", mktime(0,0,0,$month,$day,2009));
$date = $_POST['date'];
$day = $_POST['day'];
$month = $_POST['month'];
$author = $_POST['author'];




if ($title&&$category&&$ads&&$location&&$body&&$contact&&$email&&$end)
{
mysql_connect("************************") or die (mysql_error());
mysql_select_db("************") or die (mysql_error());

$date = date("Y-m-d");
$end = date("Y-m-d", mktime(0,0,0,$month,$day,2009));
$day = $_POST['day'];
$month = $_POST['month'];
$author = $_SESSION['username'];
$id = $_GET['id'];






$insertedit = mysql_query("UPDATE INTO ads SET WHERE `id`='$id' ('', '$title','$category','$ads','$location','$body','$contact','$email','$telephone','$end','$date','$author')") or die(mysql_error());

die("WOW! Wasn't thateasy");
<a href='index.php'>No thanks, Take me back to the home page</a>");
}
else
echo "Please complete all fields<p>";


}







?>

<form action='edit.php' method='POST'>
<table>
<tr>
<td>
Title:
</td>
<td>
<input type='text' name='title' value='<?php echo "$title";?>'>
</tr>

This is just what my form looks like, Not all of it obviously, jsut a preview so you can see why i am echoing out all the info back into the form so it can be edited and resent.

I have no idea what i've done, i'm relativly new to php and i miss things. Hope you can help

Thank you
 
Back
Top