#37925 [Opn->Fbk]: After a try catch block, the echo doens't work with an exit
| From: | bjori@php.net | Date: | Tue, 27 Jun 2006 11:52:05 +0000 |
| Subject: | #37925 [Opn->Fbk]: After a try catch block, the echo doens't work with an exit | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-98826@lists.php.net to get a copy of this message | ||
ID: 37925
Updated by: bjori@php.net
Reported By: batataw at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: Output Control
Operating System: Linux Fedora
PHP Version: 5.1.4
New Comment:
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php
If you can provide more information, feel free to add it
to this bug and change the status back to "Open".
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2006-06-27 11:30:52] batataw at gmail dot com
<?
public function insertUser($user){
//call the stored procedure
$sql = "CALL
user_insert(@userId,:username,:passwd,:firstname,:lastname,:email,:web,:country,:language,:gender,:city,:dob,:initial,:avatar,:servicelevelId);";
//Prepare request
try{
$sth = $this->db->prepare($sql);
}
catch(PDOException $e){
$errmsg = implode(":",$sth->errorInfo());
Error::userErrorHandler(E_USER_WARNING, $errmsg, __FILE__, __LINE__,
DRM_ERROR_DB_CALL);
}
$sth->bindParam(":username", $user["username"],PDO::PARAM_STR);
$sth->bindParam(":passwd", $user["passwd"],PDO::PARAM_STR);
$sth->bindParam(":firstname", $user["firstname"],PDO::PARAM_STR);
$sth->bindParam(":lastname", $user["lastname"],PDO::PARAM_STR);
//Execute Request
try{
$sth->execute();
}
catch(PDOException $e){
$errmsg = implode(":",$sth->errorInfo());
Error::userErrorHandler(E_USER_WARNING, 'DB Error : '. $errmsg,
__FILE__, __LINE__, $errmsg); echo "Error Message";
exit;
}
}
?>
------------------------------------------------------------------------
[2006-06-27 11:25:37] tony2001@php.net
I don't think I have $sth and Error::userErrorHandler() method. That's
why I asked for short but COMPLETE reproduce script.
------------------------------------------------------------------------
[2006-06-27 11:18:58] batataw at gmail dot com
<?
try{
$sth->execute();
}
catch(PDOException $e){
$errmsg = implode(":",$sth->errorInfo());
Error::userErrorHandler(E_USER_WARNING, 'DB Error : '. $errmsg,
__FILE__, __LINE__, $errmsg);
echo "Message Error";
exit;
}
?>
------------------------------------------------------------------------
[2006-06-27 11:14:45] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc.
If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[2006-06-27 11:05:14] batataw at gmail dot com
Description:
------------
After a Try/Catch block I used an exit. It's impossible to display all
the echos (print, var_dump...) between the Try/Catch block and the
exit.
I had to use these functions to force the echo :
$buffer = ob_get_flush();//hack
flush();
exit;
Reproduce code:
---------------
//Execute Request
try{
$sth->execute();
}
catch(PDOException $e){
$errmsg = implode(":",$sth->errorInfo());
Error::userErrorHandler(E_USER_WARNING, 'DB Error : '. $errmsg,
__FILE__, __LINE__, $errmsg);
}
------------------------------------
echo "Message Error";
exit;
Expected result:
----------------
Message Error
Actual result:
--------------
Nothing
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37925&edit=1