php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46997 Column Name Based Result Fetching Causes Access Violation
Submitted: 2009-01-03 13:58 UTC Modified: 2009-02-13 01:00 UTC
Votes:7
Avg. Score:4.6 ± 0.7
Reproduced:7 of 7 (100.0%)
Same Version:4 (57.1%)
Same OS:2 (28.6%)
From: dangerousdave86 at hotmail dot com Assigned:
Status: No Feedback Package: MySQLi related
PHP Version: 5.2.8 OS: win32 only - W Server 2008 Std
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dangerousdave86 at hotmail dot com
New email:
PHP Version: OS:

 

 [2009-01-03 13:58 UTC] dangerousdave86 at hotmail dot com
Description:
------------
Error: PHP has encountered an Access Violation at 00322BEB When calling mysqli_fetch_assoc or mysqli_fetch_object on mysqli result. Also occurs using OO method.

Error does not occur when using mysqli_fetch_row. Result is correct and indexed numerically in array.

Reproduce code:
---------------
Any database query using mysql that fetches rows using mysql_fetch_object, _fetch_assoc, _fetch_array. Or OO equivilents.

Expected result:
----------------
an array representing a row from the database

Actual result:
--------------
Access Violation

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-04 21:09 UTC] dangerousdave86 at hotmail dot com
Replication Code:
<?php
# Connect to DB
$db = mysqli_connect('localhost','root','','');
$res = mysqli_query($db, 'CREATE TEMPORARY TABLE tst1 (c1 VARCHAR(8), c2 VARCHAR(8))');
$res = mysqli_query($db, 'INSERT INTO tst1 (c1, c2) VALUES ("aa","bb"), ("cc","dd")');
$res = mysqli_query($db, 'SELECT * FROM tst1');
$data = mysqli_fetch_assoc($res);
var_dump($data);
?>
Never reaches VAR_DUMP(); Errors on MYSQLI_FETCH_ASSOC(); PHP has encountered an Access Violation at 004B2BEB
 [2009-02-05 14:14 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-02-06 20:45 UTC] pslide at gmail dot com
For me, the latest Windows VC6 thread safe snapshot, dated 2009-Feb-05 12:00:00, did not work.

My machine:
Windows XP Pro SP3
IIS 5.1, with PHP ISAPI module

(If this is not helpful, please accept my apologies and delete.)
 [2009-02-13 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-02-18 11:18 UTC] mark at kramtek dot com dot au
Same problem, seems to be column related. Test cases below
Cheers,
Mark

<?php
// MySQL libmysql.dll version from MySQL 5.1.30 ( Version 5.1.30 )
// PHP version 5.2.8
// When using the libmysql.dll version that came with PHP 5.2.8 all works fine ( version is 5.0.51a )
// Problem seems to be when multiple columns are mentioned.
// OS Windows Vista on IIS 7
// Browser IE7 and FireFox ( Only Firefox shows the error, IE7 gives a HTTP 500 error )
// PHP version 5.2.8 ( ISAPI )
// MySQL 5.1.30
// My workaround is to is use the library that came with PHP
//

// Fails with PHP has encountered an Access Violation at 01582BEB
$mysqli = new mysqli("localhost", "my_user", "my_password", "my_db");
$result = $mysqli->query("SELECT id, admin_name FROM admin_users LIMIT 1");
$row = $result->fetch_object();
$result->close();
echo $row->id;

// Works with 2nd column name removed
$mysqli = new mysqli("localhost", "my_user", "my_password", "my_db");
$result = $mysqli->query("SELECT id FROM admin_users LIMIT 1");
$row = $result->fetch_object();
$result->close();
echo $row->id;

// Works with single column
$mysqli = new mysqli("localhost", "my_user", "my_password", "my_db");
$result = $mysqli->query("SELECT admin_name FROM admin_users LIMIT 1");
$row = $result->fetch_object();
$result->close();
echo $row->admin_name;

// mysql also fails with PHP has encountered an Access Violation at 021EAC5A
$link = mysql_connect('localhost', 'my_user', 'my_password');
$result = mysql_query("SELECT id, admin_name FROM admin_users LIMIT 1");
$row = mysql_fetch_row($result);
mysql_close($link);
echo $row[0];
echo $row[1];

// Also fails with one column selected :-(
$link = mysql_connect('localhost', 'my_user', 'my_password');
$result = mysql_query("SELECT id FROM admin_users LIMIT 1");
$row = mysql_fetch_row($result);
mysql_close($link);
echo $row[0];
?>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 23:01:27 2024 UTC