TGWSE_GY Posted August 17, 2009 Share Posted August 17, 2009 Ok guys, I will attach the code below. When this scripts run I have echoed all variables and they return the correct values, however it executes the mysql update query in CASE 0 and returns no errors however it does NOT update the corresponding record in the database. I have ran the query in terminal mode and it works just fine. The mysql database connection info held in config.php is correct and I have no idea why this query is not working. <?php //This script will process the updates to the article that is designated by the sectionid passed from the previouse php page in the form. //Then we will take this and store it into the correct table of the database. Remember we always call our database configuration at the start. //Get database connectiong config include('phpcontent/config.php'); $id = $_POST['id']; $date = date(mdo); $tblnews = "sndsurf_news"; $tblreviews = "sndsurf_reviews"; $tblradio = "sndsurf_radio"; //Get the entries from the form. $section = $_POST['section']; $title = addslashes($_POST['title']); $new_article = $_POST['article']; $summary = addslashes($_POST['summary']); $search = "src=\"http://www.hmtotc.com/dev/projects/VRassoc/jamsmagazine.com/images"; $replace = "src=\"images"; $article = str_replace($search, $replace, $new_article); $article = addslashes($article); switch ($section) { case 0: //News mysql_query("UPDATE sndsurf_news SET title='$title', article='$article', summary='$summary', date='$date' WHERE id='$id'") or die(mysql_error()); $sectionid = "edit_news"; break; case 1: //Radio $tbl = $tblradio; mysql_query("INSERT INTO `$tblradio` ( article , date) VALUES ('$article', '$date')") or die(mysql_error()); $sectionid = "edit_radio"; break; case 2: //Reviews $tbl = $tblreviews; mysql_query("INSERT INTO `$tblreviews` ( article , date) VALUES ('$article', '$date')") or die(mysql_error()); $sectionid = "edit_reviews"; break; } header("Location: http://www.hmtotc.com/dev/projects/VRassoc/jamsmagazine.com/admin/classes/forms/maineditor.php?section=edit_news"); ?> Thanks Guys :facewall: :facewall: Quote Link to comment https://forums.phpfreaks.com/topic/170739-solved-update-statement-not-working-but-returning-no-errors/ Share on other sites More sharing options...
onedumbcoder Posted August 17, 2009 Share Posted August 17, 2009 Well if the query executes and gives u no errors, then the only possible issue is that the $id you are providing is not the value you are looking for. Make sure what ever id value you are posting there is the one you want to be changing. Quote Link to comment https://forums.phpfreaks.com/topic/170739-solved-update-statement-not-working-but-returning-no-errors/#findComment-900511 Share on other sites More sharing options...
TGWSE_GY Posted August 17, 2009 Author Share Posted August 17, 2009 I have echoed the '$id' and it is returning the appropriate value. Quote Link to comment https://forums.phpfreaks.com/topic/170739-solved-update-statement-not-working-but-returning-no-errors/#findComment-900514 Share on other sites More sharing options...
TGWSE_GY Posted August 18, 2009 Author Share Posted August 18, 2009 Okay after pouring over this code, I don't see where the issue is. Is there any reason why an update query would fail to update the record that it is suppose to. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/170739-solved-update-statement-not-working-but-returning-no-errors/#findComment-900575 Share on other sites More sharing options...
onedumbcoder Posted August 18, 2009 Share Posted August 18, 2009 here is my suggestion, delete the lines of code u have for case 0 and rewrite them from scratch, do not copy and past. Quote Link to comment https://forums.phpfreaks.com/topic/170739-solved-update-statement-not-working-but-returning-no-errors/#findComment-900605 Share on other sites More sharing options...
fenway Posted August 21, 2009 Share Posted August 21, 2009 Echo the queries and post them. Quote Link to comment https://forums.phpfreaks.com/topic/170739-solved-update-statement-not-working-but-returning-no-errors/#findComment-903210 Share on other sites More sharing options...
TGWSE_GY Posted August 26, 2009 Author Share Posted August 26, 2009 onedumbcoder was right, it just needed to be rewritten IDK what the problem was possibly something in cache. Thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/170739-solved-update-statement-not-working-but-returning-no-errors/#findComment-906953 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.