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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kma
Forum Newbie
Posts: 1
Joined: Fri May 14, 2010 11:05 pm

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

Post 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();

?>
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post by requinix »

You're mixing mysqli_connect with mysql_query. MySQLi and MySQL. Can't do that.

Pick one and go with it.
Post Reply