Jump to content

[SOLVED] UPDATE, DELETE functionality not working with CMS


mjurmann

Recommended Posts

Hey there. I'm building a CMS for my client, but I'm having problems. The information to be edited is filtered correctly according to "id" on the edit page. Once changes are made in the text areas boxes, and the submit button is clicked, the page is supposed to go to a update_processor page that will add the new information posted by the form to the database. Once the information is updated, the user is redirected via the Header command to the Admin's index page. I have done this many times before, and it has always worked. However, I've never got it to work with this host. I'm not sure if there is a setting I have to change or something I have to look for that allows the database to be updated via the UPDATE command. The DELETE command doesn't work either. (Haven't tried the ADD, but I'm sure it won't either.)

Here is my code on the processor page:

[code]<?php
$host = "myhostipaddress";
$user = "myusername";
$pwd = "mypassword";
$dbConn = mysql_connect($host,$user,$pwd);
// Connect to Database
$database = "alanhaft_cms";
mysql_select_db($database);

$query_updateEntry = "UPDATE about_cms SET id='".$_GET['id']."', paragraph1='".$_POST['p1']."', paragraph2='".$_POST['p2']."', paragraph3='".$_POST['p3']."', paragraph4='".$_POST['p4']."', paragraph5='".$_POST['p5']."' WHERE id=".$_GET['id'];

$updateEntry = mysql_query($query_updateEntry);

header("Location: ../index.php");
?>[/code]

Please help me guys! I'm using network solutions as the host and domain providers!
This might sound dumb, but the network solutions mysql servers just had a case of the stupids in the last 15 minutes. I was having issues with it as well, running an UPDATE query.

I only found out it was the mysql servers when I tried to run the translated query through phpmyadmin.

See if the query works directly. If not, troubleshoot from there. You may find the issue was the server, and not the code. That was my issue about 4 minutes ago.

Jusy my $0.02
I really appreciate the response, However, I've been trying this since late last night - probably about 12 hours of looking at my code more times than I'd like to admit! Anyone else? I feel this has to be an option that is turned off, but I'm not sure.
just a try:
[code]

<?php

if(empty($_GET['id']))
{
  die("No id");
}
else
{
  $id = $_GET['id'];
  settype($id, integer);
}

$host = "myhostipaddress";
$user = "myusername";
$pwd = "mypassword";
$dbConn = mysql_connect($host,$user,$pwd);
// Connect to Database
$database = "alanhaft_cms";
mysql_select_db($database);


$query_updateEntry = "UPDATE about_cms SET paragraph1='".$_POST['p1']."', paragraph2='".$_POST['p2']."', paragraph3='".$_POST['p3']."', paragraph4='".$_POST['p4']."', paragraph5='".$_POST['p5']."' WHERE id='$id'";

$updateEntry = mysql_query($query_updateEntry) or die(mysql_error());

header("Location: ../index.php");
exit();

?>

[/code]
[quote author=alpine link=topic=118095.msg482326#msg482326 date=1165792478]
just a try:
[code]

<?php

if(empty($_GET['id']))
{
  die("No id");
}
else
{
  $id = $_GET['id'];
  settype($id, integer);
}

$host = "myhostipaddress";
$user = "myusername";
$pwd = "mypassword";
$dbConn = mysql_connect($host,$user,$pwd);
// Connect to Database
$database = "alanhaft_cms";
mysql_select_db($database);


$query_updateEntry = "UPDATE about_cms SET paragraph1='".$_POST['p1']."', paragraph2='".$_POST['p2']."', paragraph3='".$_POST['p3']."', paragraph4='".$_POST['p4']."', paragraph5='".$_POST['p5']."' WHERE id='$id'";

$updateEntry = mysql_query($query_updateEntry) or die(mysql_error());

header("Location: ../index.php");
exit();

?>

[/code]
[/quote]


I'm getting an error that says "No id" on the next page! What does this mean? Ahhh I can't believe that!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.