jmfillman Posted June 27, 2008 Share Posted June 27, 2008 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 More sharing options...
Tchelo Posted June 27, 2008 Share Posted June 27, 2008 Well, it seems to me that you are always throwing the exception. There is not a check to see if the query has been correctly executed. Link to comment https://forums.phpfreaks.com/topic/112121-error-message-help/#findComment-575624 Share on other sites More sharing options...
cooldude832 Posted June 27, 2008 Share Posted June 27, 2008 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 More sharing options...
jmfillman Posted June 27, 2008 Author Share Posted June 27, 2008 Thank you! Link to comment https://forums.phpfreaks.com/topic/112121-error-message-help/#findComment-575636 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.