So, I just installed XAMPP on my PC running Windows 7. Here's what my website looks like:




function connect(){
$username = "dartz654";
$password = "letmein";
$hostname = "localhost";
$con = mysql_connect($hostname,$username,$password) or die ("Unable to connect");
mysql_select_db(database, $con);



    echo "<form method=\"post\">";
    echo "<input type=\"text\" name=\"username\">";
    echo "<input type=\"password\" name=\"password\">";
    echo "<input type=\"submit\" name=\"submit\" value=\"Register\">";
    echo "</form>";
}else {

$username = $_POST['username'];
$password = $_POST['password'];

$sql = "INSERT INTO `users` (`username`,`password`) VALUES ('".$username."','".$password."')";
$res = mysql_query($sql) or die(mysql_error());

echo "You've registered.";


When I hit 'register' on the register one, it'll show an error like this:

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\My\Register.php on line 15

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs\My\Register.php on line 15
Access denied for user 'ODBC'@'localhost' (using password: NO)

Help please?

P.S. If theres some error in my code, its probably just a mistake I made when cutting out code... The actual register is alot longer, I just took out the unimportant stuff. The real problem is the connection part...

In line 7 of /Functions.php in your post you put:

mysql_select_db(database, $con);

In this context the keyword database is neither a name or a variable. Perhaps you meant "database" or $database when you typed it?

In my connect function I use the name of my database there:


Yes, "database" is the name of the database. Do i have to put the ' around it?

Yes. If you don't put either single or double quotes around it PHP will treat it as a keyword/function and not as a name.

each in every page the connection must there.
example you create a connet.php containing
then include connect.php in every page.

if we look at table user :

 Select * From mysql.user;

nothing user with name 'ODBC'
but, default user to use ODBC.
i also don't know why ?

but, you can try to make user ODBC.
and then
try to given access table to user :

 grant all On [db].[tabelName] to [userName];


 grant all On mysql.* to root;
 grant all On mysql.* to ODBC;