Jump to content

[SOLVED] Help editing rows


cs1h

Recommended Posts

Hi,

 

I have a script that is meant to be used to edit a row in a mysql table but its not doing it, I'm not getting any errors, its just not updating.

 

Can anyone help?

 

The script is

<?php

include "dog.php";

$email=$_POST['Email']; 
$name=$_POST['name']; 
$title=$_POST['title']; 
$id=$_POST['hiddenField'];
$Abs=$_POST['message']; 
$Art=$_POST['messagetwo']; 

mysql_connect("localhost", "zzz", "xxx") or die(mysql_error()) ; 
mysql_select_db("real") or die(mysql_error()) ; 

mysql_query(" UPDATE items
SET Email='$email', name='$name', title='$title', Abstract='$Abs', Article='$Art',  WHERE id='$id'");

echo "Changes made to $title.<br /> <a href='arteditor.php'>Click here</a> to return to the admin home.";

?>

 

Thanks

Colin

Link to comment
Share on other sites

Instead of...

 

<?php

  mysql_query(" UPDATE items
SET Email='$email', name='$name', title='$title', Abstract='$Abs', Article='$Art',  WHERE id='$id'");

?>

 

Use....

 

<?php

  $sql = "UPDATE items SET Email='$email', name='$name', title='$title', Abstract='$Abs', Article='$Art',  WHERE id='$id'";
  if (mysql_query($sql)) {
    echo "Success";
  } else {
    echo mysql_error() . "<br />$sql";
  }

?>

 

Now what do you get?

Link to comment
Share on other sites

Thanks for the reply,

 

I made the changes surgested, but I now get the following error,

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id=16' at line 1

UPDATE items SET Email='This is a system test', name='This is a system test ', title='This is a system test', Abstract='This is a system test ', Article='This is a system test ', WHERE id=16

 

The new script is

<?php

include "dog.php";

$email=$_POST['Email']; 
$name=$_POST['name']; 
$title=$_POST['title']; 
$id=$_POST['hiddenField'];
$Abs=$_POST['message']; 
$Art=$_POST['messagetwo']; 

mysql_connect("localhost", "zzz", "xxx") or die(mysql_error()) ; 
mysql_select_db("real") or die(mysql_error()) ; 

$sql = "UPDATE items SET Email='$email', name='$name', title='$title', Abstract='$Abs', Article='$Art',  WHERE id=$id";
 if (mysql_query($sql)) {
   echo "Success";
 } else {
   echo mysql_error() . "<br />$sql";
 }


?>


 

Any ideas why?

 

All help is very much appreciated.

 

Thanks

Colin

Link to comment
Share on other sites

Done that but still no luck, I'm still getting the error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = 16' at line 1

UPDATE items SET Email='This is a system test ', name='This is a system test ', Title='This is a system test ', Abstract='This is a system test ', Article='This is a system ', WHERE id = 16

 

Any more ideas, all help is appriciated.

 

Thanks

Colin

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.