Jump to content

[SOLVED] mySql and php don't want to work together


andytymeiz

Recommended Posts

Tearing hair out, have apache 2.2.4, mySql 5.0 and php 5.2.3 installed, apache can find php but cannot find mySql, have been through the various topics on this site but to no avail. Firefox keeps loading blank pages, can't find a way round.

I am testing with:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>

<head>
  <title>My SQL connection test</title>
</head>
<body>
<h2>
    
    <?php
    $connection = mysql_connect( "localhost", "root", "" )
    or die( "sorry - unable to connect you to MySQL" );
    echo( "Congratulations - you connected to MySQL" );
    ?>

</h2>

</body>
</html>

I have configured php.ini correctly (I hope, attached), but still it goes belly up, any suggestions would be appreciated.

Many thanks,

Andy

 

[attachment deleted by admin]

Link to comment
Share on other sites

Your configuration appears to be fine. What is the file name this code is in? You must place PHP code within a .php file. You cannot place PHP code in .html files or any other file extension unless the server is configured to parse these files with PHP interpreter.

Link to comment
Share on other sites

<?php
    $connection = mysql_connect( "localhost", "root", "" )
    or die( "sorry - unable to connect you to MySQL\nError: " . mysql_error() );
    echo( "Congratulations - you connected to MySQL" );
?>

 

Try that; post any error resulting.

Link to comment
Share on other sites

Do you see a mysql heading/section when you run phpinfo() on its own:

<?php
phpinfo();
?>

 

If you can't find a mysql heading/section then check that PHP is reading the php.ini file you are editing. You can check this by searching for either Configuration File (php.ini) Path or Loaded Configuration File (when you have ran phpinfo function) and seeing what they are set to. If either of the paths stated is not correct then PHP is not reading your php.ini

Link to comment
Share on other sites

I have tried the code sent but blank page and no error message, running the php_info file returns the php data page showing config file path as c:\windows but the loaded config file in C:\PHP\php.ini so I guess the loaded file is incorrect, where do I change this parameter?

Thanks for your patience!

Link to comment
Share on other sites

Is your php.ini in C:\PHP? If so PHP is reading your php.ini

 

Also did you manage to find a MySQL section/heading when you ran phpinfo? You didn't reply when I asked you that question earlier. If you cannot find a MySQL section/heading then it looks like PHP is having trouble loading the mysql extension - even though you have enabled the extension in the php.in

 

If you answer Yes and No for the above questions then I may know what the problem could be.

 

 

Link to comment
Share on other sites

Running phpinfo gives me:

 

System Windows NT D3NN192J 5.1 build 2600

Build Date May 31 2007 09:36:39

Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared"

Server API Apache 2.0 Handler

Virtual Directory Support enabled

Configuration File (php.ini) Path C:\WINDOWS

Loaded Configuration File C:\PHP\php.ini

PHP API 20041225

PHP Extension 20060613

Zend Extension 220060519

Debug Build no

Thread Safety enabled

Zend Memory Manager enabled

IPv6 Support enabled

Registered PHP Streams php, file, data, http, ftp, compress.zlib

Registered Stream Socket Transports tcp, udp

Registered Stream Filters convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.*

 

So no mysql heading or section, I note that the config file path and the loaded config file are different, is this correct?

 

I appear to have more php.ini files than I need, one in windows and one in c:\PHP. If the one in PHP is deleted will it default to the one in windows?

 

Many thanks again - us beginners must be a pain!

 

Link to comment
Share on other sites

Only one path needs to be true. This one is duff:

Configuration File (php.ini) Path    C:\WINDOWS

 

However this one is correct:

Loaded Configuration File    C:\PHP\php.ini

 

When PHP reports C:\WINDOWS that means it cannot find a php.ini file. But on your setup PHP is reading the correct .ini file.

 

Ok what I need you to do now is to go into the php.ini and turn a setting called display_startup_errors on. By changing its default value from Off to On. Save the php.ini and restart Apache.

 

If PHP is having trouble loading extensions that you have uncommented in the php.ini it will notify you when Apache starts up again.

 

Can you post the error messages you get.

Link to comment
Share on other sites

Aha! Light at end of tunnel...

Error:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mysqltest.php on line 11

sorry - unable to connect you to MySQL Error: Access denied for user 'root'@'localhost' (using password: NO)

 

Is this just a password insertion required?

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.