Jim R Posted June 16, 2012 Share Posted June 16, 2012 It's a WordPress site, but this still seems more like a PHP/MySQL issue rather than a WordPress issue. I'm trying to match Images (ngp.pid) tags (tr.object_id) that share the same ID's. The Images matched have to then share the same ID as $wp_tagID, which the Page gets based on whatever link my user clicks. From there I want to print what I have to the screen. Here is the test screen: http://hoosierhoopsreport.com/tag/Michael-Volovic/ (All the information above the HR is from a database, linked to $wp_tagID, so I know that part of it is working.) Clicking on his link, carries a $wp_tagID of 677. When I test my query in my MySQL program and just use 677 (as $wp_tagID) it works. I get five images that share the same link of this basketball player. The second var_dump is producing a false result on the actual page. Not sure why. $qImage = ' SELECT * FROM wp_terms AS t JOIN wp_ngg_gallery AS ngg JOIN wp_term_taxonomy AS tt JOIN wp_term_relationships AS tr JOIN wp_ngg_pictures AS ngp WHERE t.term_id = tt.term_id AND ngg.gid = ngp.galleryid AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tr.object_id = ngp.pid AND tt.taxonomy = "ngg_tag" AND t.term_id = "$wp_tagID" LIMIT 5'; // AND t.term_id = "$wp_tagID" $pImage = mysql_query($qImage); while($image = mysql_fetch_assoc($pImage)) { foreach ($image as $images) { echo '<img src="http://hoosierhoopsreport.com'. $images['path'] .'/'. $images['filename'] .'>'; } } var_dump($wp_tagID); var_dump($image); Quote Link to comment https://forums.phpfreaks.com/topic/264297-var_dump-giving-me-a-boolfalse-but-im-not-sure-why/ Share on other sites More sharing options...
xyph Posted June 16, 2012 Share Posted June 16, 2012 The manual says this about mysql_fetch_assoc Returns an associative array of strings that corresponds to the fetched row, or FALSE if there are no more rows. Quote Link to comment https://forums.phpfreaks.com/topic/264297-var_dump-giving-me-a-boolfalse-but-im-not-sure-why/#findComment-1354420 Share on other sites More sharing options...
Jim R Posted June 16, 2012 Author Share Posted June 16, 2012 It is my second usage of mysql_fetch_assoc in the file. I'm a tweaker, not a coder. *shocking, right? * I've never really gotten a grasp of which function to use after my queries, so I basically just use that one. Once I was told to "reset the pointer" on another issue awhile ago. Is that my issue now? Quote Link to comment https://forums.phpfreaks.com/topic/264297-var_dump-giving-me-a-boolfalse-but-im-not-sure-why/#findComment-1354421 Share on other sites More sharing options...
xyph Posted June 16, 2012 Share Posted June 16, 2012 It shouldn't matter, as you've given it a new result resource. The function will always return FALSE after it's been looped through, or if there are no rows returned. <?php mysql_connect('localhost','root',''); mysql_select_db('db'); echo '<h3>Bunch of results</h3>'; $res = mysql_query('SELECT * FROM events'); while( $row = mysql_fetch_assoc($res) ) { var_dump($row); echo '<br>'; } echo 'End: '; var_dump($row); echo '<h3>One result</h3>'; $res = mysql_query('SELECT * FROM events WHERE id = 1'); while( $row = mysql_fetch_assoc($res) ) { var_dump($row); echo '<br>'; } echo 'End: '; var_dump($row); echo '<h3>No results</h3>'; $res = mysql_query('SELECT * FROM events WHERE id = -1'); while( $row = mysql_fetch_assoc($res) ) { var_dump($row); echo '<br>'; } echo 'End: '; var_dump($row); ?> ---------------------- Bunch of results ---------------------- array 'id' => string '1' (length=1) 'date' => string '2012-04-27 00:00:00' (length=19) 'source_id' => string '1' (length=1) array 'id' => string '2' (length=1) 'date' => string '2012-04-27 00:00:00' (length=19) 'source_id' => string '1' (length=1) array 'id' => string '3' (length=1) 'date' => string '2012-04-27 15:51:29' (length=19) 'source_id' => string '2' (length=1) array 'id' => string '4' (length=1) 'date' => string '2012-05-23 00:00:00' (length=19) 'source_id' => string '1' (length=1) array 'id' => string '5' (length=1) 'date' => string '0000-00-00 00:00:00' (length=19) 'source_id' => string '2' (length=1) array 'id' => string '6' (length=1) 'date' => string '2012-04-27 16:06:36' (length=19) 'source_id' => string '2' (length=1) array 'id' => string '7' (length=1) 'date' => string '2012-04-27 16:16:51' (length=19) 'source_id' => string '1' (length=1) array 'id' => string '14' (length=2) 'date' => string '2012-04-27 16:45:27' (length=19) 'source_id' => string '4' (length=1) array 'id' => string '16' (length=2) 'date' => string '2012-04-27 16:58:04' (length=19) 'source_id' => string '4' (length=1) End: boolean false ---------------------- One result ---------------------- array 'id' => string '1' (length=1) 'date' => string '2012-04-27 00:00:00' (length=19) 'source_id' => string '1' (length=1) End: boolean false ---------------------- No results ---------------------- End: boolean false Quote Link to comment https://forums.phpfreaks.com/topic/264297-var_dump-giving-me-a-boolfalse-but-im-not-sure-why/#findComment-1354425 Share on other sites More sharing options...
Jim R Posted June 16, 2012 Author Share Posted June 16, 2012 Ok...that may explain the var_dump, but I'm still not getting the same result on my page query vs. the query made in my MySQL program. I moved the var_dump up higher and get this: resource(352) of type (mysql result) Quote Link to comment https://forums.phpfreaks.com/topic/264297-var_dump-giving-me-a-boolfalse-but-im-not-sure-why/#findComment-1354428 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.