#35793 [Com]: General error: 2050

2006-03-22 Thread qlogix at gmail dot com
 ID:   35793
 Comment by:   qlogix at gmail dot com
 Reported By:  deadman_great at mail dot ru
 Status:   Assigned
 Bug Type: PDO related
 Operating System: RH Fedora Core 2
 PHP Version:  5CVS-2005-12-25 (snap)
 Assigned To:  Wez
 New Comment:

I can confirm the statement on Centos 4.1, PHP 5.1.2, Mysql 4.1.16

"You cannot use the same variable for a PDOStatement object twice. As
others have pointed out it works when you set this variable to null in
between."

setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$result = $db->query('SELECT COUNT(*) FROM Locations');
echo $result."";
$row = $result->fetchAll(PDO::FETCH_ASSOC); 
/* Comment the next line out and script returns an error */
//$result = null;   
$result = $db->query('SELECT COUNT(*) FROM Accounts');
echo $result."";
$row = $result->fetch(PDO::FETCH_ASSOC); /* This line causes the error
*/
?>


With line "$result = null;" commented out:
Object id #2
Object id #3
PDOException Object
(
[message:protected] => SQLSTATE[HY000]: General error: 2050 

With line "$result = null;" not commented out:
Object id #2
Object id #2

No error message (script works)


Previous Comments:


[2006-03-21 18:37:15] email at steffenweber dot net

I can confirm that this error does not occur on Windows XP + PHP 5.1.2
+ MySQL 5.0.18. It does happen for me on Gentoo Linux + PHP 5.1.2 +
MySQL 4.1.16.

You cannot use the same variable for a PDOStatement object twice. As
others have pointed out it works when you set this variable to null in
between.



[2006-03-18 22:09:27] gg15 at gmx dot net

$result = $db->query('SELECT COUNT(*) FROM XYZ');
$row = $result->fetch(PDO::FETCH_ASSOC);
$result->closeCursor();

$result = $db->query('SELECT * FROM XYZ');
$row = $result->fetch(PDO::FETCH_ASSOC); // this one throws the error

an $result = null; between the statements fixes the issue, so I think
this is a problem of php...



[2006-03-11 10:42:51] peres dot yzqk8 at mailnull dot com

I'd got same problem with this piece of code:

$s = $db->query("SELECT * FROM test ORDER BY poledrugie;");
var_dump($s->fetchAll());
$s = $db->query("SELECT * FROM test ORDER BY poletrzecie;");
var_dump($s->fetchAll());

Changed it to:

$s = $db->query("SELECT * FROM test ORDER BY poledrugie;");
var_dump($s->fetchAll());
$st = $db->query("SELECT * FROM test ORDER BY poletrzecie;");
var_dump($st->fetchAll());

So I think it's wrong use of PHP objects...



[2006-02-14 16:06:00] m at tacker dot org

I can reproduce this bug on two machines (athlon-xp and pentium3) with


PHP 5.1.1-gentoo (cli) (built: Feb 10 2006 18:06:50)
Zend Engine v2.1.0

This is the test case:

http://bugs.php.net/bug.php?id=35793
*
* @author Markus Tacker <[EMAIL PROTECTED]>
* @version $Id: pdo-proxy-bug.php 760 2006-02-14 14:59:19Z mtacker
$
*/

// If you set this to true I will reconnect before each select
// at line 56
// => no crash
$reconnect_before_select = false;

error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 1);

$dsn = array(
'dbtype' => 'mysql',
'host' => 'localhost',
'database' => 'test',
'username' => 'test',
'password' => '',
);

// $DB = new Database;
$DB = new PDO($dsn['dbtype'] . ':host=' . $dsn['host'] . ';dbname='
. $dsn['database'], $dsn['username'], $dsn['password']);

$table = uniqid();

// Create a test table
$sql = 'CREATE TABLE `' . $table . '` ('
. "varname varchar(64) NOT NULL default '',"
. "varvalue tinytext NOT NULL default '',"
. 'PRIMARY KEY (varname)'
. ') ENGINE=InnoDB DEFAULT CHARSET=utf8';
$result = $DB->exec($sql);
if ($result === false and $result->errorCode() != PDO::ERR_NONE) {
exit('Query failed: ' . $sql . "\n");
}
echo 'OK: ' . $sql . "\n";

