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

<?php
        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);
            if(!$meta){
                echo"no information available<br />\n";
            }
            echo "<pre>
                example 1:    $meta
                example 2:    $meta
            </pre>";
            $i++;
        }
        ?>

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.

Recommended Answers

All 4 Replies

problem is in dbfucntions.php, post it here

<?php
$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']));
    while($row=mysqli_fetch_array($result))
    {
        $returnArray[] = $row;
    }
    return $returnArray;
}
function executeInsertQuery($query)
{
    return mysqli_query($GLOBALS['link'], $query) or die(mysqli_error($GLOBALS['link']));
}

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.