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!
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

[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!
Link to comment
Share on other sites

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.