...

View Full Version : Update?



Dat
11-18-2007, 08:08 PM
I've gone through it 100 times and I can't seem to find the error, and I've worked with php for a very long time, I'm sure anyone can find the error in my sick state.

I updated my form and now it will not update...

if($_POST['edit_submit']) {

$id = $_POST['id'];
$type = escape_data( $_POST['type'] );
$title = escape_data( $_POST['title'] );
$titlejap = escape_data( $_POST['japtitle'] );
$image= escape_data( $_POST['image'] );
$genres = escape_data( $_POST['genres'] );
$formats = escape_data( $_POST['formats'] );
$episode_number = escape_data( $_POST['episode_number'] );
$length = escape_data( $_POST['length'] );
$year = escape_data( $_POST['year'] );
$opening = escape_data( $_POST['opening'] );
$ending = escape_data( $_POST['ending'] );
$summary = escape_data( $_POST['summary'] );
$episode = escape_data( $_POST['episode'] );
$review = escape_data( $_POST['review'] );
$s_author = escape_data( $_POST['s_author'] );
$r_author = escape_data( $_POST['r_author'] );
$last_updated = date("Y-m-d");

//Check if any fields are empty or not
if((empty($title)) OR (empty($summary))) {
echo "<center><b>Please fill in all required fields!</b></center>";

} else {
//The MySQL query which will update the content in the table.
$query = "UPDATE anime_reviews SET title = '$title', title_jap = '$titlejap', image = '$image', genres = '$genres', formats = '$formats', episode_number = '$episode_number', length = '$length', released = '$year', opening_t = '$opening', ending_t = '$ending', summary = '$summary', review = '$review', s_author = '$s_author', r_author = '$r_author', episodes = '$episode', last_updated = '$last_updated', type = '$type' WHERE id = '$id'";
//Execute the query.
$result = mysql_query($query) or die(mysql_error());
echo '<meta http-equiv="Refresh" content="10; URL=/" />The entry has been edited, please wait a few seconds (3) while I redirect you.<br> if not then click <a href="/">here!</a>';

}

mlseim
11-18-2007, 11:33 PM
how about this ... at the very end ...

//Execute the query.
$result = mysql_query($query) or die(mysql_error());
echo '<meta http-equiv="Refresh" content="10; URL=/" />The entry has been edited, please wait a few seconds (3) while I redirect you.<br> if not then click <a href="/">here!</a>';

}
}

Dat
11-18-2007, 11:48 PM
Sorry, I didn't want to include my WHOLE code but that wasn't the problem:

This is what's underneath the given code:

} elseif($_GET['id']) {

After this is the form and so on and so on...

I've partially tested it by placing an echo before the MySQL Query so the form is work perfectly I think.

Dat
11-19-2007, 03:19 AM
Oh, I found the problem, it was my form I was missing a tag to declare the id

<input type="hidden" name="id" value="<?php echo "$id"; ?>" />

Inigoesdr
11-19-2007, 05:07 AM
You need to use intval() or similar on $_POST['id'];

$id = intval($_POST['id']);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum