tags:

views:

896

answers:

4

This might be ridiculously easy for you but I've been struggling with this for an hour... :(

<?php
$connect = mysql_connect("localhost:8080", "root", "mypassword");
echo($connect);?>

This is the code that I'm trying to run - you can see that I'm using 8080 as my port number and, of course, I have html codes as well.

However, it gives me the following error messages whenever I try to open the PHP file:

====================================================================================

Warning: mysql_connect() [function.mysql-connect]: MySQL server has gone away in C:\wamp\www\php_sandbox\index.php on line 2

Warning: mysql_connect() [function.mysql-connect]: Error while reading greeting packet. PID=4932 in C:\wamp\www\php_sandbox\index.php on line 2

Warning: mysql_connect() [function.mysql-connect]: MySQL server has gone away in C:\wamp\www\php_sandbox\index.php on line 2

=====================================================================================

I don't know... what's wrong with this? Is it because of the port number?

+5  A: 

Change localhost:8080 to localhost:3306.

JonnyLitt
Oh my god, how stupid I am... I thought that port-number belong to MySQL :S Thank you very much!!!
Phrixus
It can be confusing since they don't tell you upon installation. If you want to put it out on the internet make sure you have a password for root since WAMP does not include one automatically. Cheers mate.
JonnyLitt
+4  A: 

Try opening Port 3306, and using that in the connection string not 8080.

Kevin
Oh my god, how stupid I am... I thought that port-number belong to MySQL :S Thank you very much!!!
Phrixus
@Phrixus see http://www.iana.org/assignments/port-numbers for port numbers
Chris
A: 

hey i got this

Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:8080) in C:\wamp\www\mytest\db.php on line 2

Warning: mysql_connect() [function.mysql-connect]: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\wamp\www\mytest\db.php on line 2

Fatal error: Maximum execution time of 60 seconds exceeded in C:\wamp\www\mytest\db.php on line 2

Rupesh
A: 

Just Change the Connection mysql string to 127.0.0.1 and it will work

Snehasis Mohapatra