CODE
<?php
mysql_connect ('localhost', '****', '****');
mysql_select_db ('****');
if (isset($_POST['update'])) {
$id = (int)$_POST['id'];
$id = htmlspecialchars(strip_tags($_POST['id']));
$name = htmlspecialchars(strip_tags($_POST['name']));
$email = htmlspecialchars(strip_tags($_POST['email']));
$site = htmlspecialchars(strip_tags($_POST['site']));
$info = $_POST['info'];
$info = nl2br($info);
if (!get_magic_quotes_gpc()) {
$title = addslashes($title);
$info = addslashes($info);
}
$result = mysql_query("UPDATE fas_portrait SET name='$name', email='$email', site='$site', info='$info', WHERE id='$id'") or print ("Can't update info.<br />" . mysql_error());
}
if (!isset($_GET['id']) || empty($_GET['id']) || !is_numeric($_GET['id'])) {
die("Invalid info ID.");
}
else {
$id = (int)$_GET['id'];
}
$result = mysql_query ("SELECT * FROM fas_portrait WHERE id='$id'") or print ("Can't select info.<br />" . $sql . "<br />" . mysql_error());
while ($row = mysql_fetch_array($result)) {
$old_title = stripslashes($row['title']);
$old_info = stripslashes($row['info']);
$old_name = $row['name'];
$old_email = $row['email'];
$old_site = $row['site'];
$old_title = str_replace('"','\'',$old_title);
$old_info = str_replace('<br />', '', $old_info);
}
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p><input type="hidden" name="id" value="<?php echo $id; ?>" />
<strong><label for="name">Name:</label></strong> <input type="text" name="name" id="name" size="40" value="<?php echo $old_name; ?>" /></p>
<p><strong><label for="email">Email:</label></strong> <input type="text" name="email" id="email" value="<?php echo $old_email; ?>" size="40" /> </p>
<p><strong><label for="site">Website:</label></strong> <input type="text" name="site" id="site" value="<?php echo $old_site; ?>" size="40" /> </p>
<p><strong><label for="info">Information:</label></strong><br />
<textarea cols="80" rows="20" name="info" id="info"><?php echo $old_info; ?></textarea></p>
<p><input type="submit" name="update" id="update" value="Update"></p>
</form>
<?php
mysql_close();
?>
Now, the error I'm getting is this:
CODE
Can't update info.
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='1'' at line 1Invalid info 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 'WHERE id='1'' at line 1Invalid info ID.
It's exactly like that. I finally got everything to show, but now I cannot edit it from the admin panel. Any help would be appreciated.