943,948 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 9083
  • PHP RSS
Jul 11th, 2009
0

how to connect to mysql in wamp

Expand Post »
php Syntax (Toggle Plain Text)
  1. <?php
  2. $con = mysql_connect("localhost:3306","pm" ,"");
  3. if (!$con)
  4. {
  5. die('Could not connect: ' . mysql_error());
  6. }
  7.  
  8. // some code
  9. ?>

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.
Last edited by peter_budo; Jul 12th, 2009 at 5:19 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
prateekm is offline Offline
2 posts
since Jul 2009
Jul 11th, 2009
0

Re: how to connect to mysql in wamp

Is 'pm' an user? Try 'root' and no password (default settings).
Sponsor
Featured Poster
Reputation Points: 1048
Solved Threads: 949
Sarcastic Poster
ardav is offline Offline
6,698 posts
since Oct 2006
Jul 11th, 2009
0

Re: how to connect to mysql in wamp

Click to Expand / Collapse  Quote originally posted by prateekm ...
<?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;
php Syntax (Toggle Plain Text)
  1. $con = mysql_connect("localhost","root" ,"");
  2. if (!$con)
  3. {
  4. die('Could not connect: ' . mysql_error());
  5. }

Hope it will help you...
Why you are writing port number with localhost? Also No username "pm" with password as "empty string" is registered.
Reputation Points: 10
Solved Threads: 6
Junior Poster in Training
emarshah is offline Offline
61 posts
since Jan 2008
Jul 12th, 2009
0

Re: how to connect to mysql in wamp

Click to Expand / Collapse  Quote originally posted by ardav ...
Is 'pm' an user? Try 'root' and no password (default settings).
thanks bro.....i got my mistake......its working with root and no password
Reputation Points: 10
Solved Threads: 0
Newbie Poster
prateekm is offline Offline
2 posts
since Jul 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Friends list
Next Thread in PHP Forum Timeline: use singlw query to insert record in diff tables





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC