I want know the reason why this code is not running ?
My Wampserver IP address is 127.0.0.1:8080 or localhost:8080 !
The username is the default "root", but I changed my password to "abcd" !

<?php

/**
 * @author 
 * @copyright 2011
 */

   $con = mysql_connect('127.0.0.1:8080','root','abcd');
   if (!$con) {
    die('Could not connect: ' .mysql_error());
   }
?>

Errors when the file is run !!! :O

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

Warning: mysql_connect() [function.mysql-connect]: Error while reading greeting packet. PID=7828 in C:\wamp\www\PHPgiri\4.php on line 8

Warning: mysql_connect() [function.mysql-connect]: MySQL server has gone away in C:\wamp\www\PHPgiri\4.php on line 8
Could not connect: MySQL server has gone away

Please help !

Mysql usually runs on port 3306, not on 8080.

Actually I have IIS installed on my system which is the localhost.
I have set Wampserver to function from port 8080.
Please tell can I access port 3306 from there ???

If you set wampserver to 8080, that means that apache will run on 8080. Unless you changed something mysql will be accessible on the default port 3306. So just remove the :8080 from your host in the mysql_connect.

when i used this i got this message when i run the page ,"Could not connect: No connection could be made because the target machine actively refused it. " can anyone help

leave out the port number if you have not messed up with MySQL installation

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.