MySQL result resource error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BOMEz
    New Member
    • Dec 2007
    • 40

    MySQL result resource error

    Hi everyone,

    I have a form which updates some info in a DB. Currently the user does a search, which will load up results, which the user can change, and then submit those changes back into the DB.

    I'm attempting to make it that after submitting data successfully that the search results load back up right away, so the user doesn't have to put in search criteria again.

    Results are held in a $result variable :
    Code:
    $result = search($_POST['f_name'], $_POST['l_name'], $_POST['sub'], $_POST['des'], $_POST['id'], $_POST['u_id'], $cat, $s_date, $e_date);
    $result is then passed to a function edit_tables($re sult) where I print out the data in forms which the user can edit.

    Before I iterate through $result I pass it into another variable, which i then pass along as a $_POST variable (lets call it new_result) as the user hits submit which sends the data into another function which actually updates in the information.

    My problem is that if I echo my $_POST['new_result'] it gives me "Resource ID#6" which is my expected result, but if I now try to traverse that Resource ID by passing it back into my edit_tables function, I get the error:

    Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL result resource in /web/apache/htdocs/folder/folder/dev/file.php on line 46

    Can anyone point out what I'm doing wrong or recommended a better way to do this?
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    This "Resource ID #", are you printing it into the HTML to be re-submitted to another page?

    If so, keep in mind that when a mysql_query call returns a result object, the object is used to fetch the data. What you get from printing it ("Resource ID #") is just a string PHP uses to show you what the object is.

    Once the code has been executed and the output sent to the client, the resource your mysql_query call returned no longer exists. What you put into the form is now just a string and can not be used to access those results anymore.

    You need to query them again in the second page.

    Comment

    • BOMEz
      New Member
      • Dec 2007
      • 40

      #3
      So pretty much I'm just really passing along a string.

      I think I got

      Thanks for the reply. I'm moving onto an entirely different strategy

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Good luck! :)
        Let us know if you need help with you new strategy.

        Comment

        Working...