homepage Welcome to WebmasterWorld Guest from 54.145.183.169
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
PHP isn't working
andrewsmd

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4161671 posted 10:15 pm on Jun 29, 2010 (gmt 0)

I wasn't for sure if this should go here or on the php forum. I am running win2k8 iis7 and installed the latest version of php. I also have Mysql installed. Whenever I try to call the mysql_connect function, my page just continues to load but never finishes. I have no idea why and can't really figure out how to troubleshoot this since the page never loads. Any ideas? Thanks,

 

marcel

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4161671 posted 11:39 am on Jun 30, 2010 (gmt 0)

PHP isn't working

Does a simple 'Hello World' work?
<?php
Echo "Hello, World!";
?>


Can you connect to the DB manually? Could you show us the connect string you are using?

IntegrityWebDev

5+ Year Member



 
Msg#: 4161671 posted 1:51 pm on Jun 30, 2010 (gmt 0)

Create a page (info.php) and try this:

<?php
phpinfo();
?>


Should give you some info about your php install and your mysql install.

andrewsmd

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4161671 posted 2:27 pm on Jun 30, 2010 (gmt 0)

I should have been more specific. I can run PHP, I even ran a script that uses curl. As soon as I put a mysql_connect("blah"...);
command in, then the page just loads like it is in a redirect loop.

Red_Eye

10+ Year Member



 
Msg#: 4161671 posted 2:31 pm on Jun 30, 2010 (gmt 0)

With PHP 5 the MYSQL functions are now an extension and I think that normally you need to uncomment the extensions you want to use in the PHP.ini file.

andrewsmd

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4161671 posted 2:39 pm on Jun 30, 2010 (gmt 0)

I thought of that, they are uncommented. If they weren't wouldn't I get an error when I call the method?

IntegrityWebDev

5+ Year Member



 
Msg#: 4161671 posted 3:00 pm on Jun 30, 2010 (gmt 0)

So when you run phpinfo, it tells you all is OK with mysql?

Red_Eye

10+ Year Member



 
Msg#: 4161671 posted 3:01 pm on Jun 30, 2010 (gmt 0)

Is the error reporting switched on in the php.ini file. That way it might throw an error.

andrewsmd

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4161671 posted 3:17 pm on Jun 30, 2010 (gmt 0)

So this is all my php info lists for mysql

mysqlnd
mysqlnd enabled
Version mysqlnd 5.0.7-dev - 091210 - $Revision: 294543 $
Compression supported
Command buffer size 4096
Read buffer size 32768
Read timeout 31536000
Collecting statistics Yes
Collecting memory statistics No

Also, my curl script is not working now. It was working fine yesterday, and I had not changed the file at all, and now it is saying call to undefined function curl_init(); I see they are enabled in the ini file, but curl does not even show up in the phpinfo anywhere. I will enable error reporting. Should I just uninstall and re-install?

andrewsmd

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4161671 posted 3:19 pm on Jun 30, 2010 (gmt 0)

This is what my error reporting was set to
error_reporting = E_ALL & ~E_DEPRECATED

andrewsmd

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4161671 posted 3:49 pm on Jun 30, 2010 (gmt 0)

So I just uninstalled and re-installed. Curl is working again, but the mysql is not. After letting the page run for a while with this code mysql_connect("localhost","user","pass");
@mysql_select_db("db") or die( "Unable to select database");
$query="SELECT * FROM contacts";
$result=mysql_query($query);
var_dump($result);
mysql_close();

I get Unable to select database, however, if I run a mysql client with that exact information it connects fine. Any ideas?

andrewsmd

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4161671 posted 4:49 pm on Jun 30, 2010 (gmt 0)

Ok, finally figured it out. After just trying a mysql_connect(blah...) or die(mysql_error()); I got that it couldn't connect to the host. I was using localhost. Apparently php couldn't resolve localhost to 127.0.0.1. Put in 127.0.0.1 and it works. I'm sure there's some setting in PHP to fix this, or possibly changing my hosts file. But it's working! Thanks for everyone's help.

Anyango

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4161671 posted 9:28 am on Sep 30, 2010 (gmt 0)

Its an old topic, and im sure im late to be of any help for andrewsmd but i just came across this post and i know why it happens, so posting just in case anyone else needs to figure out why this happens.

In the latest versions of windows which mostly support IPV6 too, localhost doesnt exactly always map to 127.0.0.1 and hence when your script calls mysql_connect to localhost it cant connect. If you go to your HOSTS file you will see an entry like this

#127.0.0.1 localhost

You have to uncomment it, for it to be able to successfuly resolve localhost to that. It surely does happen on my win7 ultimate

Hope this helps anyone who is trying everything to figure out why their code or phpmyadmin cant connnect to mysql on their new windows

Cheers

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved