capturing query result

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ddtpmyra
    Contributor
    • Jun 2008
    • 333

    capturing query result

    how can I capture the query result in PHP?

    I have two queries below:
    [PHP]# Fetch the file information
    $query ="update filestorage set approved ='Y' where FileID = {$id}";
    $query1 ="select members.email from members, filestorage where filestorage.aut hor = members.usernam e and FileID = {$id}" ;[/PHP]

    then execute the query using command below:
    [PHP] $result = @mysql_query($q uery) or die("Error! Query failed: <pre>". mysql_error($db Link) ."</pre>");
    $result1 = @mysql_query($q uery1) or die("Error! Query failed: <pre>". mysql_error($db Link) ."</pre>");[/PHP]

    assigning var $result1:
    [PHP] echo "$result1";
    $to = "$result1";[/PHP]

    and when I tried to print the $result1 it shows
    "Resource id #3"
    where I'm expecting "email address" (johnsmith@yaho o.com) as a result :( Please anyone can show me how to do this in a right way.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    You have to run it through one of mysql's functions such as mysql_fetch_arr ay().

    Code:
    $result1 = @mysql_query($query1)  or die("Error! Query failed: <pre>". mysql_error($dbLink) ."</pre>");
    
    while($output = mysql_fetch_array($result1))
    {
        echo $output['email'];
    }

    Comment

    Working...