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?

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.