954,576 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to connect to mysql in wamp

<?php
$con = mysql_connect("localhost:3306","pm" ,"");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// some code
?>


on writing the above code it is showing the following error:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'pm'@'localhost' (using password: NO) in C:\wamp\www\p2.php on line 83
Could not connect: Access denied for user 'pm'@'localhost' (using password: NO)

how can i solve this error.

prateekm
Newbie Poster
2 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Is 'pm' an user? Try 'root' and no password (default settings).

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

<?php $con = mysql_connect("localhost:3306","pm" ,""); if (!$con) { die('Could not connect: ' . mysql_error()); }

// some code ?>

on writing the above code it is showing the following error:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'pm'@'localhost' (using password: NO) in C:\wamp\www\p2.php on line 83 Could not connect: Access denied for user 'pm'@'localhost' (using password: NO)

how can i solve this error.

Hello prateekm,

in WAMP, use this syntax for your connection establishment;

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


Hope it will help you...
Why you are writing port number with localhost? Also No username "pm" with password as "empty string" is registered.

emarshah
Junior Poster in Training
61 posts since Jan 2008
Reputation Points: 10
Solved Threads: 6
 
Is 'pm' an user? Try 'root' and no password (default settings).

thanks bro.....i got my mistake......its working with root and no password

prateekm
Newbie Poster
2 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You