Extracting Results from Query

Thread Solved

Join Date: Mar 2005
Posts: 4
Reputation: Ajaxxx is an unknown quantity at this point 
Solved Threads: 0
Ajaxxx Ajaxxx is offline Offline
Newbie Poster

Extracting Results from Query

 
0
  #1
Mar 21st, 2005
I have the following code:

[php]$rebate_query = tep_db_query("select * from " . TABLE_REBATES . " where product_id = " . (int)$HTTP_GET_VARS['products_id']);
$rebate_information = tep_db_fetch_array($rebate_query);[/php]

This should return only 1 row of data

I have this code - " [php]$rebate = $rebate_information['rebate_amount'];[/php] "
for extracting the rebate amount. For the life of me I cannot
understand why this isn't working. It doesn't error out, but nothing is returned, and I know that the value exists.

I would very much appreciate any help you can give. Thanks.
Reply With Quote Quick reply to this message  
Join Date: Nov 2003
Posts: 360
Reputation: Gary King will become famous soon enough Gary King will become famous soon enough 
Solved Threads: 5
Team Colleague
Gary King's Avatar
Gary King Gary King is offline Offline
PHP/vBulletin Guru

Re: Extracting Results from Query

 
0
  #2
Mar 22nd, 2005
I edited code for easier reading.
Reply With Quote Quick reply to this message  
Join Date: Nov 2003
Posts: 360
Reputation: Gary King will become famous soon enough Gary King will become famous soon enough 
Solved Threads: 5
Team Colleague
Gary King's Avatar
Gary King Gary King is offline Offline
PHP/vBulletin Guru

Re: Extracting Results from Query

 
0
  #3
Mar 22nd, 2005
Use this code instead: [php] $rebate = mysql_fetch_array($rebate_information['rebate_amount']);
$rebate = $rebate[0];[/php]

And now, $rebate is set

Let me know if it didn't work; my PHP is a bit on the rough side during March Break :p
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 4
Reputation: Ajaxxx is an unknown quantity at this point 
Solved Threads: 0
Ajaxxx Ajaxxx is offline Offline
Newbie Poster

Re: Extracting Results from Query

 
0
  #4
Mar 22nd, 2005
Originally Posted by Gary
Use this code instead: [php] $rebate = mysql_fetch_array($rebate_information['rebate_amount']);
$rebate = $rebate[0];[/php]

And now, $rebate is set

Let me know if it didn't work; my PHP is a bit on the rough side during March Break :p
Hi Gary. Thanks for the response. I am getting the following error when I try your suggestion:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource.

I tried using the oscommerce fetch array function in its place, and that didn't work either. I am stumped on this for some reason. Logically, it doesn't make much sense to me yet.

If you could take another look I'd appreciate it.

Thanks again.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 4
Reputation: Ajaxxx is an unknown quantity at this point 
Solved Threads: 0
Ajaxxx Ajaxxx is offline Offline
Newbie Poster

Re: Extracting Results from Query

 
0
  #5
Mar 23rd, 2005
Thanks for your help. I had a different problem which was causing
my grief - got everything working now......
Reply With Quote Quick reply to this message  
Join Date: Nov 2003
Posts: 360
Reputation: Gary King will become famous soon enough Gary King will become famous soon enough 
Solved Threads: 5
Team Colleague
Gary King's Avatar
Gary King Gary King is offline Offline
PHP/vBulletin Guru

Re: Extracting Results from Query

 
0
  #6
Mar 26th, 2005
Glad it worked
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for MySQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC