Badge Shop SQL needed,

Results 1 to 7 of 7
  1. #1
    Sorcerer Supreme QuixFounder is offline
    Member +Rank
    Aug 2012 Join Date
    United KingdomLocation
    284Posts

    Badge Shop SQL needed,

    Hey guys i have my badge shop but i havnt got a SQL for it and i keep getting errors, would someone me able to make me a SQL please,? asap thanks

    My Badge.php:
    Spoiler:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>Blur-Hotel - Badge Shop</title>

    <link rel="stylesheet" href="{url}/app/tpl/skins/Habbo/styles/common.css" type="text/css">
    <script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/libs2.js"></script>
    <script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/visual.js"></script>
    <script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/libs.js"></script>
    <script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/common.js"></script>
    <script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/fullcontent.js"></script>
    <link rel="shortcut icon" href="http://blurhotel.tk/images/favicon.ico">



    <script type="text/javascript">
    document.habboLoggedIn = true;
    var habboName = "{username}";
    var habboId = {userid};
    var habboReqPath = "";
    var habboStaticFilePath = "{url}/app/tpl/skins/Habbo";
    var habboImagerUrl = "http://www.habbo.com/habbo-imaging/";
    var habboPartner = "";
    var habboDefaultClientPopupUrl = "{url}/client";
    window.name = "habboMain";
    if (typeof HabboClient != "undefined") {
    HabboClient.windowName = "eac955c8dbc88172421193892a3e98fc7402021a";
    HabboClient.maximizeWindow = true;
    }
    </script>

    <!--[if IE 8]>
    <link rel="stylesheet" href="{url}/app/tpl/skins/Habbo/styles/ie8.css" type="text/css">
    <![endif]-->
    <!--[if lt IE 8]>
    <link rel="stylesheet" href="{url}/app/tpl/skins/Habbo/styles/ie.css" type="text/css" />
    <![endif]-->
    <!--[if lt IE 7]>
    <link rel="stylesheet" href="{url}/app/tpl/skins/Habbo/styles/ie6.css" type="text/css" />
    <script type="text/javascript" src="{url}/app/tpl/skins/Habbo/js/pngfix.js"></script>
    <script type="text/javascript">
    try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}
    </script>
    <style type="text/css">
    body { behavior: url({url}/app/tpl/skins/Habbo/js/csshover.htc); }
    </style>
    <![endif]-->
    </head>

    <body id="home">

    <div id="overlay"></div>
    <div id="header-container">
    <div id="header" class="clearfix">
    <h1><a href="{url}/"></a></h1>
    <div id="subnavi">
    <div id="subnavi-user">
    <div style="margin-top:7px"><b>Welcome back to Blur-Hotel</b>, <i>{username}!</i> </div>
    </div>
    <div id="subnavi-search">
    <div id="subnavi-search-upper">
    <ul id="subnavi-search-links">
    <li><a href="{url}/logout" style="color:#000">Sign Out</a></li>
    <li><a href="{url}/privacy" style="color:#000">Privacy</a></li>
    </ul>
    </div>
    </div>
    <div id="to-hotel">
    <a href="{url}/api.php" class="new-button green-button" target="eac955c8dbc88172421193892a3e98fc7402021a" onClick="HabboClient.openOrFocus(this); return false;"><b>Enter {hotelName}</b><i></i></a>
    </div>
    </div>
    <ul id="navi">
    <li class="metab"><a href="{url}/me">{username}</a><span></span></li>
    <li><a href="{url}/community">Community</a><span></span></li>
    <li><a href="{url}/vip">Store</a><span></span></li>
    <li><a href="http://blurfounder.moonfruit.com/" target="_blank">Forums</a><span></span></li>
    <li class="selected"><a href="{url}/badge">Badge Store</a><span></span></li>
    <li><a href="https://www.facebook.com/" target="_blank">Facebook</a><span></span></li>
    <?php if(mysql_result(mysql_query("SELECT rank FROM users WHERE id = '" . $_SESSION['user']['id'] . "'"), 0) >= 5) { ?>
    <li><a href="{url}/ase">Housekeeping</a><span></span></li>
    <?php
    }
    ?>
    <div id="habbos-online"><div class="rounded"><span>{online}<br> Members Online!</span></div></div>
    </div>
    </div>
    <div id="content-container">

    <div id="navi2-container" class="pngbg">
    <div id="navi2" class="pngbg clearfix">
    <ul>
    <li class="selected">
    Badge Store
    </li>

    </ul>
    </div>
    </div>

    <?php
    $link = mysql_connect("localhost", "root", "blur");
    mysql_select_db("testing", $link);
    $result = mysql_query("SELECT * FROM badge_store", $link);
    $num_rows = mysql_num_rows($result);
    ?>

    <div id="container">
    <div id="content" style="position: relative" class="clearfix">
    <div id="column1" class="column">
    <div class="habblet-container ">
    <div class="cbb clearfix {colour} ">
    <h2 class="title">Badge Shop - <?php echo "$num_rows"; ?> Badges</h2>
    <div style="padding:5px">
    <table>


    <?php
    $query = mysql_query("SELECT * FROM `badge_store` ");
    while($result = mysql_fetch_array($query)) {
    $badgeCodes = $result["badgeid"];
    $badgeCosts = $result["badgecost"];
    ?>

    <?php
    $subCode = $_GET['id'];
    if(isset($subCode)){

    $badgeExsist = false;

    if($subCode == $badgeCodes){

    // Check to see if user has badge
    $hasBadgeCheck = mysql_query('SELECT * FROM user_badges WHERE user_id = '.$_SESSION['user']['id'].' AND badge_id = "'.$badgeCodes.'"')or die(mysql_error());

    if(mysql_num_rows($hasBadgeCheck) < 1){
    // check pixels
    $pixelCheck = mysql_query('SELECT * FROM users WHERE id = '.$_SESSION['user']['id'].'')or die(mysql_error());
    $gotPixelCheck = mysql_fetch_assoc($pixelCheck);
    if($gotPixelCheck['activity_points'] >= $badgeCosts){

    $removePixels = mysql_query('UPDATE users SET activity_points = activity_points - '.$badgeCosts.' WHERE id = '.$_SESSION['user']['id'].'')or die(mysql_error());
    $giveUserBadge = mysql_query('INSERT INTO user_badges (user_id, badge_id) VALUES ('.$_SESSION['user']['id'].',"'.$badgeCodes.'")')or die(mysql_error());

    $_SESSION['user']['activity_points'] = $_SESSION['user']['activity_points'] - $badgeCosts;

    echo '<div id="badge-container-error" style="background-color:green;"><center><font color="white"> You have recived the badge! You may have to reload.</font></center></div>';
    break;

    }

    else{

    // You don't have enough pixels
    echo '<div id="badge-container-error">You do not have enough pixels.</div>';

    }

    }
    else{
    // You have badge
    echo '<div id="badge-container-error">You already have this badge.</div>';
    }

    break;
    }
    }

    }


    $query = mysql_query("SELECT * FROM `users` WHERE id = '" . $_SESSION['user']['id'] . "'");
    while($result = mysql_fetch_array($query)) {
    $onlinecheck = $result["online"];

    if($onlinecheck == "1")
    {
    echo "You cannot buy badges while you are logged in. Please logout first.";
    } else {

    echo "<table>";
    echo "<tr><td><strong>Badge</strong></td><td><strong>Badge Name</strong></td><td><strong>Cost</strong></td><td><strong>Buy</strong></td></tr>";

    $query = mysql_query("SELECT * FROM `badge_store` ");
    while($result = mysql_fetch_array($query)) {
    $badgeCodes2 = $result["badgeid"];
    $badgeCosts2 = $result["badgecost"];

    echo '
    <tr>
    <td width="50%">
    <img src="/r63/c_images/album1584/'.$badgeCodes2.'.gif"/>
    <br/>
    </td>
    <td width="10%">
    <center><strong>'.$badgeCodes2.'</strong></center>
    </td>
    <td width="10%">
    <center>'.$badgeCosts2.' Pixels</center>
    </td>
    <td width="30%">
    <center><a href="{url}/index.php?url=badge&id='.$badgeCodes2.'"><input type="submit" href="{url}/index.php?url=badge&id='.$badgeCodes2.'" value="Buy Now"/></a></center>
    </td>
    </tr>
    ';
    } } }
    echo '</table>';
    ?>
    </div></div>
    </div>
    </div>




    <div id="column2" class="column">
    <div class="habblet-container ">
    <div class="cbb clearfix pixellightblue ">
    <h2 class="title">About the Badge Shop</h2>
    <div style="padding:5px">
    <center>
    You can buy badges here for your ingame credits and pixels. Badges are a way of showing your personality, or how popular you are inside the hotel, buy a badge today!
    </center>
    </div>
    </div>
    </div>
    </div>
    <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>



    <?php
    $query = mysql_query("SELECT * FROM `users` WHERE id = '" . $_SESSION['user']['id'] . "'");
    while($result = mysql_fetch_array($query)) {
    $onlinecheck = $result["online"];
    if($onlinecheck == "0")
    {
    ?>


    <div id="column2" class="column">
    <div class="habblet-container ">
    <div class="cbb clearfix {colour} ">
    <h2 class="title">My Stats</h2>
    <div style="padding:5px">
    <center>
    <img src='http://www.habbo.fr/habbo-imaging/avatarimage?figure={figure}&action=wav&direction=3&head_direction=3&gesture=s&size=l'/>
    <hr>
    <table>
    <tr>
    <td>
    <strong>Coins:</strong></td><td><?php echo $_SESSION['user']['credits']; ?>
    </td>
    </tr>
    <tr>
    <td>
    <strong>Pixels:</strong></td><td><?php echo $_SESSION['user']['activity_points']; ?>
    </td>
    </tr>
    <tr>
    <td>
    <strong>Rank:</strong></td><td>{rank}
    </td>
    </tr>
    </table>
    </center>
    </div>

    <?php
    } }
    ?>
    </div>
    </div>
    </div>
    <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
    </div>
    </div>
    </div>

    </div>
    </body></html>


  2. #2
    The Omega Superfun is offline
    Grand MasterRank
    Dec 2006 Join Date
    The NetherlandsLocation
    5,221Posts

    Re: Badge Shop SQL needed,

    Please post the actual errors.

  3. #3
    Sorcerer Supreme QuixFounder is offline
    Member +Rank
    Aug 2012 Join Date
    United KingdomLocation
    284Posts

    Re: Badge Shop SQL needed,

    Here you go: ( I need the SQL you run into the database )

  4. #4
    The Omega Superfun is offline
    Grand MasterRank
    Dec 2006 Join Date
    The NetherlandsLocation
    5,221Posts

    Re: Badge Shop SQL needed,

    $link = mysql_connect("localhost", "root", "blur");
    mysql_select_db("testing", $link);


    Is this the correct login plus database name?
    Line 102+103

  5. #5
    Sorcerer Supreme QuixFounder is offline
    Member +Rank
    Aug 2012 Join Date
    United KingdomLocation
    284Posts

    Re: Badge Shop SQL needed,

    Yes that is correct,

  6. #6
    I don't even know azaidi is offline
    Grand MasterRank
    Apr 2010 Join Date
    the NetherlandsLocation
    2,065Posts

    Re: Badge Shop SQL needed,

    Table badge_store {
    primary int id
    string badgeid
    int badgecost
    }

    Just create the table yourself and add some badges

  7. #7
    Sorcerer Supreme QuixFounder is offline
    Member +Rank
    Aug 2012 Join Date
    United KingdomLocation
    284Posts

    Re: Badge Shop SQL needed,

    Already solved but thanks ill give you some rep for helping! ( close thread please )



Advertisement