Hi there,

I am new to Php and MySql.

However, i have been learning for some time now.

I get the above error and my line 77 has the following statement:
$result=mysql_query($query,$conn);

Any ideas? If you need more of the code please let me know.

Thanks a lot,

Sofia

You have an error in your query. It isn't returning a valid resource. Print out $query, execute it in phpmyadmin/mysql. Then you ll know what's the error. You can also give die(mysql_error());
ie., $result=mysql_query($query,$conn) or die(mysql_error());

You have an error in your query. It isn't returning a valid resource. Print out $query, execute it in phpmyadmin/mysql. Then you ll know what's the error. You can also give die(mysql_error());
ie., $result=mysql_query($query,$conn) or die(mysql_error());

Hi, I have found that error now. i called the $conn in the included file $connection.

I feel rather daft now, but at least i have a different error to play with now :o)

Thanks for the rapid response

:) You are welcome!

Hi nav33n,

coul you please help me.. im trying to display quiz questions from database but i get an the same error as desribed above . please see my code

the error points to line 3 and 7.

1 <?php


2 include("contentdb.php");


3 $display = mysql_query("SELECT * FROM $table ORDER BY id",$db);


4 if (!$submit) {



echo "<form method=post action=$PHP_SELF>";
echo "<table border=0>";


7 while ($row = mysql_fetch_array($display)) {

Please please please... i desperately need your help.

Thank in advance

3 $display = mysql_query("SELECT * FROM $table ORDER BY id",$db);

Select * from $table ? What does $table have ? It must be empty.

my table is defined in config. file

<?
$database = "quiz";
$hostname = "localhost";
$table = "quiz";
?>
as you see table is called quiz and it has data in it.

Shall I recall
$display = mysql_query("SELECT * FROM $table ORDER BY id",$db);

to

$display = mysql_query("SELECT * FROM $quiz ORDER BY id",$db); ???

thanks

Nope. Just print out the query. ie., instead of

$display = mysql_query("SELECT * FROM $table ORDER BY id",$db);

do,

$query="SELECT * FROM $table ORDER BY id";
echo $query;
$display = mysql_query($query,$db);

Execute your query in phpmyadmin/mysql console and see what's the problem. Or, you can also try putting die statement after mysql_query to see the error.

$display = mysql_query($query,$db) or die(mysql_error());

i have an error hen i use die mysql_query()

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in E:\wamp\www\weberp\includes\Config.php on line 8

and when i dont us mysql_error() yhen error is

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in E:\wamp\www\weberp\includes\Config.php on line 8

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in E:\wamp\www\weberp\includes\Config.php on line 10

Fatal error: Call to undefined function DB_free_result() in E:\wamp\www\weberp\includes\Config.php on line 20

my code is

if(isset($ForceConfigReload) and $ForceConfigReload==TRUE OR !isset($_SESSION['CompanyDefaultsLoaded'])) {
    $sql = "SELECT confname, confvalue FROM config"; // dont care about the order by
    echo $sql;
    $ConfigResult =mysql_query($sql,$db) ;
 echo $ConfigResult;
    while( $myrow = mysql_fetch_row($ConfigResult)) {
        if (is_numeric($myrow[1]) and $myrow[0]!='DefaultPriceList'){
            //the variable name is given by $myrow[0]
            $_SESSION[$myrow[0]] = (double) $myrow[1];
        } else {
            $_SESSION[$myrow[0]] =  $myrow[1];
        }

    } //end loop through all config variables
    $_SESSION['CompanyDefaultsLoaded'] = true;
    DB_free_result($ConfigResult);

i have an error hen i use die mysql_query()

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in E:\wamp\www\weberp\includes\Config.php on line 8

and when i dont us mysql_error() yhen error is

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in E:\wamp\www\weberp\includes\Config.php on line 8

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in E:\wamp\www\weberp\includes\Config.php on line 10

Fatal error: Call to undefined function DB_free_result() in E:\wamp\www\weberp\includes\Config.php on line 20

my code is

if(isset($ForceConfigReload) and $ForceConfigReload==TRUE OR !isset($_SESSION['CompanyDefaultsLoaded'])) {
    $sql = "SELECT confname, confvalue FROM config"; // dont care about the order by
    echo $sql;
    $ConfigResult =mysql_query($sql,$db) ;
 echo $ConfigResult;
    while( $myrow = mysql_fetch_row($ConfigResult)) {
        if (is_numeric($myrow[1]) and $myrow[0]!='DefaultPriceList'){
            //the variable name is given by $myrow[0]
            $_SESSION[$myrow[0]] = (double) $myrow[1];
        } else {
            $_SESSION[$myrow[0]] =  $myrow[1];
        }

    } //end loop through all config variables
    $_SESSION['CompanyDefaultsLoaded'] = true;
    DB_free_result($ConfigResult);

end quote.

Your query seems fine.. Check if you have a valid connection. :)