how to connect to mysql in wamp

Reply

Join Date: Jul 2009
Posts: 2
Reputation: prateekm is an unknown quantity at this point 
Solved Threads: 0
prateekm prateekm is offline Offline
Newbie Poster

how to connect to mysql in wamp

 
0
  #1
Jul 11th, 2009
  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 4:19 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1,514
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 194
Sponsor
ardav's Avatar
ardav ardav is offline Offline
Anthrax Poster

Re: how to connect to mysql in wamp

 
0
  #2
Jul 11th, 2009
Is 'pm' an user? Try 'root' and no password (default settings).
Twpsyn cythraul. Cawr y dom tarw. Gwybod dim, gofyn dim.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 57
Reputation: emarshah is an unknown quantity at this point 
Solved Threads: 5
emarshah emarshah is offline Offline
Junior Poster in Training

Re: how to connect to mysql in wamp

 
0
  #3
Jul 11th, 2009
Originally Posted by prateekm View Post
<?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;
  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.
Syed Ammar Hassan
" A man is known by his level of Determinism "
--------------------------------------------------------
"Some cause happiness where ever they go, others whenever They go"
--------------------------XIII---------------------------
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 2
Reputation: prateekm is an unknown quantity at this point 
Solved Threads: 0
prateekm prateekm is offline Offline
Newbie Poster

Re: how to connect to mysql in wamp

 
0
  #4
Jul 12th, 2009
Originally Posted by ardav View Post
Is 'pm' an user? Try 'root' and no password (default settings).
thanks bro.....i got my mistake......its working with root and no password
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 2186 | Replies: 3
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC