Jump to content

What am I doing wrong?


bri4n

Recommended Posts

Hi everybody!

 

I am learning how to write a login page in PHP and when I go to login witht a mock username and password (which is stored in a MySQL db) I get the following:

 

Warning: mysql_connect(): Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Inetpub\vhosts\god-zone.org.nz\httpdocs\Login.php on line 13

Couldn't connect to server.

 

The db connection information is in an include file which is called by the Login.php page. Here is the include file:

 

<?php

$user="members";

$host="localhost";

$password="";

?>

 

and here is the Login.php portion:

 

session_start();

include("dogs.inc");

switch (@$_GET['do'])

{

case "login":

  $connection = mysql_connect($host,$username,$password)

or die ("Couldn't connect to server.");

$db = mysql_select_db($database, $connection)

or die("Couldn't select database");

 

As far as I can tell  haven't done anything wrong, but I just can't figure out why it doesn't work! Grrrrrrrrrrrrr >:(

 

I really appreciate any help in helping resolve this simple problem!  ;D

 

Thanx,

Brian :-)

Link to comment
Share on other sites

Warning: mysql_connect(): Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Inetpub\vhosts\god-zone.org.nz\httpdocs\Login.php on line 13

Couldn't connect to server.

 

 

It doesn't have anything to do with changing localhost to mysql...leave localhost as it is. You need to go into your database using the root username (with phpMyAdmin, etc.) and create a user, in this case ODBC and give it full rights to everything, then make a password for it. Its giving you that error because as of now, ODBC has no rights to even connect to the database.

Link to comment
Share on other sites

Hi Archadian!

 

That got it! I created a new user:ODBC and now it's functioning  :D. There was a user created previously by me: members. I was wondering if you could tell me how I could replace the user:ODBC with the user: members.

 

Thanx,

Brian :-)

Link to comment
Share on other sites

Hi Brian, I'm Brian :)

 

Sometimes it's the easiest things that are the hardest to spot..

 

In your include file, you set $user, but in Login.php you use $username.  That results in an empty username being passed, which somewhere gets changed to a default "ODBC" username.

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.