Xtremer360 Posted October 23, 2010 Share Posted October 23, 2010 I had some help righting this query and the extensive coding here and most of it I understand however when i run this it gives me an undefined variable charname error and I'm trying to understand why. Does the coding make sense to anyone? <?php $query = "SELECT ecm.name AS fighters, ecb.id AS showid, ecm.id AS matchid, ecb.bookingdate AS bookingdate, ecb.event_id AS event_id, els.name AS name, ecb.label AS label FROM `efed_content_appearances` AS eca INNER JOIN `efed_content_matchseg` AS ecm ON eca.content_id = ecm.id INNER JOIN `efed_content_booking` AS ecb ON ecm.booking_id = ecb.id INNER JOIN `efed_list_shownames` AS els ON ecb.event_id = els.id WHERE eca.bio_id = '$id' AND eca.type = 'match' ORDER BY ecb.bookingdate DESC, ecm.sortorder ASC"; $result = mysql_query($query); if(mysql_num_rows($result) == 0){ echo '<td colspan="3" class="noseg">This wrestler has never been in an event match.</td>' ; } else{ $count = 1; while($row = mysql_fetch_assoc($result)){ $fighter = explode(' vs. ', $row['fighters']); $opponents = ''; for($i = 0; $i < count($fighter); $i++){ if($fighter[$i] != $charname){ if($opponents != ''){ $opponents .= ', '; } $opponents .= $fighter[$i]; } } echo '<table cellspacing="0px" style="text-align: center;"><tr class="titlebar"><td>Date</td><td>Show</td><td>Opponent/s</td></tr>'; echo '<tr class="row' . $count . '"><td>' . convertdate($row['bookingdate']) . '</td><td><a href="content.php?p=results&show=' . $row['event_id'] . '&id=' . $row['showid'] . '#' . $row['matchid'] . '">' . $row['name'] . ' ' . $row['label'] . '</a></td><td>' . $opponents . '</td></tr>'; echo '</table>'; if($count == 1){ $count = 2; } else { $count = 1; } } } ?> Link to comment https://forums.phpfreaks.com/topic/216655-undefined-variable/ Share on other sites More sharing options...
marcus Posted October 23, 2010 Share Posted October 23, 2010 if($fighter[$i] != $charname){ No where in your code is $charname ever defined. Link to comment https://forums.phpfreaks.com/topic/216655-undefined-variable/#findComment-1125650 Share on other sites More sharing options...
Xtremer360 Posted October 23, 2010 Author Share Posted October 23, 2010 Does the coding make sense logically of course. Link to comment https://forums.phpfreaks.com/topic/216655-undefined-variable/#findComment-1125652 Share on other sites More sharing options...
marcus Posted October 23, 2010 Share Posted October 23, 2010 Sure, but what is $charname supposed to be? Link to comment https://forums.phpfreaks.com/topic/216655-undefined-variable/#findComment-1125677 Share on other sites More sharing options...
Xtremer360 Posted October 23, 2010 Author Share Posted October 23, 2010 The fighter's name I think. Like I said had that written and kind of understand it and kind of don't. Link to comment https://forums.phpfreaks.com/topic/216655-undefined-variable/#findComment-1125681 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.