Hello, I am trying this code out but has error. Please help,
This is my code.

        include 'dbFunctions.php';

        $result = mysql_query('select * from criteria_m');
        if (!$result){
            die('Query failed: ' . mysql_error());

        $i = 0;
        while ($i < mysql_num_fields($result)){
            echo"information for column $i:<br />\n";
            $meta = mysql_fetch_field($result, $i);
                echo"no information available<br />\n";
            echo "<pre>
                example 1:    $meta
                example 2:    $meta

The error message i got is this,

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

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

Thank you.

Edited by Dani: Formatting fixed

6 Years
Discussion Span
Last Post by Jiaxin
$HOST = 'localhost';
$USERNAME = 'root';//letter s followed by your student ID
$PASSWORD = '';//password you used to login
$DB = 'fyp';

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

function executeSelectQuery($query)
    $result = mysqli_query($GLOBALS['link'], $query) or die(mysqli_error($GLOBALS['link']));
        $returnArray[] = $row;
    return $returnArray;
function executeInsertQuery($query)
    return mysqli_query($GLOBALS['link'], $query) or die(mysqli_error($GLOBALS['link']));

Edited by Dani: Formatting fixed


are you sure you can login to phpmyadmin without password. I think in your main code file you must user mysqli_query instead of mysql_query, for that matter all function you must change.

Edited by urtrivedi: n/a


Yes, this was done last time during school work. It works with other things. I used the exact same one for something else too, but didnt have any error. The problem shouldn't lies there.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.