Page 1 of 1

i mgetting errors

Posted: Wed Jul 08, 2009 2:47 am
by mayanktalwar1988
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\oo\add_topic.php on line 9
cannot connect



<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="ask"; // Database name
$tbl_name="forum_question"; // Table name

// Connect to server and select database.
mysql_connect("$host","$username","$password") or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// get data that sent from form
$topic=$_POST['topic'];
$detail=$_POST['detail'];
$name=$_POST['name'];
$email=$_POST['email'];

$datetime=date("d/m/y h:i:s"); //create date time

$sql="INSERT INTO $tbl_name(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')";
$result=mysql_query($sql);

if($result){
echo "Successful<BR>";
echo "<a href=main_forum.php>View your topic</a>";
}
else {
echo "ERROR";
}
mysql_close();
?>

Re: i mgetting errors

Posted: Wed Jul 08, 2009 2:51 am
by SvanteH
I'm going to go on an edge here and guess that you've entered a wrong username/password for mysql.

Re: i mgetting errors

Posted: Wed Jul 08, 2009 5:12 am
by iamngk
i hope you are using xampp by default mysql username will be root..

$username="root";// Mysql username
$password=""; // Mysql password


and then try....

Re: i mgetting errors

Posted: Wed Jul 08, 2009 6:26 am
by mayanktalwar1988
yes thanks ...i changed the username to root ...now it is working..thanks :D