4 Replies - 1325 Views - Last Post: 11 August 2007 - 11:26 AM Rate Topic: -----

#1 k0b13r   User is offline

  • D.I.C Head
  • member icon

Reputation: 15
  • View blog
  • Posts: 243
  • Joined: 18-July 06

Updating database records

Post icon  Posted 11 August 2007 - 02:44 AM

Hi :) I have this code:
$title_new = $_POST['title_new'];
$content_new = $_POST['content_new'];

if(isset($title_new) && isset($content_new))
{
	mysql_query("UPDATE note SET title = $title_new WHERE id = $edited");
	mysql_query("UPDATE note SET content = $content_new WHERE id = $edited");
	mysql_query("INSERT INTO note VALUES('', '', '', '', '$last_edit'");
}
?>



This should update note title, content and add last_edit date in database, but when I process this, nothing happens :/ mysql_error(); give me no info. What can be wrong? Of course $edited is set

This post has been edited by k0b13r: 11 August 2007 - 02:46 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Updating database records

#2 MitkOK   User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 403
  • Joined: 09-August 07

Re: Updating database records

Posted 11 August 2007 - 03:24 AM

Pay attention to the quotes :

	mysql_query("UPDATE note SET title = '$title_new' WHERE id = '$edited' ");
	mysql_query("UPDATE note SET content = '$content_new' WHERE id = '$edited' ");
	mysql_query("INSERT INTO note VALUES('', '', '', '', '$last_edit'");

?>



Hint : You can update the table with one query :
mysql_query("UPDATE note SET title = '$title_new', content = '$content_new' WHERE id = '$edited'");

Was This Post Helpful? 0
  • +
  • -

#3 k0b13r   User is offline

  • D.I.C Head
  • member icon

Reputation: 15
  • View blog
  • Posts: 243
  • Joined: 18-July 06

Re: Updating database records

Posted 11 August 2007 - 03:30 AM

Thanks for hint, but this still don't work :(
Was This Post Helpful? 0
  • +
  • -

#4 MitkOK   User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 403
  • Joined: 09-August 07

Re: Updating database records

Posted 11 August 2007 - 04:02 AM

View Postk0b13r, on 11 Aug, 2007 - 03:30 AM, said:

Thanks for hint, but this still don't work :(

Do this and tell us what is printed :

$title_new = $_POST['title_new'];
$content_new = $_POST['content_new'];

$query = "UPDATE note SET title = '$title_new', content = '$content_new' WHERE id = '$edited' ";

echo $query;

Was This Post Helpful? 0
  • +
  • -

#5 Amadeus   User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 253
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Updating database records

Posted 11 August 2007 - 11:26 AM

Better yet, simply echo $edited to see the value. If it does not hold a valid value, the records will not be found for updating.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1