Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Should be easy PHP/MySQL query but having problem with syntax or?? 1

Status
Not open for further replies.

topjimmie

IS-IT--Management
Feb 4, 2002
28
US
I know there is a syntax problem here but I just can't figure it out. Trying retrieve eventdetail_id from a table. I have gone through countless permutations of this code and every time it returns as if there is not a matching record (array, etc). I know there is a matching record, and the eventdetail_id should return 35.
Code:
//fyi: Values already assigned are: $rp_id=3516 and $evtID=3516

$detailid = "SELECT eventdetail_id FROM jos_jevents_repetition WHERE rp_id =".$evtID;
$db->setQuery( $detailid );
$jbIds= $db->loadObjectList();
$jbId=mysql_fetch_array($jbIds)

I'm not a PHP expert so if something does not follow my limited expectations, I try stuff and hope to find the answer. I'm out of things to try. Unfortunately, the task at hand doesn't always respect your skill level.

Any help is appreciated

Jevents: 1.5.4
Database Version: 5.1.36-community-log
Database Collation: utf8_general_ci
PHP Version: 5.2.5
Web Server: Apache/2.2.11 (Win32) PHP/5.2.5
Web Server to PHP interface: apache2handler
Joomla! Version: Joomla! 1.5.15 Stable
 
the last two lines of your code seem inconsistent. up until the last line you are using a database abstraction layer (probably the one built into joomla). then in the last line you call mysql_* functions directly.

now, i don't use joomla but i suspect the loadobjectlist() method returns an array of standard class objects.

so something like this will probably work better

Code:
//fyi: Values already assigned are: $rp_id=3516 and $evtID=3516

$detailid = "SELECT eventdetail_id FROM jos_jevents_repetition WHERE rp_id =".$evtID;
$db->setQuery( $detailid );
$rows = $db->loadObjectList();
foreach ($rows as $row){
   echo "The event detail ID is " . $row->eventdetail_id . "<br/>";
}
 
Thanks Jpadie, that works! Hadn't realized the difference. Learning continues!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top