So I am just learning PHP today and I have it installed and running on my IIS 7.5 server. I tested with a 'phpinfo();' statement and it is working fine.
Now I am trying to connect to a MySQL database. I am following this guide: www. freewebmasterhelp. com/tutorials/phpmysql/4
The problem seems to be with a 'hang' when my script tries to connect to the DB server. I am using some echo statements to try and pin point the issue and have it down to this one line:
<p><?php
echo "Start<br>";
//phpinfo();
$username='noSuch';
$password='fake';
$database='NONE';
echo "1: Attempting MySQL Connection<br>";
mysql_connect(localhost,$username,$password) or die("Unable to connect to localhost");
echo "2: Connected<br>";
- <p><?php
- echo "Start<br>";
- //phpinfo();
- $username='noSuch';
- $password='fake';
- $database='NONE';
- echo "1: Attempting MySQL Connection<br>";
- mysql_connect(localhost,$username,$password) or die("Unable to connect to localhost");
- echo "2: Connected<br>";
I browse to my file with my internet browser:
http://localhost/Test_1.phpAnd I see '1: Attempting MySQL Connection', but nothing else. So... It seems to be stuck trying to connect... I triple checked the $username and $password that I entered earlier in the script so I know those are ok. I just don't understand why it won't give me one of the 2 messages:
2: Connected
OR
Unable to connect to localhost
But I don't see either message... How is this possible?
EDIT:
I tried setting my variables to random values that should not possibly work and I still have the exact same issue... It's hanging, not printing any messages at all.
nicolai. is-a-geek .com/Test_1.php
On another note, if I upload my 'Test_1.php' to my managed web host at geekisp .com and run the page, the page takes a minute to load and then DOES print out:
Unable to connect to localhost
I tried changing the 'localhost' in the connection:
mysql_connect('nicolai. is-a-geek .com:3306',$username,$password) or die("Unable to connect to localhost");
But still no luck...
I know geekisp offers MySQL, but for this particular table, I need it working locally...