Jump to content

valid MySQL result resource - What's that mean?


Darkmatter5

Recommended Posts

Here's my code

 

<?php
    include 'library/config.inc.php';
    mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
    mysql_select_db($dbnamemain);
    
    $query="SELECT cabinet_id, cab_name, cab_description
            FROM $dbnamemain.cabinets
            ORDER BY cab_name ASC";
    $result=mysql_fetch_array($query) or die($query . '<br >'.mysql_error());
    //while(list($cabinet_id, $cab_name, $cab_description)=mysql_fetch_array($query, MYSQL_NUM)) {
    foreach ($result as $row) {
        $cabinet=$cab_name. ": " .$cab_description;
        echo "<tr>
        <td width='200'>" .substr($cabinet,0,100). "</td>
        <td width='100' align='center'><a href='cab_edit.php?cab_id=$cabinet_id'>edit </a> | <a href='javascript:delArticle('$cabinet_id','$cab_name');>delete</a>,/td>
        </tr>";
    }
            
    mysql_close($conn);
?>

 

Here's the error it's producing. "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/thealien/public_html/ecabinet/testing.php on line 9

SELECT cabinet_id, cab_name, cab_description FROM thealien_ecabinet.cabinets ORDER BY cab_name ASC". How can I fix this?

You need to RUN the query first!

 

   include 'library/config.inc.php';
    mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
    mysql_select_db($dbnamemain);
    
    $query="SELECT cabinet_id, cab_name, cab_description
            FROM $dbnamemain.cabinets
            ORDER BY cab_name ASC";

    //Run the querey
    $result=mysql_query($query) or die (mysql_error());
    //$result = mysql_fetch_array($query)

    while(list($cabinet_id, $cab_name, $cab_description)=mysql_fetch_array($result, MYSQL_NUM)) {
    foreach ($result as $row) {
        $cabinet=$cab_name. ": " .$cab_description;
        echo "<tr>
        <td width='200'>" .substr($cabinet,0,100). "</td>
        <td width='100' align='center'><a href='cab_edit.php?cab_id=$cabinet_id'>edit </a> | <a href='javascript:delArticle('$cabinet_id','$cab_name');>delete</a>,/td>
        </tr>";
    }
            
    mysql_close($conn);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.