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
https://forums.phpfreaks.com/topic/39983-what-am-i-doing-wrong/
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
https://forums.phpfreaks.com/topic/39983-what-am-i-doing-wrong/#findComment-193372
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
https://forums.phpfreaks.com/topic/39983-what-am-i-doing-wrong/#findComment-193438
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.