php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47283 mysql_connect call crashes web server
Submitted: 2009-02-02 21:59 UTC Modified: 2009-02-11 10:37 UTC
From: darren at misterdoom dot com Assigned: pajoye (profile)
Status: Not a bug Package: MySQL related
PHP Version: 5.2.8 OS: win32 only - Vista Home Premium
Private report: No CVE-ID: None
 [2009-02-02 21:59 UTC] darren at misterdoom dot com
Description:
------------
I have a really strange problem. I've recently re-installed my computer and set up IIS7, PHP and MySQL so that I could carry on working on my website.

I did a quick test with phpinfo(); and everything seemed to be working fine. Then set up 2 blank documents and started working on opening a connection to a database, which is when all the trouble started. On viewing the page, I would get the following message "PHP has encountered an Access Violation at 01FCAC5A" and windows would also produce an error message stating that IIS had been stopped. If I comment out the mysql_connect line it worked fine. 

I read some things about a possible problem with the php5isapi.dll, so I installed Apache 2.2.1.1 web server, set up PHP, but got exactly the same result.

Reproduce code:
---------------
file 1 (index.php)
<?php
	require("farq.php");
?>
<html>
  <head>
      <title>Site Administration</title>
<?php
	// If cookie, redirect
?>
  </head>
  
  <body>
    <!-- If no cookie, show form. -->
    <form action="index.php" method="post">
    	<input name="username" maxlength="255">
      <input name="password" maxlength="255">
      <input type="submit">
    </form>
  </body>
</html>

File 2 (farq.php)
<?php
	$conn = mysql_connect('localhost', 'dbuser', 'dbpass') or die ('Error connecting to mysql');
	echo "conncected";
	mysql_select_db("dbname", $conn) or die ("Could not select to main database");
?>

Expected result:
----------------
I would expect to see connected followed by a form.

Actual result:
--------------
in the browser:
Internet Explorer cannot display the webpage

Windows also pops up the alert box:
Apache HTTP Server stopped working and was closed

If I comment out the line "$conn = mysql_connect('localhost', 'dbuser', 'dbpass') or die ('Error connecting to mysql');" The page displays correctly.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-06 13:25 UTC] kalle@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.


 [2009-02-06 13:46 UTC] pajoye@php.net
And you have installed mysql 5.1 right?
 [2009-02-06 22:44 UTC] darren at misterdoom dot com
Yes, I am running MySql 5.1.11.

I have un-installed PHP 5.2.8 as I needed to continue working on my web site. I now have PHP 5.2.5 installed, and the problem does not occur.
 [2009-02-10 10:44 UTC] tony2001@php.net
Pierre, you seem to know what's wrong there - is this some lib version incompatibility?
 [2009-02-10 18:40 UTC] pajoye@php.net
Do not ever use DLLs from mysql but only the one we provide with PHP. Be sure that PHP's install directory (where the libmysql.dll is) is first in your path for apache.

Not a php bug > bogus.
 [2009-02-11 09:20 UTC] darren at misterdoom dot com
I used the PHP supplied DLLS. The PHP extensions directory is in the path information, the MySQL DLL was visible. This problem happened with IIS 7, not just Apache.

Thinking about it logically, if the DLL was not visible or the incorrect DLL with the 5.2.8 install, it would have still not been visible or correct with the 5.2.5 install, which is working.

This is a bug, not bogus.
 [2009-02-11 09:26 UTC] pajoye@php.net
Please, read again what I said. There is dozen other reports about this exact issue with detailed explanations. Take a look at them.
 [2009-02-11 10:28 UTC] darren at misterdoom dot com
I have read what you said, and it from my understanding, you are saying that my install was either not finding the dll, or finding the incorret dll because the path information is incorrect. It also seemed to relate only to Apache

I ask, if that is the case, then why does it work after uninstalling 5.2.8 and installing 5.2.5 without any path information changing?

Also, the problem was present in both Apache and IIS 7.

I did search for the error, however most of the answers that I could see pointed the error at a bad version of the ISAPI dll.
 [2009-02-11 10:37 UTC] pajoye@php.net
In your setup, PHP uses libmysql.dll from mysql 5.1, and that's why it crashes, I'm 99.999% sure about that.

Try php.exe using CLI from a command line:

cd c:\php528
php -dextension_dir=ext -dextension=php_mysql.dll mysql.php

and it will work smoothly. 


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 06:01:29 2024 UTC