Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 27
  1. #1
    Regular Coder
    Join Date
    May 2006
    Location
    Canada
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Showing Mysql tables?

    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
    Rawli

  • #2
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am confused too. maybe you want to run the query:
    Code:
    SHOW TABLES
    ultimately, I have no idea what you're asking.

  • #3
    Regular Coder
    Join Date
    May 2006
    Location
    Canada
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts
    like what i want to so is something like this

    PHP Code:
    <?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])?>&nbsp;</td>
          </tr><tr>;
           <td><font id=thefont>Crack:</td><td><?=commas($km_users[crack])?>&nbsp;</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?
    Rawli

  • #4
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    something like this?
    PHP Code:
    <?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'])?>&nbsp;</td>
          </tr><tr>
           <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?>&nbsp;</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>
    <?
    }
    ?>

  • #5
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by fci
    something like this?
    PHP Code:
    <?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'])?>&nbsp;</td>
          </tr><tr>
           <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?>&nbsp;</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?"

  • #6
    Regular Coder
    Join Date
    May 2006
    Location
    Canada
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy

    yup but that puts a error

    this is my whole code includeing that one


    PHP 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> 

    <?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'])?>&nbsp;</td>
          </tr><tr>
           <td><font id=thefont>Crack:</td><td><?=commas($row['
    crack'])?>&nbsp;</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 &copy;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?
    Rawli

  • #7
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    .....
            <
    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 ';

  • #8
    Regular Coder
    Join Date
    May 2006
    Location
    Canada
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok thanx, now it posts anyother error...

    Code:
    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> ';
    Rawli

  • #9
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 Code:
    <?php

    <?php

    ?>
    the above should produce a similar error which is easier to debug now that you can see the big picture.

  • #10
    Regular Coder
    Join Date
    May 2006
    Location
    Canada
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 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'])?>&nbsp;</td>
          </tr><tr>
           <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?>&nbsp;</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 &copy;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>
    Rawli

  • #11
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    }
    print 
    '<center>
            <font size="2">Thugkillin &copy;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.

  • #12
    Regular Coder
    Join Date
    May 2006
    Location
    Canada
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs down same Error

    new code once AGAIN and ERROR again

    PHP 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'])?>&nbsp;</td>
          </tr><tr>
           <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?>&nbsp;</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 &copy;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
    Rawli

  • #13
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    alright, I decided to actually open it up and make it have no syntax errors:
    PHP 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'])?>&nbsp;</td>
          </tr><tr>
           <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?>&nbsp;</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 &copy;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.

  • #14
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey you need to escape the quotations on your HTML attributes.

    so...
    Code:
    <font size="1">
    within the print method should be
    Code:
    <font size=\"1\">
    ... If you don't fix that, it will definately give you a parse error.

    Quote Originally Posted by RawliJr
    new code once AGAIN and ERROR again

    PHP 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'])?>&nbsp;</td>
          </tr><tr>
           <td><font id=thefont>Crack:</td><td><?=commas($row['crack'])?>&nbsp;</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 &copy;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

  • #15
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    he only needs to escape it if he does it like this:
    Code:
    print "<font =\"1\">";
    not if he does
    Code:
    print '<font ="1">';


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •