hi someone help me with this error:(
Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\CDX\class_lib.php on line 57
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs\CDX\class_lib.php on line 57
<?php
class contactdirectory{
private $db_host = 'localhost'; // Database Host
private $db_user = 'root'; // Username
private $db_pass = 'root'; // Password
private $db_name = 'contactdirectory'; // Database
private $con = false; // Checks to see if the connection is active
private $result = array(); // Results that are returned from the query
/*
* Connects to the database, only one connection allowed
*/
public function connect()
{
if(!$this->con)
{
$myconn = @mysql_connect($this->db_host,$this->db_user,$this->db_pass);
if($myconn)
{
$seldb = @mysql_select_db($this->db_name,$myconn);
if($seldb)
{
$this->con = true;
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return true;
}
}
function form(){
echo "<form name=contact method=post action=index.php>";
echo "Name:"."<input type=text name=name /><br />";
echo "Address:"."<input type=text name=address /><br />";
echo "Email"."<input type=text name=email /><br />";
echo "Tel No:"."<input type=text name=tel /><br />";
echo "Mobile No:"."<input type=text name=mobile /><br />";
echo "<input type=submit name=add value=Add />";
echo "</form>";
}
function add($name,$address,$email,$tel,$mobile){
$query = "INSERT INTO contact VALUES(0, '$name','$address','$email','$tel','$mobile')";
mysql_query($query);//<<-------line 57
$directory = new contactdirectory();
$directory -> form();
}
function select($idno){
$query = "SELECT * FROM contact WHERE idno=$idno";
$rs = mysql_query($query);
if(mysql_num_rows($rs) > 0) {
while($row = mysql_fetch_assoc($rs)){
?>
<form name="contact" action="index.php" method="post">
<table border=1>";
<tr>";
<td width=150><?php echo $row[name] ?></td>";
<td width=150><?php echo $row[address] ?></td>";
<td width=150><?php echo $row[email] ?></td>";
<td width=150><?php echo $row[tel] ?></td>";
<td width=150><?php echo $row[mobile] ?></td>";
<td width=150><form name=name1 action=index.php method=post>
<input type=hidden name=idno value=$row[idno] />
<input type=submit name=edit value=Edit />";
<input type=submit name=delete value=Delete /></form></td>";
</tr>";
</table>";
</form>
<?php
}
}
}
function delete($idno){
$query="DELETE FROM contact WHERE idno=$idno";
mysql_query($query);
$directory = new contactdirectory();
$directory -> form();
}
function edit($idno){
$query = "SELECT * FROM contact WHERE idno=$idno";
$rs = mysql_query($query) or die (mysql_error());
if(mysql_num_rows($rs) > 0) {
while($row = mysql_fetch_assoc($rs)){
?>
<form name="contact" action="index.php" method="post">
Name:<input type="text" name="name1" value="<?php echo $row[name] ?>" /><br />
Address:<input type="text" name="address1" value="<?php echo $row[address] ?>" /><br />
Email:<input type="text" name="email1" value="<?php echo $row[email] ?>" /><br />
Tel No:<input type="text" name="tel1" value="<?php echo $row[tel] ?>" /><br />
Mobile No:<input type="text" name="mobile1" value="<?php echo $row[mobile] ?>" /><br />
<input type="hidden" name="idno" value="<?php echo $row[idno] ?>" />
<input type="submit" name="update" value="Update" />
</form>
<?php
}
}
}
function update(){
$query="UPDATE contact SET name='$_POST[name1]', address='$_POST[address1]', email='$_POST[email1]', tel='$_POST[tel1]', mobile='$_POST[mobile1]' WHERE idno='$_POST[idno]'";
$rs=mysql_query($query) or die ('Update info error!' . mysql_error());
$directory = new contactdirectory();
$directory -> form();
}
}
?>
tnx.