Does a simple 'Hello World' work?
Echo "Hello, World!";
Can you connect to the DB manually? Could you show us the connect string you are using?
Create a page (info.php) and try this:
Should give you some info about your php install and your mysql install.
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.
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.
I thought of that, they are uncommented. If they weren't wouldn't I get an error when I call the method?
So when you run phpinfo, it tells you all is OK with mysql?
Is the error reporting switched on in the php.ini file. That way it might throw an error.
So this is all my php info lists for mysql
Version mysqlnd 5.0.7-dev - 091210 - $Revision: 294543 $
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?
This is what my error reporting was set to
error_reporting = E_ALL & ~E_DEPRECATED
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";
I get Unable to select database, however, if I run a mysql client with that exact information it connects fine. Any ideas?
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.
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
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