By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,346 Members | 2,318 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,346 IT Pros & Developers. It's quick & easy.

capturing query result

ddtpmyra
100+
P: 333
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
Share this Question
Share on Google+
1 Reply


Markus
Expert 5K+
P: 6,050
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.