471,351 Members | 1,507 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,351 software developers and data experts.

capturing query result

ddtpmyra
333 100+
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.author = members.username and FileID = {$id}" ;[/PHP]

then execute the query using command below:
[PHP] $result = @mysql_query($query) or die("Error! Query failed: <pre>". mysql_error($dbLink) ."</pre>");
$result1 = @mysql_query($query1) or die("Error! Query failed: <pre>". mysql_error($dbLink) ."</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@yahoo.com) as a result :( Please anyone can show me how to do this in a right way.
Oct 25 '08 #1
1 1615
Markus
6,050 Expert 4TB
You have to run it through one of mysql's functions such as mysql_fetch_array().

Expand|Select|Wrap|Line Numbers
  1. $result1 = @mysql_query($query1)  or die("Error! Query failed: <pre>". mysql_error($dbLink) ."</pre>");
  2.  
  3. while($output = mysql_fetch_array($result1))
  4. {
  5.     echo $output['email'];
  6. }
  7.  
Oct 25 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.