#37925 [Bgs]: After a try catch block, the echo doens't work with an exit

From: Date: Fri, 30 Jun 2006 11:28:21 +0000
Subject: #37925 [Bgs]: 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-98991@lists.php.net to get a copy of this message
 ID:               37925
 Updated by:       tony2001@php.net
 Reported By:      batataw at gmail dot com
 Status:           Bogus
 Bug Type:         Output Control
 Operating System: Linux Fedora
 PHP Version:      5.1.4
 New Comment:

I don't have your database and your tables, including "user" table.
Please provide COMPLETE reproduce script that doesn't require any
nonexistent tables, database and stored procedures.
You can create them in the script itself, btw.


Previous Comments:
------------------------------------------------------------------------

[2006-06-30 11:18:07] batataw at gmail dot com

Below, the store procedure.

BEGIN
	#declare local variables
	DECLARE sp_userId BIGINT(30) DEFAULT 0;

	#declare copies of incoming variables
	DECLARE sp_username VARCHAR(30);
	DECLARE sp_passwd VARCHAR(20);


	#tidy input and apply initial transformations
	SET sp_username = TRIM(in_username);
	SET sp_passwd = TRIM(in_passwd);

	#the insert
	INSERT INTO user
	(username, passwd)
	VALUES
	(sp_username, sp_passwd);

	#get the new userId
	SELECT LAST_INSERT_ID() INTO sp_userId;

	#set the output variable
	SET out_userId = sp_userId;
END

------------------------------------------------------------------------

[2006-06-30 11:06:55] tony2001@php.net

42000:1305:PROCEDURE test.user_insert does not exist

------------------------------------------------------------------------

[2006-06-30 10:56:55] batataw at gmail dot com

<?php

		define ('DRM_DMDB_DEV',  'dev');

		$GLOBALS[DRM_DMDB_DEV]['db_dsn'] 		=
"mysql:dbname=mydatabase;host=localhost";
		$GLOBALS[DRM_DMDB_DEV]['db_user']		= "root";
		$GLOBALS[DRM_DMDB_DEV]['db_passwd']		= "";
		
		$conf = DRM_DMDB_DEV;


	   	try{
			$db = new PDO($GLOBALS[$conf]['db_dsn'], $GLOBALS[$conf]['db_user'],
$GLOBALS[$conf]['db_passwd']);
			$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
			$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);			
		}
		catch(PDOException $e){			
			$errmsg = "connection failed: ".$e->getMessage();
			echo $errmsg;
			exit;
		}	

    	    	
    	    	
		//call the stored procedure
		$sql = "CALL user_insert(@userId,:username,:passwd);";
				
		//Prepare request
		try{
			$sth = $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);
																							
		//Execute Request
		try{
			$sth->execute();
		}
		catch(PDOException $e){
					
			$errmsg = implode(":",$sth->errorInfo());
			echo $errmsg;
			exit; 						
		}		
		
		
		echo "OK !";
		

?>

------------------------------------------------------------------------

[2006-06-27 11:53:50] tony2001@php.net

Please provide SHORT AND COMPLETE reproduce script, which I can
copy/paste and run to reproduce your problem.
Until then -> bogus.

------------------------------------------------------------------------

[2006-06-27 11:52:05] bjori@php.net

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.




------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/37925

-- 
Edit this bug report at http://bugs.php.net/?id=37925&edit=1


Thread (11 messages)

« previous php.bugs (#98991) next »