Need help. "PHP has encountered an Access Violation at XXXXX"

I have a problem and need help.  (crying a little over here)

I put a script on my server that included the following:

$link = mysql_connect('localhost', 'username', 'password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
echo 'Connected successfully';

And when I run this, I get PHP has encountered an Access Violation at XXXXX.

I am running PHP 5.2.13 on a Windows Server, running IIS7 and MySQL 1.2.17.

The problem seems to occur only when I try to connect to the MySQL database.  The person I was working with, said it might be something with the php_mysql.dll.  But I tried putting an older version of the php_mysql.dll (from PHP v5.2.6) and it still didn't work.

I am in the process of setting up this new server so I just feel it must be something in the set up, permissions or something.  I just don't know what.

I don't know what would cause the PHP has encountered an Access Violation or how to fix this.

We also looked at the log files and he didn't see any error messages in there.

I have no problem allowing someone to look at the server (using remote access) if that would help, while we look at it together.

I just need help so I can get this running.

Please???  I hope someone can help fix this issue and provide the changes I need to make.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

This is what happens when you try to run IIS and PHP.

You're using PHP and mysql, why can't you use apache also?

Apache2Triad would solve all of your problems and make your life soooooo much easier. So unless you need IIS for exchange or ASP, go with apache.

Sorry, but I'd have to be looking at the computer to fix this issue.

Hopefully, someone else here has the experience to tell you over a short message with little information. : )

Best of luck, let me know if i can be of more help
njcuwebsupportAuthor Commented:
There was also another note I saw when I looked at EVENTS under Summary under Roles and Web Server (IIS) in the Server manager.

A process serving application pool '' suffered a fatal communication error with the Windows Process Activation Service. The process id was '4160'. The data field contains the error number.

I'm not sure if this information helps.

I need to run IIS and feel it should work fine.  I just need someone who knows IIS and PHP so they can help.

I appreciate your input, but hopefully someone knows PHP and IIS7 enough to help.

If you are very familiar with IIS7 and PHP (for windows) I'd be happy to let you look at the server.  But it sounds like you're more familiar with Apache .. correct?

Just for kicks, check your PATH environment variable to see if the MySQL entry is before the PHP entry. If so, try moving the PHP portion of the PATH in front of MySQL. PHP may be finding the libmySQL.dll in MySQL, rather than the libmysql.dll PHP uses, and getting all confused.

...;C:\PHP;"C:\Program Files\MySQL\MySQL Server 5.0\bin";... Your paths may differ slightly...
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

njcuwebsupportAuthor Commented:

No.  the path to PHP was already before the MySQL.


Any other thoughts?

Could you run phpinfo(); and include the MySQL portion of the output in a reply?
Is this a legacy application? Are you actually running MySQL 1.2.17, not a 4.x or 5.x version?
njcuwebsupportAuthor Commented:
MySQL Support enabled
Active Persistent Links  0  
Active Links  0  
Client API version  5.0.51a  

Directive Local Value Master Value
mysql.allow_persistent On On
mysql.connect_timeout 60 60
mysql.default_host no value no value
mysql.default_password no value no value
mysql.default_port no value no value
mysql.default_socket no value no value
mysql.default_user no value no value
mysql.max_links Unlimited Unlimited
mysql.max_persistent Unlimited Unlimited
mysql.trace_mode Off Off

How can I tell exactly what version of MySQL I am running.  (just to be sure)?  1.2.17 is what showed up in the MySQL Manager. So, maybe that is wrong.

Hi Gary,
According to the phpinfo, you've got MySQL Server 5.0.51a, so let's assume that's it.
I think the 1.2.17 is the MySQL Manager version (the GUI).
Anyhow, just to be sure...
Running MySQL in command-line mode should be enough.
 If you're not sure how to do this...
Bring up a command window and run mysql in command-line mode:
C:\> mysql -u username -p
(type your password)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.67-community-nt-log MySQL Community Edition (GPL)
If this does not tell you the Server version, use the status command at the mysql> prompt:
mysql> status;
(results show here)
mysql> exit

njcuwebsupportAuthor Commented:
5.1.44 is what comes up.  :-)
In your PHP folder (Usually C:\PHP), find and rename the libmysql.dll to some other name (say, libmysql-5.0.51a.dll , just to save it away...), then copy libmysql.dll from the MySQL bin folder (on MY machine it is C:\Program Files\MySQL\MySQL Server 5.0\bin ) into the PHP folder. Restart IIS.

njcuwebsupportAuthor Commented:
Can you explain what it is about this file that might be causing the problem?


(It worked when I replaced the file from the php folder into the windows\system32 folder)  Explain that one?  haha
Hi Gary,
PHP was most likely using the old one which was in Windows\System32 one all along. The PHP folder had the right file, but still used the System32 outdated file (%SystemRoot%\system32 comes before C:\PHP in your PATH, does it not?). If you compare the DLLs from the PHP folder and the MySQL\bin folder (and now Windows\System32), they're most likely identical. So it was only the Windows\System32 file that was the wrong version, I would suspect. What I cannot explain is why System32 had an outdated version.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
njcuwebsupportAuthor Commented:
Thank you.

Good job bud.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.