Page 1 of 1

need help on PHP!!! Keep Coming out errors....

Posted: Fri May 14, 2010 11:07 pm
by kma
I am doing for system administrator.I wanted to retrieve data from the database but keep coming out this error

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

can someone pls help???

this is the code i type for my webpage.Thks alot :D

<?php
session_start();
include 'ui.control.php';

head('Assign Course To Course Administrator');
box();
nav();

//connect to database
$HOST = 'localhost';
$USERNAME = 'root';
$PASSWORD = '';
$DB = 'sjas';

$link = mysqli_connect($HOST,$USERNAME,$PASSWORD,$DB);

$query = "SELECT idmember,name,role FROM member";


$result = mysql_query($query) or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>Name</th> <th>Age</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array($result))
{
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['id'];
echo "</td><td>";
echo $row['name'];
echo "</td></tr>";
echo $row['role'];
echo "</td></tr>";
}

echo "</table>";
?>






footer();

?>

Re: need help on PHP!!! Keep Coming out errors....

Posted: Sat May 15, 2010 2:58 am
by requinix
You're mixing mysqli_connect with mysql_query. MySQLi and MySQL. Can't do that.

Pick one and go with it.