Jump to content

[SOLVED] UPDATE Statement not working but returning no errors


Recommended Posts

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: :facewall: :facewall: :facewall:

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.