Jump to content

PHP files with mysql code are causing apache to close


TCool

Recommended Posts

Hi, I did some searching on the forums but couldn't find anything similar to my situation.  I apologize if there is information already about this and I just missed it.

 

Anyway, I recently downloaded apache 2.29, mysql 5.1.25 and php 5.2.6.  I used the installer for all of the applications.  I was able to get the php working with apache, and mysql support enabled.  I verified that mysql was working by creating a database through the command line.  The problem I'm having now is that I made a page to test to see if everything was working with mysql.

 

The code looks like:

 

<?php

# Define MySQL Settings
define("MYSQL_HOST", "localhost");
define("MYSQL_USER", "root");
define("MYSQL_PASS", "tim");
define("MYSQL_DB", "test");

$conn = mysql_connect("".MYSQL_HOST."", "".MYSQL_USER."", "".MYSQL_PASS."") or die(mysql_error());
mysql_select_db("".MYSQL_DB."",$conn) or die(mysql_error());

$sql = "SELECT * FROM test";
$res = mysql_query($sql);

while ($field = mysql_fetch_array($res))
{
$id = $field['id'];
$name = $field['name'];

echo 'ID: ' . $field['id'] . '<br />';
echo 'Name: ' . $field['name'] . '<br /><br />';
}

?> 

 

Now anytime I try to load that page I get an error from windows saying apache has to close, and then after this happens apache will not work at all no matter how many times I try to restart the service. 

 

I've gone through all the steps (as far as I know) to add the mysql extension to php, and properly configure all the files but nothing seems to work.  I've reinstalled all the programs many times, but that isn't working either.

 

Does anyone have any idea what is wrong here and how I can fix it?  If you need any more information from me just let me know.

 

Thanks in advance for your help!

 

Tim

Link to comment
Share on other sites

Check the Apache error log for information about what might be happening and since this is affecting Windows, check the Windows event log too.

 

Everyone who has used the the php .msi installer has had problems. I (and everyone else on this forum) recommend using the php .zip package.

Link to comment
Share on other sites

Thanks for the reply!

 

As I went to bed last night I was thinking about it.  I tried multiple times to install it using multiple different guides.  One guide told me to put the libmysql.dll file in the system32 folder and another told me to put it into the windows folder.  I'm guessing some how these were conflicting with one another because I forgot to delete it from the system32 folder after that attempt, but after I just deleted it today everything is working.  :)

 

 

Link to comment
Share on other sites

Try not to move any files outside of the PHP Installation folder. Keep all files that come with PHP within the installtion folder. You should add the PHP installation folder to the PATH Environment Variable instead.

 

Moving files can cause problems when you go to upgrade PHP later on. upon uninstallation, PHP will not automatically remove files you have moved.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.