Xtremer360 Posted November 30, 2009 Share Posted November 30, 2009 I probably have this setup wrong well I know I do because nothing is showing up now. What I want is for it to show all the character names that are assigned to each user so yes than can be more than one. Can't figure out where at in my coding is my problem. table efed_bio id charactername table handler_characters id handler_id bio_id table efed_handler id default_character_id login forum_id <?php { $query = "SELECT h.login, h.forumname, bio.charactername AS charactername FROM efed_bio AS bio, efed_handler_characters AS ech, efed_handler AS h WHERE h.default_char_id = bio.id AND ech.handler_id=h.id AND ech.bio_id=bio.id"; $result = mysql_query ( $query ); // Run The Query if ($result) { print '<h1 class=backstage>Active Handler Directory</h1><br />'; print '<table width="100%" class="table1">'; print '<tr class="rowheading">'; print '<td>Name</td>'; print '<td>Forum Name</td>'; print '<td>Characters</td>'; print '</tr>'; // Fetch and print all records. $i = 0; while ( $row = mysql_fetch_array ( $result, MYSQL_ASSOC ) ) { $sClass = 'row2'; if ($i ++ & 1) { $sClass = 'row1'; } printf ( "<tr class=\"%s\">", $sClass ); printf ( "<td valign=\"top\">%s</td>", $row [login] ); printf ( "<td valign=\"top\">%s</td>", $row [forumname] ); printf ( "<td valign=\"top\"><ul class=\"characters\"><li>%s</li>", $row [charactername] ); print '</ul></td>'; print '</tr>'; } print '</table><br />'; print '<h2 class=backstage><form method=POST><input type=hidden name=action value=mainmenu><input type=submit value="Return to Main Menu" class=button200></form></h2>'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/183387-query-issues/ Share on other sites More sharing options...
GKWelding Posted November 30, 2009 Share Posted November 30, 2009 try this instead. $query = "SELECT h.login, h.forumnname, b.charactername FROM efed_handler AS h JOIN handler_characters AS c ON h.id = c.handler_id JOIN efed_bio AS b ON c.bio_id = b.id"; Quote Link to comment https://forums.phpfreaks.com/topic/183387-query-issues/#findComment-968055 Share on other sites More sharing options...
Xtremer360 Posted November 30, 2009 Author Share Posted November 30, 2009 Thank you but it didn't work. I tried working with it to work and couldn't get it either. Quote Link to comment https://forums.phpfreaks.com/topic/183387-query-issues/#findComment-968323 Share on other sites More sharing options...
mrMarcus Posted November 30, 2009 Share Posted November 30, 2009 provide more details as to what's happening. when you execute the query, does anything happen? error message? white screen? add trigger_error() to your query: $result = mysql_query ( $query ) or trigger_error (mysql_error()); // Run The Query Quote Link to comment https://forums.phpfreaks.com/topic/183387-query-issues/#findComment-968325 Share on other sites More sharing options...
Xtremer360 Posted November 30, 2009 Author Share Posted November 30, 2009 White screen. What is the purpose of trigger? Quote Link to comment https://forums.phpfreaks.com/topic/183387-query-issues/#findComment-968328 Share on other sites More sharing options...
mrMarcus Posted November 30, 2009 Share Posted November 30, 2009 trigger_error will, well...trigger an error if there is one. adding mysql_error() as the argument to trigger_error() will display any errors within the mysql query in question. white screen usually means a parse error. add: <?php ini_set ('display_errors', 1); error_reporting(E_ALL); to the very top of your script(s), immediately after <?php Quote Link to comment https://forums.phpfreaks.com/topic/183387-query-issues/#findComment-968338 Share on other sites More sharing options...
Xtremer360 Posted November 30, 2009 Author Share Posted November 30, 2009 I found the issues. It's displaying the html table like it should and the join tag for the query is working properly now it's displaying the character names however it's giving me these errors above the table. Notice: Use of undefined constant login - assumed 'login' in /home/content/y/a/n/yankeefaninkc/html/defiant/backstage/backstage_libs/directory.php on line 38 Notice: Use of undefined constant forumname - assumed 'forumname' in /home/content/y/a/n/yankeefaninkc/html/defiant/backstage/backstage_libs/directory.php on line 39 Notice: Undefined index: forumname in /home/content/y/a/n/yankeefaninkc/html/defiant/backstage/backstage_libs/directory.php on line 39 Notice: Use of undefined constant charactername - assumed 'charactername' in /home/content/y/a/n/yankeefaninkc/html/defiant/backstage/backstage_libs/directory.php on line 40 <?php {ror_reporting(E_ALL); $query = "SELECT h.login, h.id, b.charactername FROM efed_handler AS h JOIN efed_handler_characters AS c ON h.id = c.handler_id JOIN efed_bio AS b ON c.bio_id = b.id"; $result = mysql_query ( $query ) or trigger_error (mysql_error()); // Run The Query if ($result) { print '<h1 class=backstage>Active Handler Directory</h1><br />'; print '<table width="100%" class="table1">'; print '<tr class="rowheading">'; print '<td>Name</td>'; print '<td>Forum Name</td>'; print '<td>Characters</td>'; print '</tr>'; // Fetch and print all records. $i = 0; while ( $row = mysql_fetch_array ( $result, MYSQL_ASSOC ) ) { $sClass = 'row2'; if ($i ++ & 1) { $sClass = 'row1'; } printf ( "<tr class=\"%s\">", $sClass ); printf ( "<td valign=\"top\">%s</td>", $row [login] ); printf ( "<td valign=\"top\">%s</td>", $row [forumname] ); printf ( "<td valign=\"top\"><ul class=\"characters\"><li>%s</li>", $row [charactername] ); print '</ul></td>'; print '</tr>'; } print '</table><br />'; print '<h2 class=backstage><form method=POST><input type=hidden name=action value=mainmenu><input type=submit value="Return to Main Menu" class=button200></form></h2>'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/183387-query-issues/#findComment-968349 Share on other sites More sharing options...
mrMarcus Posted November 30, 2009 Share Posted November 30, 2009 these are just Notices, but it's great practice to eliminate these. the Notice: Notice: Use of undefined constant x is because you're not wrapping your $row index with quotes, like so: $row['forumname'] and so on. the Notice: Notice: Undefined index: forumname would be because `forumname` has not been set by a value from the db. Quote Link to comment https://forums.phpfreaks.com/topic/183387-query-issues/#findComment-968357 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.