beanfair Posted February 7, 2010 Share Posted February 7, 2010 I have tested both of these queries in PHPMyAdmin and they work great. When I try to call those queries and data bind, one works and one doesn't. I can't see where the problem is. This works <?php $meeting = $wpdb->get_row("SELECT *, date_FORMAT(startDate, '%M %e, %Y') as newDate FROM sfa_meetings WHERE meetingID = 163");?> <h3><?php echo $meeting->newDate; ?></h3> <h2><?php echo $meeting->title; ?></h2> This does not <?php $location =$wpdb->get_row("SELECT locID, locName, address, city, zip, drive, locDesc, comments FROM locations WHERE locID =7 ");?> <h3><?php echo $loc->locName; ?> </h3> I am stumped. Both code blocks appear on this page http://174.123.219.170/~romancew/meeting-test but I have also tried the code blocks on separate pages to make sure they weren't interfering. The first code block works whereever I put it but not the second. Any assistance is appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/191224-one-query-works-one-doesnt-need-a-second-set-of-eyes/ Share on other sites More sharing options...
trq Posted February 7, 2010 Share Posted February 7, 2010 The results of the get_row() method is being stored in an object called $location, you are then trying to echo a property of an object called $loc. Where is $loc defined? Quote Link to comment https://forums.phpfreaks.com/topic/191224-one-query-works-one-doesnt-need-a-second-set-of-eyes/#findComment-1008266 Share on other sites More sharing options...
beanfair Posted February 7, 2010 Author Share Posted February 7, 2010 That was a typo after too many hours staring at the code. Here is the code as it appears on the test page This works [/<?php $meeting = $wpdb->get_row("SELECT *, date_FORMAT(startDate, '%M %e, %Y') as newDate FROM sfa_meetings WHERE meetingID = 163");?> <h3><?php echo $meeting->newDate; ?></h3> <h2><?php echo $meeting->title; ?></h2>php] This does not [code=php:0]<?php $location =$wpdb->get_row("SELECT locID, locName, address, city, zip, drive, locDesc, comments FROM locations WHERE locID =7 ");?> <h3><?php echo $location->locName; ?> </h3> Here is subsequent code on that page <table> <tr><td>Registration Begins</td><td><?php echo $meeting->regTime; ?></td></tr> <tr><td>Business Meeting Begins</td><td><?php echo $meeting->busTime; ?></td></tr> <tr><td>Feature Begins</td><td><?php echo $meeting->featureTime; ?></td></tr> <tr><td>Adjourn</td><td><?php echo $meeting->adjournTime; ?></td></tr> <tr><td>Location</td><td><?php echo $location->locName; ?></td></tr> <tr><td>Address</td><td><?php echo $location->address; ?></td></tr> <tr><td></td><td><?php echo $location->city; ?>, CA <?php echo $location->zip; ?></td></tr> <tr><td>Directions</td><td><?php echo $location->drive; ?></td></tr> <tr><td>Questions?</td><td><?php echo $meeting->email; ?></td></tr> </table> The test page is at http://174.123.219.170/~romancew/meeting-test Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/191224-one-query-works-one-doesnt-need-a-second-set-of-eyes/#findComment-1008430 Share on other sites More sharing options...
Buddski Posted February 7, 2010 Share Posted February 7, 2010 Have you checked to see if the query is returning any results in PHP or produced any errors? try var_dump($location) and see what that has to say... Quote Link to comment https://forums.phpfreaks.com/topic/191224-one-query-works-one-doesnt-need-a-second-set-of-eyes/#findComment-1008436 Share on other sites More sharing options...
beanfair Posted February 8, 2010 Author Share Posted February 8, 2010 No errors and the var_dump works, returning all expected values. This is driving me crazy. Quote Link to comment https://forums.phpfreaks.com/topic/191224-one-query-works-one-doesnt-need-a-second-set-of-eyes/#findComment-1008686 Share on other sites More sharing options...
RussellReal Posted February 8, 2010 Share Posted February 8, 2010 if the var dump returns the values then maybe you're calling the object's parameters the wrong way. check the names. Quote Link to comment https://forums.phpfreaks.com/topic/191224-one-query-works-one-doesnt-need-a-second-set-of-eyes/#findComment-1008688 Share on other sites More sharing options...
kalidossmm Posted February 8, 2010 Share Posted February 8, 2010 Can u print the VAR_DUMP output here. Quote Link to comment https://forums.phpfreaks.com/topic/191224-one-query-works-one-doesnt-need-a-second-set-of-eyes/#findComment-1008730 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.