Jump to content


how to determine a action has been completed

  • Please log in to reply
2 replies to this topic

#1 Maverickb7

  • Members
  • PipPipPip
  • Advanced Member
  • 112 posts

Posted 10 April 2006 - 06:10 AM

Hello-- I have a cms I'm working on and would like to get some help with something. I add/edit/remove articles using PHP and MySQL. I usually use something like:
$query = "UPDATE table SET tablecolumn = '$stuff'";
I was wondering how I could confirm that its been successful and display text such as "Update Successful"?

#2 toplay

  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 10 April 2006 - 06:57 AM

See instructions and code examples of the mysql_query() at:

[a href=\"http://us2.php.net/manual/en/function.mysql-query.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.mysql-query.php[/a]

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
For other type of SQL statements, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error.

#3 Yesideez

  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 10 April 2006 - 07:46 AM

I use something like this:
if (mysql_query("UPDATE table SET `field`='$newcontents' WHERE `condition`='true'")) {
  echo "Update successful";
} else {
  echo "Update failed";
It works for me :)
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users