Jump to content

Newbie SQL/PHP linking question


jhenrichs

Recommended Posts

Hello,

 

I am VERY new to PHP but I am trying to teach myself it so excuse me if I don't make sense.  What I am trying to do at the moment, is to create a website with a log-on page, so to start out with, I setup WAMP on a Windows 7 machine, I have that up and going.  So my next step was logging into phpMyAdmin and creating a new database named "diode" I then proceeded to go under privlages and then created a username and password with all privlages for that database yet my php code can't access it, so I have no clue what I am doing wrong.  I will post my sql connection code below as well as the error message I am getting.

 

PHP Code

$connection = mysql_connect("127.0.0.1","username","password") OR die(mysql_error());

$db_select = mysql_select_db("diode",$connection) OR die(mysql_error());

 

Error Message

( ! ) Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user 'username'@'localhost' (using password: YES) in C:\wamp\www\index.php on line 3

Call Stack

# Time Memory Function Location

1 0.0019 684760 {main}( ) ..\index.php:0

2 0.0019 685048 mysql_connect ( ) ..\index.php:3

Access denied for user 'username'@'localhost' (using password: YES)

 

 

Any help at all would be greatly appreciated!

Link to comment
Share on other sites

You probably want to change "username" to root, and "password" to "" or NULL. Typical WAMP setup for the DB is root with no password. You can also change the IP to "localhost" but that shouldn't matter.

 

Edit: I see you say you set up a username and pass - Does the code actually have them or do you have what you've posted here? (Don't post your username and password here regardless :))

Link to comment
Share on other sites

ok, right now you are my hero!!  I did set it to root and null for the password and that made it work!  Granted I don't want to leave it at that because I would like it more secure, but I got the page to come up for once! 

 

But yes, my code does have the actual database username and password but permission wise I must still have something wrong but I can't find out what.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.