Hi All,

I am new to PHP and MYSQL. I installed Apache2.2, MySQL Server 7.0 and PHP 5.2.10.

I created database and table in MYSQL - its working fine.

PHPINFO() - its working fine.

When i tried to connect to my MYSQL using PHP with the following code, i am not getting any error or the die message.

<?php
echo "connecting...<br><br>";
$dbhandle = mysql_connect("localhost","root@localhost","logu") 
or die("Could not connect"); 
echo "Connected to MySQL<br>";
?>

I tried with "root", "root@localhost", "logu", "logu@localhost" for username but nothing works.

It displays only the message 'Connecting...'

The details are in the attachment, it will be of great help if any one helps at an earliest.

Thanks in Advance,
Logu.

Recommended Answers

All 4 Replies

Read the documentation for mysql_connect again. It's mysql_connect('host', 'user', 'password') . You have mysql_connect('host', 'user@host', 'password')

Thanks for your reply.

I mentioned that already i tried with "root", "root@localhost", "logu", "logu@localhost" for username but nothing works.

Thanks,
Logu.

Hi,
Do check with the following code for connection

$dbhandle = mysql_connect("localhost","root","");

// because the default password is empty string

It will show connecting because you haven't written the exact code you should do like following;

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
else
  echo "connecting....";

Hi,

Even this is doing the same function. Can you please look in to the phpinfo() and mysql info in the attachment of my #1 mail.


Thanks,
Logu.

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.