// Insert into test table
$sql = 'INSERT INTO `' . $table . '`'
. ' (varname, varvalue)'
. ' VALUES (' . $DB->quote('uniqid') . ', ' . $DB->quote($table) .
')';
$result = $DB->exec($sql);
if ($result === false and $r

#36826 [NEW]: Throwing an exception inside an exception handler catch block causes fatal

2006-03-22 Thread qlogix at gmail dot com
From: qlogix at gmail dot com
Operating system: Centos 4.1
PHP version:  5.1.2
PHP Bug Type: Scripting Engine problem
Bug description:  Throwing an exception inside an exception handler catch block 
causes fatal

Description:

Throwing an exception from inside a catch block within an exception
handler function causes a fatal error.

If I comment out the marked line, the fatal error does not occur.

I would expect PHP to re-call the master exception handler function.

Reproduce code:
---
class TestException extends Exception { }
set_exception_handler('handler');

function handler($ex)
{   
/* Just to rule out recursion */
if ($ex instanceof TestException) { die("Recursion"); } 
try 
{   
/* This is where I would attempt to write to the db */
throw new Exception("someDBFunction failed");   

}
catch (Exception $ex)
{   
/* If I comment out the following line, the error goes away */
throw new TestException("The db logging function failed..write 
to
file.");
}   
}
throw new Exception("Ex");

Expected result:

The script should die with the message "Recursion"

Actual result:
--
Fatal error: Exception thrown without a stack frame in Unknown on line 0

-- 
Edit bug report at http://bugs.php.net/?id=36826&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=36826&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=36826&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=36826&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36826&r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=36826&r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=36826&r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=36826&r=needscript
Try newer version:http://bugs.php.net/fix.php?id=36826&r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=36826&r=support
Expected behavior:http://bugs.php.net/fix.php?id=36826&r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=36826&r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=36826&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36826&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=36826&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36826&r=dst
IIS Stability:http://bugs.php.net/fix.php?id=36826&r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=36826&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=36826&r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=36826&r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=36826&r=mysqlcfg


#34369 [NEW]: mssql_query() does not use link identifier

2005-09-04 Thread qlogix at gmail dot com
From: qlogix at gmail dot com
Operating system: Windows Server 2003 STD
PHP version:  4.4.0
PHP Bug Type: MSSQL related
Bug description:  mssql_query() does not use link identifier

Description:

mssql_query() does not use the link identifier your specify. If you open
two database connections using mssql_connect then specify which one of
those connections to use in mssql_query(), the mssql_query() function will
just use the last connection opened, no matter what.

CONN1 is the address to my local mssql server.

Table donations exists in database db1, not in db2
Table tbl_admin_user exists in database db2, not in db1

If I switch the order of connections, the first query works and the second
one fails, and of course vice versa.

In my case, yes, I am opening two connections to the same server, just
changing the name of the database I want to use, however this application
can be configured to connect to to different servers.

Reproduce code:
---
$conn1 = mssql_connect("CONN1","dbuser","dbpass");
mssql_select_db("db1",$conn1);

$conn2 = mssql_connect("CONN1","dbuser","dbpass");
mssql_select_db("db2",$conn2);

$sq = mssql_query("SELECT  * FROM donations",$conn1);

$sq2 = mssql_query("SELECT * FROM tbl_admin_user",$conn2);

Expected result:

No errors.

Actual result:
--
Warning: mssql_query(): message: Invalid object name 'donations'.
(severity 16) in C:\htdocs\noname2.php on line 8

Warning: mssql_query(): Query failed in C:\htdocs\noname2.php on line 8

-- 
Edit bug report at http://bugs.php.net/?id=34369&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=34369&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=34369&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=34369&r=trysnapshot51
Fixed in CVS:http://bugs.php.net/fix.php?id=34369&r=fixedcvs
Fixed in release:http://bugs.php.net/fix.php?id=34369&r=alreadyfixed
Need backtrace:  http://bugs.php.net/fix.php?id=34369&r=needtrace
Need Reproduce Script:   http://bugs.php.net/fix.php?id=34369&r=needscript
Try newer version:   http://bugs.php.net/fix.php?id=34369&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34369&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=34369&r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=34369&r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=34369&r=submittedtwice
register_globals:http://bugs.php.net/fix.php?id=34369&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=34369&r=php3
Daylight Savings:http://bugs.php.net/fix.php?id=34369&r=dst
IIS Stability:   http://bugs.php.net/fix.php?id=34369&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34369&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=34369&r=float
No Zend Extensions:  http://bugs.php.net/fix.php?id=34369&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=34369&r=mysqlcfg