Jump to content

[SOLVED] Can't connect in IIS


bryandc

Recommended Posts

Hi,

 

help!

 

I have PHP installed and works fine via localhost.

 

I have Mysql installed and have fill access and utility via the Mysql CLI.

 

However, when I attempt to use the code below to connect:

 

 

<?php

$location = "localhost";

$username = "administrator";

$password = "bc99mard";

$database = "bryan";

 

$conn = mysql_connect("$location","$username","$password");

if (!$conn) die ("Could not connect MySQL");

mysql_select_db($database,$conn) or die ("Could not open database");

 

?>

 

 

All i get is the pretties white screen.  No connection, no error, nada.

 

I tried setting up an ODBC to talk to mysql but there is no connection type for mysql.

 

When I use Mysql via the CLI it does ask for a password which is the same as my admin login password.  It never asks for a userid and I don't know what it see as a userid.  I suspect that therein lies my problem but I really don't know.  i have no issue with the DB itself as i have done many projects in Access, SQLserver, and to a lesser extent Oracle.

 

Is there a way to config MySql so that it doesn't require a userid, password?  if not what do you think it is using as a userid?

 

I am quite perplexed.

 

Thanks

Link to comment
Share on other sites

Open your php.ini file and turn display_errors on and make sure error_reporting is set to E_ALL

 

Save the php.ini and restart IIS.

 

Re-run your script. If there is any errors PHP finds they will now be displayed to the browser. Post all error messages you get here in full.

Link to comment
Share on other sites

I just don't get it.

 

I made the changes you suggested.  I do have one issue however.  I have 3 php.ini files and am not sure how I got 3. 

 

One is in c:\WINDOWS

 

One is in C:\Program Files

 

One is in C:WINDOWS\system32

 

I am not sure which one it talks to but I changed all 3 to be safe.

 

Here's the rub.  I do not get any errors.  I just get white screen.  i downloaded the Zend development tool and all works as should withing the tool.  I get my connectivity to MySql etc.

 

When I open the tested / debugged source code (believe me at this stage  is the simplest of code)  i get no output whatsoever.  Any HTML code will display proper results (i.e. a <p>content</p>).  The browser will display all PHP content properly as well but as soon as I add a connectvity string I getr no output.  All I see is white screen.  It seems as though there is a disjoint between PHP and MySql when I run as localhost and yet it has no issue in Zend.

 

I will perform whatever tests, actions, wrist slicing, that you may suggest.

Link to comment
Share on other sites

Only have one php.ini, delete all others. I would recommend you to keep the php.ini that is located in C:\WINDOWS

 

For turning a setting called display_errors to On in the php.ini you simply search for the following line:

; server, your database schema or other information.

Beneath that line will be the display_errors setting. change Off to On

 

Now change a setting called error_reporting (which is just a few lines above the setting your just changed) to E_ALL.

 

Now save the php.ini and restart IIS.

 

Re run your code and if there is any problems with the script PHP will display errors messages this time, these errors message will help debug your code. Post all error messages you get here

Link to comment
Share on other sites

I made the changes as suggested.

 

I now have only 1 php.ini that is sitting in C:\WINDOWS

 

I made the changes to the php.ini to turn on error reporting.

 

The rub is that I do not get any error.  I only get a pure white screen.

 

 

 

THIS IS A SAMPLE PHP PAGE THAT WORKS JUST FINE:

 

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

 

<body>

 

<?php

 

phpInfo();

 

?>

 

 

 

</body>

</html>

 

 

THIS IS MY CONNECT TEST.  THIS PRODUCES NOTHING BUT WHITE SCREEN.  THIS SAME FILE IN ZEND CONNECTS PERFECTLY.

 

 

<?php

 

$dbcnx = @mysql_connect('localhost', 'root', 'bc99mard');

if (!$dbcnx) {

 exit('<p>Unable to connect to the ' .

     'database server at this time.</p>');

}

 

echo 'Connected successfully';

 

mysql_close($link);

 

?>

 

 

I am mystified and stupified.

 

I am attaching my php.ini file

 

I am attaching a screenshot of my phpInfo() screen.

 

 

The user named Kung says he solved it but he posted no solution.

 

 

 

 

 

 

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

Remove the @ from in front of mysql_connect. The @ suppresses errors so if have that in front of a line/function call then any errors returned will be ignored.

 

Also when you make any changes to server configuration files, you must restart the server.

Link to comment
Share on other sites

Aha progress.  perhaps this message is telltale.

 

Fatal error: Call to undefined function mysql_connect() in C:\Inetpub\wwwroot\PHP\connect1.php on line 3

 

 

This is launching thru localhost so I don't get the reference to C:\Inetpub...  seems like it should say /localhost

Link to comment
Share on other sites

The mysql extension hasn't been enabled or PHP is having issues loading the extension.

 

I see in your php.ini you have set up the extension_dir to point to PHP's extension folder which is correct and that you have enabled the mysql extension line in the php.ini

 

Those are correct steps to take for enabling the mysql extension.

 

There is an external library called libmysql.dll in order for the mysql extension to function correctly. Where is the location of this file?

 

 

 

Link to comment
Share on other sites

I actually have 10 such files in:

 

c:\WINDOWS 

c:\downloads\php  (my own folder)

c:\mysql\bin      *

c:\WINDOWS\system32

c:\mysql\lib\debug  *

c:\mysql\lib\opt  *

c:\Program Files\MySQL\MYSQL Server 5.0\bin    *

c:\Program Files\MySQL\MYSQL Server 5.0\debug

c:\Program Files\MySQL\MYSQL Server 5.0\opt

c:\Program Files\Zend\ZendStudio-5.5.0\bin\php5

 

 

The ones above marked with an * are identified as libmySQL as opposed to libmysql

 

 

 

 

 

Link to comment
Share on other sites

I don't think it was exectly the same problem. FYI - once I checked the log files I had infact connected and disconnected from MySQL. Hence my embarressment. Of course there was no output, I had not scripted any output beyond the back end stuff. Sorry if that wasnt any help to you

Link to comment
Share on other sites

I have just re-read the whole thread and I have gotten a little confused my self and I noticed I have missed out a few important bits.

 

Have you uncommented the mysql extension line in the php.ini?

 

Change this line:

;extension=php_mysql.dll

to

extension=php_mysql.dll

 

also ensure that you have set the extension_dir directive to point to your PHP extension folder, I believe its C:\downloads\PHP\ext

 

So make sure you set extension_dir line like this:

extension_dir = "C:\downloads\PHP\ext"

 

Save any changes you make to the php.ini and restart IIS

Link to comment
Share on other sites

I think you can check this one as solved.

 

The problem appeasrs to have been this line:

 

extension_dir = "C:\downloads\PHP\ext"

 

I had the ext mapped as C:\PHP\ext

 

As soon as I added downloads to the map it connected and I have run many test reads on DB and tables.

 

Thanks so much for the help.

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.