Jump to content

Error Message Help


jmfillman

Recommended Posts

I'm using the following function to return data to Adobe Flex:

 

  public function cancelUpdate($id, $cancelDate) {

$date5 = date("Y-m-d H:i:s", $canceldate);

$query = "UPDATE apData SET status=1, cancelDate='$date5' WHERE id='$id'";

$result = mysql_query($query);

$msg=$this->err_prefix."INSERT query error: ".$this->mysql->error;

throw new Exception($msg);

return true;

  }

 

The problem I am encountering is that even when the update query is successful, PHP is returning "INSERT query error: ". What am I doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/112121-error-message-help/
Share on other sites

The most common convention for query error reporting is

<?php
   public function cancelUpdate($id, $cancelDate) {
   $date5 = date("Y-m-d H:i:s", $canceldate);
   $query = "UPDATE apData SET status=1, cancelDate='$date5' WHERE id='$id'";
   $result = mysql_query($query) or die(mysql_error()."<br /><br />\n\n".$query);
         $msg=$this->err_prefix."INSERT query error: ".$this->mysql->error;
         throw new Exception($msg);
   return true;
   }
?>

if you want to integrate a "throw exception" into it you need to say

<?php
   public function cancelUpdate($id, $cancelDate) {
   $date5 = date("Y-m-d H:i:s", $canceldate);
   $query = "UPDATE apData SET status=1, cancelDate='$date5' WHERE id='$id'";
   $result = mysql_query($query) or die(mysql_error()."<br /><br />\n\n".$query);
   if(!$result){
         $msg=$this->err_prefix."INSERT query error: ".$this->mysql->error;
         throw new Exception($msg);
  }
else{
   return true;
}
   }

Link to comment
https://forums.phpfreaks.com/topic/112121-error-message-help/#findComment-575629
Share on other sites

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.