0

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.

Edited by Dani: Formatting fixed

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Jiaxin
0
<?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']));
}

Edited by Dani: Formatting fixed

0

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

0

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.