RawliJr
07-08-2006, 03:51 AM
ok i have a table set up..called km_users it has lots of stuff under it...and i was wondering how i could show the tables that i have under it?
cheers
rawli:confused:
cheers
rawli:confused:
|
||||
Showing Mysql tables?RawliJr 07-08-2006, 03:51 AM ok i have a table set up..called km_users it has lots of stuff under it...and i was wondering how i could show the tables that i have under it? cheers rawli:confused: fci 07-08-2006, 03:55 AM I am confused too. maybe you want to run the query: SHOW TABLES ultimately, I have no idea what you're asking. RawliJr 07-08-2006, 04:02 AM like what i want to so is something like this <?php <table width=50% cellspacing=2 cellpadding=1> <tr> <td width=5%><font id=thefont>Thugs:</td><td><?=commas($km_users[thug])?></td> </tr><tr> <td><font id=thefont>Condoms:</td><td><?=commas($km_users[condoms])?> </td> </tr><tr>; <td><font id=thefont>Crack:</td><td><?=commas($km_users[crack])?> </td> </tr><tr> <td><font id=thefont> Weed:</td><td><?=commas($km_users[weed])?></td> </tr><tr> <td><font id=thefont> AK-47's:</td><td><?=commas($km_users[ak47])?></td> </tr> </table> ?> like in a table show what the user has like the amount of thug, condoms, crack, weed, and ak:47's...so it just shows what the user what he has? fci 07-08-2006, 04:14 AM something like this? <?php $rs = mysql_query("SELECT * FROM km_users"); while ($row=mysql_fetch_assoc($rs)) { ?> <table width=50% cellspacing=2 cellpadding=1> <tr> <td width=5%><font id=thefont>Thugs:</td><td><?=commas($row['thug'])?></td> </tr><tr> <td><font id=thefont>Condoms:</td><td><?=commas($row['condoms'])?> </td> </tr><tr> <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?> </td> </tr><tr> <td><font id=thefont> Weed:</td><td><?=commas($row['weed'])?></td> </tr><tr> <td><font id=thefont> AK-47's:</td><td><?=commas($row['ak47'])?></td> </tr> </table> <? } ?> fci 07-08-2006, 04:25 AM something like this? <?php $rs = mysql_query("SELECT * FROM km_users"); while ($row=mysql_fetch_assoc($rs)) { ?> <table width=50% cellspacing=2 cellpadding=1> <tr> <td width=5%><font id=thefont>Thugs:</td><td><?=commas($row['thug'])?></td> </tr><tr> <td><font id=thefont>Condoms:</td><td><?=commas($row['condoms'])?> </td> </tr><tr> <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?> </td> </tr><tr> <td><font id=thefont> Weed:</td><td><?=commas($row['weed'])?></td> </tr><tr> <td><font id=thefont> AK-47's:</td><td><?=commas($row['ak47'])?></td> </tr> </table> <? } ?> the question you should have asked is, "how do I fetch rows from a table?" RawliJr 07-08-2006, 04:26 AM yup but that puts a error this is my whole code includeing that one <?php //Connect to the Database mysql_connect( 'Localhost', 'xxx', 'xxx' ); mysql_select_db( 'xxx' ); //Start Session session_start(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Main Menu</title> </head> <body> <link rel="stylesheet" type="text/css" href="style.css" /> <center><img src="/images/THUGKILLIN.jpg" border="0" width="444" /></a></center> <center> <?php if ( isset($_SESSION['player']) ) { //If player is logged in $player = $_SESSION['player']; //shorthand echo '<h3>' . $player . '. </h3>'; echo '<br><br>'; echo ' </center> <div class="aaa"> <a href="store.php">Corner Store</a> <br><br> <a href="nranks.php">National Ranks</a> <br> <a href="cranks.php">City Ranks</a> <br> <a href="aranks.php">Attack Ranks</a> <br><br> <a href="http://thugkillin.forumco.com/default.asp"target="_blank">Forums</a> </div> <div class="bbb"> <a href="turntrick.php">Turn Tricks</a> <br><br> <a href="faqs.php">Faqs</a> <br><br> <a href="preferences.php">Preferences</a> <br><br> <a href="poll.php">Poll</a> <br><br> <a href="credits.php">Purchase Turns</a> <br><br> <a href="http://www.thugkillin.urlshort.com">LogOut</a> </div><br><br><br><br><br><br><br><br><br> <?php $rs = mysql_query("SELECT * FROM km_users"); while ($row=mysql_fetch_assoc($rs)) { ?> <table width=50% cellspacing=2 cellpadding=1> <tr> <td width=5%><font id=thefont>Thugs:</td><td><?=commas($row['thug'])?></td> </tr><tr> <td><font id=thefont>Condoms:</td><td><?=commas($row['condoms'])?> </td> </tr><tr> <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?> </td> </tr><tr> <td><font id=thefont> Weed:</td><td><?=commas($row['weed'])?></td> </tr><tr> <td><font id=thefont> AK-47's:</td><td><?=commas($row['ak47'])?></td> </tr> </table> <? } ?> <center> <font size="2">Thugkillin ©2006. All rights reserved.</font></center>'; } else { //If user is NOT logged in print "Sorry, not logged in please <A href='index.php'>Login</a><br>"; } ?> </body> </html> and the error is Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/thugki/public_html/index3.php on line 55 ? any idea's? fci 07-08-2006, 04:32 AM ..... <br><br> <a href="http://www.thugkillin.urlshort.com">LogOut</a> </div><br><br><br><br><br><br><br><br><br> '; $rs = mysql_query("SELECT * FROM km_users"); .... co you understand why there is an error? you needed to close off the echo statement with '; RawliJr 07-08-2006, 04:36 AM ok thanx, now it posts anyother error... Parse error: syntax error, unexpected '<' in /home/thugki/public_html/index3.php on line 51 and this is line 51 i believe </div><br><br><br><br><br><br><br><br><br> '; fci 07-08-2006, 04:38 AM ah, sorry, in my explanation, I didn't include that you need to take out the <?php the error is because the interpreter sees it like so (in simple form): <?php <?php ?> the above should produce a similar error which is easier to debug now that you can see the big picture. RawliJr 07-08-2006, 04:43 AM wow another error Parse error: syntax error, unexpected $end in /home/thugki/public_html/index3.php on line 77 this is my updated code <?php //Connect to the Database mysql_connect( 'Localhost', 'xxx', 'xxx' ); mysql_select_db( 'xxx' ); //Start Session session_start(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Main Menu</title> </head> <body> <link rel="stylesheet" type="text/css" href="style.css" /> <center><img src="/images/THUGKILLIN.jpg" border="0" width="444" /></a></center> <center> <?php if ( isset($_SESSION['player']) ) { //If player is logged in $player = $_SESSION['player']; //shorthand echo '<h3>' . $player . '. </h3>'; echo '<br><br>'; echo ' </center> <div class="aaa"> <a href="store.php">Corner Store</a> <br><br> <a href="nranks.php">National Ranks</a> <br> <a href="cranks.php">City Ranks</a> <br> <a href="aranks.php">Attack Ranks</a> <br><br> <a href="http://thugkillin.forumco.com/default.asp"target="_blank">Forums</a> </div> <div class="bbb"> <a href="turntrick.php">Turn Tricks</a> <br><br> <a href="faqs.php">Faqs</a> <br><br> <a href="preferences.php">Preferences</a> <br><br> <a href="poll.php">Poll</a> <br><br> <a href="credits.php">Purchase Turns</a> <br><br> <a href="http://www.thugkillin.urlshort.com">LogOut</a> </div><br><br><br><br><br><br><br><br><br> '; $rs = mysql_query("SELECT * FROM km_users"); while ($row=mysql_fetch_assoc($rs)) { ?> <table width=50% cellspacing=2 cellpadding=1> <tr> <td width=5%><font id=thefont>Thugs:</td><td><?=commas($row['thug'])?></td> </tr><tr> <td><font id=thefont>Condoms:</td><td><?=commas($row['condoms'])?> </td> </tr><tr> <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?> </td> </tr><tr> <td><font id=thefont> Weed:</td><td><?=commas($row['weed'])?></td> </tr><tr> <td><font id=thefont> AK-47's:</td><td><?=commas($row['ak47'])?></td> </tr> </table> <? } ?> <center> <font size="2">Thugkillin ©2006. All rights reserved.</font></center>'; } else { //If user is NOT logged in print "Sorry, not logged in please <A href='index.php'>Login</a><br>"; } ?> </body> </html> fci 07-08-2006, 04:46 AM } print '<center> <font size="2">Thugkillin ©2006. All rights reserved.</font></center>'; do you see why this happened? it looks like you pasted a bunch of code in the middle of an echo '...' statement.. so then the separation was needed to clean it up. RawliJr 07-08-2006, 04:52 AM new code once AGAIN and ERROR again <?php //Connect to the Database mysql_connect( 'Localhost', 'xxx', 'xxx' ); mysql_select_db( 'xxx' ); //Start Session session_start(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Main Menu</title> </head> <body> <link rel="stylesheet" type="text/css" href="style.css" /> <center><img src="/images/THUGKILLIN.jpg" border="0" width="444" /></a></center> <center> <?php if ( isset($_SESSION['player']) ) { //If player is logged in $player = $_SESSION['player']; //shorthand echo '<h3>' . $player . '. </h3>'; echo '<br><br>'; echo ' </center> <div class="aaa"> <a href="store.php">Corner Store</a> <br><br> <a href="nranks.php">National Ranks</a> <br> <a href="cranks.php">City Ranks</a> <br> <a href="aranks.php">Attack Ranks</a> <br><br> <a href="http://thugkillin.forumco.com/default.asp"target="_blank">Forums</a> </div> <div class="bbb"> <a href="turntrick.php">Turn Tricks</a> <br><br> <a href="faqs.php">Faqs</a> <br><br> <a href="preferences.php">Preferences</a> <br><br> <a href="poll.php">Poll</a> <br><br> <a href="credits.php">Purchase Turns</a> <br><br> <a href="http://www.thugkillin.urlshort.com">LogOut</a> </div><br><br><br><br><br><br><br><br><br> '; $rs = mysql_query("SELECT * FROM km_users"); while ($row=mysql_fetch_assoc($rs)) { ?> <table width=50% cellspacing=2 cellpadding=1> <tr> <td width=5%><font id=thefont>Thugs:</td><td><?=commas($row['thug'])?></td> </tr><tr> <td><font id=thefont>Condoms:</td><td><?=commas($row['condoms'])?> </td> </tr><tr> <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?> </td> </tr><tr> <td><font id=thefont> Weed:</td><td><?=commas($row['weed'])?></td> </tr><tr> <td><font id=thefont> AK-47's:</td><td><?=commas($row['ak47'])?></td> </tr> </table> <? } ?> } print '<center> <font size="2">Thugkillin ©2006. All rights reserved.</font></center>'; } else { //If user is NOT logged in print "Sorry, not logged in please <A href='index.php'>Login</a><br>"; } ?> </body> </html> i changed what u told me too but it still post's this error Parse error: syntax error, unexpected $end in /home/thugki/public_html/index3.php on line 77 fci 07-08-2006, 04:57 AM alright, I decided to actually open it up and make it have no syntax errors: <?php //Connect to the Database mysql_connect( 'Localhost', 'xxx', 'xxx' ); mysql_select_db( 'xxx' ); //Start Session session_start(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Main Menu</title> </head> <body> <link rel="stylesheet" type="text/css" href="style.css" /> <center><img src="/images/THUGKILLIN.jpg" border="0" width="444" /></a></center> <center> <?php if ( isset($_SESSION['player']) ) { //If player is logged in $player = $_SESSION['player']; //shorthand echo '<h3>' . $player . '. </h3>'; echo '<br><br>'; echo ' </center> <div class="aaa"> <a href="store.php">Corner Store</a> <br><br> <a href="nranks.php">National Ranks</a> <br> <a href="cranks.php">City Ranks</a> <br> <a href="aranks.php">Attack Ranks</a> <br><br> <a href="http://thugkillin.forumco.com/default.asp"target="_blank">Forums</a> </div> <div class="bbb"> <a href="turntrick.php">Turn Tricks</a> <br><br> <a href="faqs.php">Faqs</a> <br><br> <a href="preferences.php">Preferences</a> <br><br> <a href="poll.php">Poll</a> <br><br> <a href="credits.php">Purchase Turns</a> <br><br> <a href="http://www.thugkillin.urlshort.com">LogOut</a> </div><br><br><br><br><br><br><br><br><br> '; $rs = mysql_query("SELECT * FROM km_users"); while ($row=mysql_fetch_assoc($rs)) { ?> <table width=50% cellspacing=2 cellpadding=1> <tr> <td width=5%><font id=thefont>Thugs:</td><td><?=commas($row['thug'])?></td> </tr><tr> <td><font id=thefont>Condoms:</td><td><?=commas($row['condoms'])?> </td> </tr><tr> <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?> </td> </tr><tr> <td><font id=thefont> Weed:</td><td><?=commas($row['weed'])?></td> </tr><tr> <td><font id=thefont> AK-47's:</td><td><?=commas($row['ak47'])?></td> </tr> </table> <? } print '<center> <font size="2">Thugkillin ©2006. All rights reserved.</font></center>'; } else { //If user is NOT logged in print "Sorry, not logged in please <A href='index.php'>Login</a><br>"; } ?> </body> </html> are you even learning anything? I'd suggest you google the error message first before posting here next time since this is a waste of both of our time. sgoddard 07-08-2006, 04:59 AM Hey you need to escape the quotations on your HTML attributes. so... <font size="1"> within the print method should be <font size=\"1\">... If you don't fix that, it will definately give you a parse error. new code once AGAIN and ERROR again <?php //Connect to the Database mysql_connect( 'Localhost', 'xxx', 'xxx' ); mysql_select_db( 'xxx' ); //Start Session session_start(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Main Menu</title> </head> <body> <link rel="stylesheet" type="text/css" href="style.css" /> <center><img src="/images/THUGKILLIN.jpg" border="0" width="444" /></a></center> <center> <?php if ( isset($_SESSION['player']) ) { //If player is logged in $player = $_SESSION['player']; //shorthand echo '<h3>' . $player . '. </h3>'; echo '<br><br>'; echo ' </center> <div class="aaa"> <a href="store.php">Corner Store</a> <br><br> <a href="nranks.php">National Ranks</a> <br> <a href="cranks.php">City Ranks</a> <br> <a href="aranks.php">Attack Ranks</a> <br><br> <a href="http://thugkillin.forumco.com/default.asp"target="_blank">Forums</a> </div> <div class="bbb"> <a href="turntrick.php">Turn Tricks</a> <br><br> <a href="faqs.php">Faqs</a> <br><br> <a href="preferences.php">Preferences</a> <br><br> <a href="poll.php">Poll</a> <br><br> <a href="credits.php">Purchase Turns</a> <br><br> <a href="http://www.thugkillin.urlshort.com">LogOut</a> </div><br><br><br><br><br><br><br><br><br> '; $rs = mysql_query("SELECT * FROM km_users"); while ($row=mysql_fetch_assoc($rs)) { ?> <table width=50% cellspacing=2 cellpadding=1> <tr> <td width=5%><font id=thefont>Thugs:</td><td><?=commas($row['thug'])?></td> </tr><tr> <td><font id=thefont>Condoms:</td><td><?=commas($row['condoms'])?> </td> </tr><tr> <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?> </td> </tr><tr> <td><font id=thefont> Weed:</td><td><?=commas($row['weed'])?></td> </tr><tr> <td><font id=thefont> AK-47's:</td><td><?=commas($row['ak47'])?></td> </tr> </table> <? } ?> } print '<center> <font size="2">Thugkillin ©2006. All rights reserved.</font></center>'; } else { //If user is NOT logged in print "Sorry, not logged in please <A href='index.php'>Login</a><br>"; } ?> </body> </html> i changed what u told me too but it still post's this error Parse error: syntax error, unexpected $end in /home/thugki/public_html/index3.php on line 77 fci 07-08-2006, 05:01 AM he only needs to escape it if he does it like this: print "<font =\"1\">"; not if he does print '<font ="1">'; RawliJr 07-08-2006, 05:04 AM Fatal error: Call to undefined function: commas()in /home/thugki/public_html/index3.php on line 54 so now i look up on google Call to undefined function: commas() ? this is were the error is somewhere in here while ($row=mysql_fetch_assoc($rs)) { ?> <table width=50% cellspacing=2 cellpadding=1> <tr> ps.thanx alot everything work's normal now..except this last error!:D fci 07-08-2006, 05:21 AM the commas function doesn't exist, just take it out, it was in your code so I just assumed it was defined somewhere. just remove everywhere it says commas in the code. when you use google, you don't want to always give it the complete error, in this case, you would've only wanted to google for the relevant part of the error message: 'Call to undefined function' it means exactly as it states, the function commas hasn't been set anywhere. if you put the following in your code it should stop the errors too but it is a less ideal solution. function commas($arg) { return $arg; } RawliJr 07-08-2006, 05:28 AM OMFG YEAHHHHHHHHH I LOVE FCI IM GOING TO NOMINATE YOU RIGHT NOW IT WORKS YESSSS <3 lol cheers rawlijr thanx alot fci :D RawliJr 07-08-2006, 03:11 PM that work's awsome thanks, but now i added another user to see what happen's and then when i logged in it shows both users...like both of all the equipment.... like what it shows now with 2 users... Thugs: 1 Condoms: 100 Crack: 100 Turns: 5 Weed: 100 AK-47's: 1 Beer: 100 Hoes: 1 Thugs: 1 Condoms: 100 Crack: 100 Turns: 5 Weed: 100 AK-47's: 1 Beer: 100 Hoes: 1 function commas($arg) { return $arg; } $rs = mysql_query("SELECT * FROM km_users"); while ($row=mysql_fetch_assoc($rs)) { ?> <table width=50% cellspacing=2 cellpadding=1> <tr> <td width=5%><font id=thefont>Thugs:</td><td><?=commas($row['thug'])?></td> </tr><tr> <td><font id=thefont>Condoms:</td><td><?=commas($row['condoms'])?> </td> </tr><tr> <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?> </td> </tr><tr> <td><font id=thefont>Turns:</td><td><?=commas($row['turn'])?> </td> </tr><tr> <td><font id=thefont> Weed:</td><td><?=commas($row['weed'])?></td> </tr><tr> <td><font id=thefont> AK-47's:</td><td><?=commas($row['ak47'])?></td> </tr><tr> <td><font id=thefont> Beer:</td><td><?=commas($row['beer'])?></td> </tr><tr> <td><font id=thefont> Hoes:</td><td><?=commas($row['hoe'])?></td> </tr> </table> and i dont know how to change the code so it just picks the user's stuff that the user logged in with? cheers rawli:confused: Danalev 07-08-2006, 05:06 PM This is a dynamic approach I used that will display the table field names - even if you add or remove them - correctly, then list all the data below. It's been modified to make it more simple. <?php // Get connection to mysql, etc. // User has selected a table and clicked submit if (isset($_POST['view'])) { // Get the table field names $sql = "DESCRIBE " . $_POST['table']; $headres = @mysql_query ($sql); $tnum = mysql_num_rows ($headres); // Error with the query if (!$headres) { print '<p>There was a problem selecting the table, try again later.</p>'; exit; } } // Prepare the query to get a list of all the tables in the database $sql = "SHOW TABLES"; $tabres = @mysql_query ($sql) or die (mysql_error()); // All the html header stuff goes here ?> <form action="<?php print $_SERVER['PHP_SELF']; ?>" method="post"> <div class="form"> Table: <select name="table"> <?php // Generate the option list which contains the table names while ($tabdet = mysql_fetch_row ($tabres)) { print "<option value=\"$tabdet[0]\">$tabdet[0]</option>"; } ?> </select> </div> <p>Select the table you wish to view the data for.</p> <div> <input type="submit" name="view" value="View" /> </div> </form> <?php //A table has been selected if ($tnum) { // Generate the table header echo "<hr /> <table> <caption>{$_POST['table']}</caption> <tr>"; $cur = 0; while ($headshow = mysql_fetch_row ($headres)) { echo "<th>$headshow[0]</th> "; } echo '</tr>'; // List the table data $sql = "SELECT * FROM {$_POST['table']}"; $datres = @mysql_query ($sql); while ($datshow = mysql_fetch_row ($datres)) { // Columns print ' <tr> '; $cur = 0; while ($datshow[$cur]) { // Rows echo " <td>$datshow[$cur]</td> "; $cur++; } print ' </tr> '; } print ' </table> '; } // Footer stuff goes here ?> RawliJr 07-08-2006, 11:28 PM thanx but that doesnt help.... So does anybody know how I could select from All the users pick the one that i loged in with and show the Turns etc. that the person has? my whole code is! <?php //Connect to the Database mysql_connect( 'Localhost', 'thugki_thug', 'king' ); mysql_select_db( 'thugki_thug' ); //Start Session session_start(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Main Menu</title> </head> <body> <link rel="stylesheet" type="text/css" href="style.css" /> <center><img src="/images/THUGKILLIN.jpg" border="0" width="444" /></a></center> <center> <?php if ( isset($_SESSION['player']) ) { //If player is logged in $player = $_SESSION['player']; //shorthand echo '<h3>' . $player . '. </h3>'; echo '<br><br>'; echo ' </center> <div class="aaa"> <a href="store.php">Corner Store</a> <br><br> <a href="nranks.php">National Ranks</a> <br> <a href="cranks.php">City Ranks</a> <br> <a href="aranks.php">Attack Ranks</a> <br><br> <a href="http://thugkillin.forumco.com/default.asp"target="_blank">Forums</a> </div> <div class="bbb"> <a href="turntrick.php">Turn Tricks</a> <br><br> <a href="faqs.php">Faqs</a> <br><br> <a href="preferences.php">Preferences</a> <br><br> <a href="poll.php">Poll</a> <br><br> <a href="credits.php">Purchase Turns</a> <br><br> <a href="http://www.thugkillin.urlshort.com">LogOut</a> </div><br><br><br><br> '; function commas($arg) { return $arg; } $rs = mysql_query("SELECT * FROM km_users"); while ($row=mysql_fetch_assoc($rs)) { ?> <table width=50% cellspacing=2 cellpadding=1> <tr> <td width=5%><font id=thefont>Thugs:</td><td><?=commas($row['thug'])?></td> </tr><tr> <td><font id=thefont>Condoms:</td><td><?=commas($row['condoms'])?> </td> </tr><tr> <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?> </td> </tr><tr> <td><font id=thefont>Turns:</td><td><?=commas($row['turn'])?> </td> </tr><tr> <td><font id=thefont> Weed:</td><td><?=commas($row['weed'])?></td> </tr><tr> <td><font id=thefont> AK-47's:</td><td><?=commas($row['ak47'])?></td> </tr><tr> <td><font id=thefont> Beer:</td><td><?=commas($row['beer'])?></td> </tr><tr> <td><font id=thefont> Hoes:</td><td><?=commas($row['hoe'])?></td> </tr> </table> <? } print '<center> <font size="2">Thugkillin ©2006. All rights reserved.</font></center>'; } else { //If user is NOT logged in print "Sorry, not logged in please <A href='index.php'>Login</a><br>"; } ?> </body> </html> im not sure but i think is has something to do with $rs = mysql_query("SELECT * FROM km_users"); so can someone help me? if u have anyquestions just ask? cheers rawli RawliJr 07-09-2006, 01:27 AM anybody know why this isnt working? Fou-Lu 07-09-2006, 02:32 AM Ok, hold on lets take a look see. Now, I understand that you are trying to only view information about a specific person correct? To be more accurate, only the user who you are logged in yeah? Ok, I'm assuming that the $_SESSION['player'] is already set from somewhere, and is still potentially unclean. Simply modify your query to search for only values related to current player. Unfortunally, without knowing your table structure, I can only assume that you have it under 'playerid' for instance. // Your original states to select 'all' values from 'all users' $player = mysql_real_escape_string($_SESSION['player']); // Above is important indeed. $rs = mysql_query("SELECT * FROM `km_users` WHERE `playerid` = $player"); All done. You actually don't need to use a while loop in this circumstance, but might as well just leave it there anyway. Good luck. RawliJr 07-09-2006, 03:36 AM ok, that just posted a error <?php //Connect to the Database mysql_connect( 'Localhost', 'xxx', 'xxx' ); mysql_select_db( 'xxx' ); //Start Session session_start(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Main Menu</title> </head> <body> <link rel="stylesheet" type="text/css" href="style.css" /> <center><img src="/images/THUGKILLIN.jpg" border="0" width="444" /></a></center> <center> <?php if ( isset($_SESSION['player']) ) { //If player is logged in $player = $_SESSION['player']; //shorthand echo '<h3>' . $player . '. </h3>'; echo '<br><br>'; echo ' </center> <div class="aaa"> <a href="store.php">Corner Store</a> <br><br> <a href="nranks.php">National Ranks</a> <br> <a href="cranks.php">City Ranks</a> <br> <a href="aranks.php">Attack Ranks</a> <br><br> <a href="http://thugkillin.forumco.com/default.asp"target="_blank">Forums</a> </div> <div class="bbb"> <a href="turntrick.php">Turn Tricks</a> <br><br> <a href="faqs.php">Faqs</a> <br><br> <a href="preferences.php">Preferences</a> <br><br> <a href="poll.php">Poll</a> <br><br> <a href="credits.php">Purchase Turns</a> <br><br> <a href="http://www.thugkillin.urlshort.com">LogOut</a> </div><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><center><a href="console.php">Console</a></center><br><br> '; function commas($arg) { return $arg; } // Your original states to select 'all' values from 'all users' $player = mysql_real_escape_string($_SESSION['player']); // Above is important indeed. $rs = mysql_query("SELECT * FROM `km_users` WHERE `playerid` = $player"); while ($row=mysql_fetch_assoc($rs)) { ?> <table width=50% cellspacing=2 cellpadding=1> <tr> <td width=5%><font id=thefont>Thugs:</td><td><?=commas($row['thug'])?></td> </tr><tr> <td><font id=thefont>Condoms:</td><td><?=commas($row['condoms'])?> </td> </tr><tr> <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?> </td> </tr><tr> <td><font id=thefont>Turns:</td><td><?=commas($row['turn'])?> </td> </tr><tr> <td><font id=thefont> Weed:</td><td><?=commas($row['weed'])?></td> </tr><tr> <td><font id=thefont> AK-47's:</td><td><?=commas($row['ak47'])?></td> </tr><tr> <td><font id=thefont> Beer:</td><td><?=commas($row['beer'])?></td> </tr><tr> <td><font id=thefont> Hoes:</td><td><?=commas($row['hoe'])?></td> </tr> </table> <? } print '<center> <font size="2">Thugkillin ©2006. All rights reserved.</font></center>'; } else { //If user is NOT logged in print "Sorry, not logged in please <A href='index.php'>Login</a><br>"; } ?> </body> </html> like i can log in and everything but where the table should be it shows this error Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/thugki/public_html/index3.php on line 56 and it probobly has to something with this line $rs = mysql_query("SELECT * FROM `km_users` WHERE `playerid` = $player"); because i dont have a field called 'playerid' this is what is under km_users ID bigint(21) No auto_increment username varchar(15) latin1_swedish_ci No password varchar(255) latin1_swedish_ci No email varchar(255) latin1_swedish_ci No turn int(10) UNSIGNED No 250 dead varchar(255) latin1_swedish_ci No killer varchar(255) latin1_swedish_ci No numberattck bigint(20) No 0 justattacked int(4) No 0 honor int(11) No 0 lastaction bigint(20) No 0 Money bigint(20) No 9000 condoms bigint(20) UNSIGNED No 100 crack bigint(20) UNSIGNED No 100 weed bigint(20) UNSIGNED No 100 beer bigint(20) UNSIGNED No 100 ak47 bigint(50) No 1 hoe bigint(50) UNSIGNED No 1 thug bigint(50) No 1 dffarmy bigint(6) No 0 science bigint(20) No 0 validated int(11) No 0 validkey varchar(255) latin1_swedish_ci No numturns bigint(20) No 0 so i dont know what i should do now? i tried this switch but it didnt work? $rs = mysql_query("SELECT * FROM `km_users` WHERE `playerid` = $player"); to $rs = mysql_query("SELECT * FROM `km_users` WHERE `username` = $player"); cheers:thumbsup: Rawlijr Fou-Lu 07-09-2006, 09:14 PM Heres the thing. If the query works without the conditionals, showing all users in the database, but does not show with the conditional, something is incorrect with the conditional. Since your structure uses `username` as your field, and assumably that is to match your $_SESSION['player'], this tells me that $_SESSION['player'] is either unset, or null value. You can test this by first changing your conditional to: `username` <> '', if it outputs all records, you know that its your $player either not being set, or being set incorrectly. If this is the case, you need to deterimine where your $_SESSION is sitting at. If you have problems with setting sessions, check your current ini configurations for this. You will want to allow cookies, not use cookies only, and enable your transid. These configurations are not defaulted within the php.ini, and this could be the root source of your troubles. RawliJr 07-10-2006, 12:38 AM i dont get what you mean? due 07-10-2006, 02:14 AM dont fell bad i dont either :D |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum