PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 300,441 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,524 people online right now. Registration is fast and FREE... Join Now!




Php Error ( just refreshing)

 

Php Error ( just refreshing)

nick1200

3 Jul, 2009 - 01:46 PM
Post #1

D.I.C Addict
****

Joined: 21 Mar, 2009
Posts: 551



Thanked: 6 times
My Contributions
i have posted this be for but i have re posted cus i relay wanna get this done to night

i have a rpg a pokemon rpg the problem is the user has 6 main pokemon that they can use but i wanna make a box ( a computer or something 0

so when they don't wanna use them 6 they can put them into user_box and get different 1s out

the problem i have is the 6 slots are stored in sessions has well has the db

i have got some 1 to make me a sell page which does the same job has what i want the user box to do

this is my new code i just coded up


user_box_send.php
CODE


?php
                        // show the user their pokemon
                        include_once('pokemon_level.php');
                        // end file include
                    ?>
            </div>
            
            <div class="mid_box">
                <div class="mid_box_title">Want to Send your pokemon To Your Box ?</div>
                <p>
                  <script>
                $(document).ready(function(){                    
                    $("select#pokeSLOT").change(function () {
                        $("button#Submit_But").text("Sell " + $("select#pokeSLOT option:selected").text());
                    });
                    
                    $("button#Submit_But").click(function () {
                        var theSlot = $("select#pokeSLOT option:selected").val();
                        var sellPokemon = $("select#pokeSLOT option:selected").text();
                        
                        
                        if (theSlot == "" || sellPrice == "") { alert("Required fields were left blank."); return false;}
                        
                        confMes = confirm("You are about to attempt to send " + send + " for " + sellPrice + ". Are you sure?");
                        if (confMes) {
                            $.post("/phpDocs/User_box.php", {
                                mode: "sendPokemon",
                                pokemonName: sellPokemon,
                                sellPrice: sellPrice,
                                User: "<?php echo $_SESSION['username']; ?>",
                                pokemonSlot: theSlot
                                },
                            
                                function(data){
                                    alert(data);
                                    window.location.href="/BuyPokemon.php";
                                }
                            );
                            return false;
                        } else {
                            alert("CANCELLED");
                            return false;
                        }
                    });
                    
                });
                </script>
                  
                  Note: This is just been made so There Mite Be Some Errors <br />
              </p>
                <form>
                <label>What slot do you want to Send To Box ?</label>
                <select name="pokeSLOT" id="pokeSLOT" style="width:150px;padding-left:5px;">
                    <option value=""></option>
                    <?php
                    for ($x=1;$x<7;$x++) {
                        if (isset($pokemon->{pok . $x}['pokeNAME'])) {
                            echo '<option value="'.$x.'">'.$pokemon->{pok . $x}['pokeNAME'].'</option>';
                        } else {
                            echo '<option value=""></option>';
                        }
                    }
                    ?>
                </select>
                <br/>
                <br/>
                <label></label>
                <br/>
                <br/>
                    <button name="submit" type="submit" id="Submit_But">send</button>
            </form>    
            
                <div style="clear:both;"></div>
            </div>
        </div>                
    </div>




that lets the user pick what slot they want to sell but i was gonna change it to add to box but then i looked at the main code of it

this is what ive changed it to so it sends the pokemon to user_box instead of poke_sell


User_box.php

CODE


        function execsendPokemon() {
            $sellName = $_POST['pokemonName'];
            $User = $_POST['User'];
            $slot = $_POST['pokemonSlot'];
            
            $info = "SELECT T1.pok".$slot."LV, T1.pok".$slot."EXP, T2.pokePIC FROM user_pokemon as T1
                    INNER JOIN pokemon as T2 ON (T2.pokeNAME = '".$sellName."')
                    WHERE userNAME = '".$User."' LIMIT 1";
            $inf = mysql_query($info) or ($this->errorHandler(mysql_error(). ' INFO'));
            $in = mysql_fetch_array($inf);
            
            $level = $in['pok'.$slot.'LV'];
            $exp   = $in['pok'.$slot.'EXP'];
            $pic   = $in['pokePIC'];
            
            $q = "INSERT INTO user_box
                (username, pokemon, pokePIC, time_stamp, level, exp)
                    VALUES
                ( '".$User."', '".$sellName."', '".$pic."', '".time()."', '".$level."', '".$exp."')";
            $r = mysql_query($q) or ($this->errorHandler(mysql_error(). ' INSERT'));
            if ($r) {
                $this->execRemoveFromUser($slot,$sellUser);
                echo "You have Added $sellName.";
            } else {
                echo "An error has occured in the selling of $sellName please try again later";
            }
        }
        
        function execRemoveFromUser($slot,$user) {
            $q = "UPDATE user_pokemon SET
                    pok".$slot."    = '0',
                    pok".$slot."LV  = '0',
                    pok".$slot."EXP = '0'
                    WHERE userNAME = '".$user."'";
            $r = mysql_query($q) or ($this->errorHandler(mysql_error(). ' Delete'));
        }            
        





can any 1 see why it ent working ?

This post has been edited by nick1200: 3 Jul, 2009 - 06:09 PM

User is offlineProfile CardPM
+Quote Post


nick1200

RE: Php Error ( Just Refreshing)

3 Jul, 2009 - 02:54 PM
Post #2

D.I.C Addict
****

Joined: 21 Mar, 2009
Posts: 551



Thanked: 6 times
My Contributions
found out were its maing the session now ive changed it so it adds the pokemon to a new table but ent working

i have edited the first post with my new code

which ent working



any 1 ?

This post has been edited by nick1200: 3 Jul, 2009 - 03:16 PM
User is offlineProfile CardPM
+Quote Post

nick1200

RE: Php Error ( Just Refreshing)

4 Jul, 2009 - 04:22 AM
Post #3

D.I.C Addict
****

Joined: 21 Mar, 2009
Posts: 551



Thanked: 6 times
My Contributions


can any 1 help or not ?
User is offlineProfile CardPM
+Quote Post

noorahmad

RE: Php Error ( Just Refreshing)

4 Jul, 2009 - 04:54 AM
Post #4

Webmaster
Group Icon

Joined: 12 Mar, 2009
Posts: 2,018



Thanked: 125 times
Dream Kudos: 1350
My Contributions
can you tell me what is your error? i mean in which line?
User is online!Profile CardPM
+Quote Post

nick1200

RE: Php Error ( Just Refreshing)

4 Jul, 2009 - 05:00 AM
Post #5

D.I.C Addict
****

Joined: 21 Mar, 2009
Posts: 551



Thanked: 6 times
My Contributions


it don't tell me the line


i pick what pokemon i want to send to the user_box and click the button and it just refreshes

so i think the error is on

user_box_send.php


user_box_send.php grabs the info the pokemon etc



and User_box.php is the database side of it which adds it to the database
User is offlineProfile CardPM
+Quote Post

noorahmad

RE: Php Error ( Just Refreshing)

4 Jul, 2009 - 05:08 AM
Post #6

Webmaster
Group Icon

Joined: 12 Mar, 2009
Posts: 2,018



Thanked: 125 times
Dream Kudos: 1350
My Contributions
change your this code
php
            $sellName = $_POST['pokemonName'];
$User = $_POST['User'];
$slot = $_POST['pokemonSlot'];


to

php
            $sellName = $_POST['pokemonName'];
$User = $_SESSION['User'];
$slot = $_POST['pokeSLOT'];


User is online!Profile CardPM
+Quote Post

nick1200

RE: Php Error ( Just Refreshing)

4 Jul, 2009 - 05:13 AM
Post #7

D.I.C Addict
****

Joined: 21 Mar, 2009
Posts: 551



Thanked: 6 times
My Contributions


still not working mate

no errors just refreshing
User is offlineProfile CardPM
+Quote Post

nick1200

RE: Php Error ( Just Refreshing)

4 Jul, 2009 - 09:20 AM
Post #8

D.I.C Addict
****

Joined: 21 Mar, 2009
Posts: 551



Thanked: 6 times
My Contributions
any 1 else ?

cus i cant see the error don't know why it just refreshes and don't do anything
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 01:23AM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month