TheMasterGeneral Posted November 4, 2014 Share Posted November 4, 2014 Hey everyone, I've recently added gang pics to my game. They work, except they won't show up on the page where you view the gangs. I'm not exactly sure why it happens, as I thought it'd be an easy copy/paste from the yourgang.php (where the pic does show) yourgang.php (where the pic works) $gangdata = $db->fetch_row($gq); $db->free_result($gq); echo " <h3><u>Your Guild - {$gangdata['gangNAME']}</u></h3> "; if($gangdata['gangPIC']) { print "<img src='{$gangdata['gangPIC']}' alt='Gang Picture' width='350' height='350' />"; } else { print " "; } Can be seen working here... This is the code on gangs.php, where it doesn't show. function gang_view() { global $db, $ir, $c, $h, $gangdata; $gangPIC = $db->query( "SELECT `gangPIC` FROM `gangs` WHERE `gangID` = {$gangdata['gangID']}"); $pq = $db->query( "SELECT `userid`, `username` FROM `users` WHERE `userid` = {$gangdata['gangPRESIDENT']} LIMIT 1"); if ($db->num_rows($pq) == 0) { $ldr = array('userid' => 0); } else { $ldr = $db->fetch_row($pq); } $db->free_result($pq); $vpq = $db->query( "SELECT `userid`, `username` FROM `users` WHERE `userid` = {$gangdata['gangVICEPRES']}"); if ($db->num_rows($vpq) == 0) { $coldr = array('userid' => 0); } else { $coldr = $db->fetch_row($vpq); } $db->free_result($vpq); echo "<h3><u>{$gangdata['gangNAME']} Guild</u></h3><hr />"; if($gangdata['gangPIC']) { print "<img src='{$gangdata['gangPIC']}' alt='Gang Picture' width='468' height='60' /><hr />"; } else { print "<b>No Gang Picture</b><hr />"; } if ($ldr['userid'] > 0) { print "Founder: <a href='viewuser.php?u={$ldr['userid']}'>{$ldr['username']}</a><br />"; } else { print "Founder: N/A<br />"; } if ($coldr['userid'] > 0) { print "Co-Founder: <a href='viewuser.php?u={$coldr['userid']}'>{$coldr['username']}</a><hr />"; } else { print "Co-Founder: N/A<hr />"; } $cnt = $db->query( "SELECT COUNT(`userid`) FROM `users` WHERE `gang` = {$gangdata['gangID']}"); echo "<b>Members:</b> " . $db->fetch_single($cnt) . "<br /> <b>Description: </b> {$gangdata['gangDESC']}<br /> <b>Respect Level: </b> {$gangdata['gangRESPECT']}<br /> > <a href='gangs.php?action=userlist&ID={$gangdata['gangID']}'> User List </a><br /> > <a href='gangs.php?action=apply&ID={$gangdata['gangID']}'> Apply </a>"; $db->free_result($cnt); } Can be seen that its not working I also get this error with the error reporting working. (On gang.php) A non-critical error has occurred. Page execution will continue. Below are the details: PHP Notice: Undefined index: gangPIC (8) Line executed: /home/chivalr2/public_html/gangs.php:108 Can anyone tell me what I've done wrong? Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted November 5, 2014 Share Posted November 5, 2014 I haven't looked at the gang data var in quite some time but does it include the gangPIC column in the query? Quote Link to comment Share on other sites More sharing options...
TheMasterGeneral Posted November 5, 2014 Author Share Posted November 5, 2014 I'm 99.9% sure its not. However, I'm not sure what file I'd check to make sure if it is(n't). I've just looked in globals (all three of them), headers, the files in the class folder, and didn't really find a reference to it. I apologize if I'm overlooking it. Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted November 6, 2014 Share Posted November 6, 2014 (edited) Question? Have you tried to see if $gangdata in global is actually working such just echoing the gangPIC to see where your error is?? Usually it helps to strip the function and only echo the part you don't see to determine what the error is. function gang_view() { global $db, $ir, $c, $h, $gangdata; echo '<img src="'.$gangdata['gangPIC'].'" alt="Gang Picture" width="468" height="60" />'; } Edited November 6, 2014 by lucky3809 Quote Link to comment Share on other sites More sharing options...
DAMINK Posted November 6, 2014 Share Posted November 6, 2014 Question? Have you tried to see if $gangdata in globals is actually working such just echoing the gangPIC to see where your error is?? Usually it helps to strip the function and only echo the part you don't see to determine what the error is. function gang_view() { global $db, $ir, $c, $h, $gangdata; echo '<img src="'.$gangdata['gangPIC'].'" alt="Gang Picture" width="468" height="60" />'; } yourgang.php (where the pic works) Yep i think his globals are working. Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted November 6, 2014 Share Posted November 6, 2014 In gangs.php and yourgang.php, find the query responsible for populating the $gangdata array. (Default: starts with $gc = $db->query("SELECT [...] FROM `gangs`[...]"); ) Make sure that, if it's not selecting everything "*", that it is selecting the `gangPIC` column. Also, make sure that the `gangPIC` column actually exists. If it doesn't, add it! ALTER TABLE `gangs` ADD `gangPIC` VARCHAR( 255 ) NOT NULL DEFAULT 'images/defaultclan.png'; # Change the "default" to whatever you want, or leave it blank, etc. Quote Link to comment Share on other sites More sharing options...
TheMasterGeneral Posted November 6, 2014 Author Share Posted November 6, 2014 Oh wow, derp on me. I thought they would have been in a globals file. Thanks Magictallguy! Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted November 12, 2014 Share Posted November 12, 2014 Tis my pleasure :) Quote Link to comment 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.