Welcome to WebmasterWorld Guest from 54.196.238.210

Forum Moderators: ocean10000

Message Too Old, No Replies

PHP isn't working

     

andrewsmd

10:15 pm on Jun 29, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



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

11:39 am on Jun 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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

1:51 pm on Jun 30, 2010 (gmt 0)

5+ Year Member



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

<?php
phpinfo();
?>


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

andrewsmd

2:27 pm on Jun 30, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



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

2:31 pm on Jun 30, 2010 (gmt 0)

10+ Year Member



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

2:39 pm on Jun 30, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



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

IntegrityWebDev

3:00 pm on Jun 30, 2010 (gmt 0)

5+ Year Member



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

Red_Eye

3:01 pm on Jun 30, 2010 (gmt 0)

10+ Year Member



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

andrewsmd

3:17 pm on Jun 30, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



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

3:19 pm on Jun 30, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



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

andrewsmd

3:49 pm on Jun 30, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



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

4:49 pm on Jun 30, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



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

9:28 am on Sep 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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
 

Featured Threads

Hot Threads This Week

Hot Threads This Month