1 (edited by towelie 2007-05-27 14:16)

Topic: You're a genious if you figure this out

code removed

Re: You're a genious if you figure this out

Rather than telling you...
go and have a look at:
http://www.php.net/manual/en/function.header.php

followed by
http://www.php.net/manual/en/function.ob-start.php

as it may be needed.


and if that doesn't help, ask again!

my mind is on a permanent tangent
byUsers forum

Re: You're a genious if you figure this out

redirect($_SERVER['HTTP_REFERER'], 'Form processed');

4 (edited by towelie 2007-05-27 14:16)

Re: You're a genious if you figure this out

code removed

Re: You're a genious if you figure this out

Erm, do you get any errors? Have you tried my code?

Re: You're a genious if you figure this out

The redirect is working absolutely fine.
I used a print_r($_GET) to see if its actually grabbing the form inputs. It is only grabbing the imatch_id the rest are fukt idk y.

<form method="get" action="new_ichallenge.php" >
    <center>
        <input type="hidden" value="" id="imatch_id" name="imatch_id">
        <input type="hidden" value="<?php $pun_user['username']?>" id="playera" name="playera">
        <input type="hidden" value="<?php $line['username']?>" id="playerb" name="playerb">
        <input type="submit" value="Challenge Player" name="submit">
    </center>
</form>

Re: You're a genious if you figure this out

<form method="get" action="new_ichallenge.php" >
    <center>
        <input type="hidden" value="" id="imatch_id" name="imatch_id">
        <input type="hidden" value="<?php echo $pun_user['username']?>" id="playera" name="playera">
        <input type="hidden" value="<?php echo $line['username']?>" id="playerb" name="playerb">
        <input type="submit" value="Challenge Player" name="submit">
    </center>
</form>

Re: You're a genious if you figure this out

Smartys you are a genious... That helped me out with something I was working on... ;-)

9 (edited by towelie 2007-05-27 14:17)

Re: You're a genious if you figure this out

code removed

Re: You're a genious if you figure this out

if (isset($_POST['submit']))
{ 
    if ($pun_user['is_guest'])
        message($lang_common['No permission']);

    $imatch_id = isset($_POST['imatch_id']) ? intval($_POST['imatch_id']) : 0;
    $playera = isset($_POST['playera']) ? intval($_POST['playera']) : 0;
    $playerb = isset($_POST['playerb']) ? intval($_POST['playerb']) : 0;


    $db->query('INSERT INTO '.$db->prefix.'ladders (imatch_id, playera, playerb) VALUES ('.$imatch_id.', '.$playera.', '.$playerb.')') or error('Unable to create new challenge', __FILE__, __LINE__, $db->error());
}

I'm not exactly sure what the first query was supposed to do (since it was never being used), so I removed it
I also simplified the code a bit and made it use the $db layer properly

11 (edited by towelie 2007-05-26 18:27)

Re: You're a genious if you figure this out

playera and b is not intval though?

First query I didn't really know how to use. It was to try to check for the current value of imatch id which is set as primary key and auto incrememnt in the table i created for this thing. (ladders table)

Re: You're a genious if you figure this out

Then replace intval with $db->escape for those two.

Re: You're a genious if you figure this out

if (isset($_POST['submit']))
{ 
    if ($pun_user['is_guest'])
        message($lang_common['No permission']);

    $imatch_id = isset($_POST['imatch_id']) ? intval($_POST['imatch_id']) : 0;
    $playera = $db->escape($_POST['playera']);
    $playerb = $db->escape($_POST['playerb']);


    $db->query('INSERT INTO '.$db->prefix.'ladders (imatch_id, playera, playerb) VALUES ('.$imatch_id.', "'.$playera.'", "'.$playerb.'")') or error('Unable to create new challenge', __FILE__, __LINE__, $db->error());
}

OK, here

Re: You're a genious if you figure this out

Smartys <3
Seriously! Thank you so much buddy.

Re: You're a genious if you figure this out

Taken from the topic I closed:

towelie wrote:
<?php 
    // query to set up appropriate player challenges
    $query = "SELECT * FROM punbb2_ladders WHERE imatch_id=$imatch_id";
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
    $imatch_id = (int)$_GET['imatch_id'];
                    
?>
<br />
<?php echo $line['username'].'\'s pending challenges:' ?></dt><br />
<?php 
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
    { if ($row['playerb'] == $line['username']) { echo $row['playera'].'has a challenge against'.$row['playerb'].'(awaiting winner)'; 
    } else     { echo 'No current challenges'; }
}
?>

I am trying to take that information that we INSERT from the thread "You're a genious if you figure this out", and display it on a page. The page is a custom user profile page; already set up. I am having trouble displaying the data. Any suggestions? Im pretty tired so Ima check this later. Replies plz wink

Again, do not use MySQL specific features, use $db.

<?php 
    // query to set up appropriate player challenges
    $imatch_id = intval($_GET['imatch_id']); 
    $result = $db->query("SELECT * FROM ".$db->prefix."ladders WHERE imatch_id=$imatch_id") or error('Query failed', __FILE__, __LINE__, $db->error());

?>
<br />
<?php echo $line['username'].'\'s pending challenges:' ?></dt><br />
<?php 

    while ($row = $db->fetch_assoc($result))
    {
        if ($row['playerb'] == $line['username'])
        {
            echo $row['playera'].'has a challenge against'.$row['playerb'].'(awaiting winner)'; 
        }
        else
        {
            echo 'No current challenges';
        }
    }
?>

The if statement in the while loop doesn't make much sense to me, but I'm not really sure what a lot of the stuff in this code is for tongue

16 (edited by towelie 2007-05-26 20:41)

Re: You're a genious if you figure this out

Okay I will try to explain my goal..
I am trying to display challenges. Here is an example of a page they will be displayed on.

I will make comments in the script..

<?php 
    // query to set up appropriate player challenges
    $imatch_id = intval($_GET['imatch_id']); 
    $result = $db->query("SELECT * FROM ".$db->prefix."ladders WHERE imatch_id=$imatch_id") or error('Query failed', __FILE__, __LINE__, $db->error());

?>
<br />
<?php echo $line['username'].'\'s pending challenges:' ?></dt><br />
<?php 
    //while loop here could be totally wrong,  using to examine all matches listed....
    while ($row = $db->fetch_assoc($result))
    {
        //if there is a match listed where the playerb's name is equal to the name of the player whose profile page it is ($line['username']) then it will show this match 
        if ($row['playerb'] == $line['username'])
        {
       //when it finds above, it lists the playera and the playerb for that match
            echo $row['playera'].'has a challenge against'.$row['playerb'].'(awaiting winner)'; 
        }
        else
        {
       //if these possibilities do not occur then echo no current challenges
            echo 'No current challenges';
        }
    }
?>

Re: You're a genious if you figure this out

I have no clue what imatch_id is or why you're getting it from GET when it seems what you want to do is get the matches where the player whose profile is being viewed is a fighter

Re: You're a genious if you figure this out

L o L @ rollonequick: You challenged me to a battle I see in the database.
@smartys hmm lemme re-examine my code here.

19 (edited by rollonequick 2007-05-26 22:25)

Re: You're a genious if you figure this out

yea i clicked on it to try and figure out how it worked.....  there should be a message that gets sent back to me telling me that I challenged you..   so I would be able to keep track of my own challenges.....

then there should be a option to make it a free challenge or a money challenge... use with Cash mod...

then there should be a way so that both of the players have to choose the same outcome...

either you won or I won... but we would have to choose the same inorder for the win or loss to count....

I may be intrested in this script after you are done with it.. if you need some ideas for it I could help ya out there.. but i am kind of shit at PHP right now

20 (edited by towelie 2007-05-27 05:26)

Re: You're a genious if you figure this out

Well, I don't mind, and I have already worked out the database where playera and playerb must verify before scores update. I don't use cash mod at my site. I have been getting a couple other offers on this app aswell (around 100$usd). If you are interested, when its finished I can install it at your site for a price. (Even though it is my baby. t_T)

@ Smartys.. will I be able to copywright my work when it is finished?

Re: You're a genious if you figure this out

you should release it for free...just charge people if they need you to install it.. That is the "right way" to do it...

Re: You're a genious if you figure this out

Copyright? Yes. However, it's based off of PunBB and thus if you release it (as in, use it for more than just your own site) the rules of the GPL apply. Which mean you can charge as much as you want but you must provide the source for the mod for free (or for some reasonable price if you would incur expenses sending the code to the person, eg by mail) if someone asks you for it wink

23 (edited by towelie 2007-05-27 14:16)

Re: You're a genious if you figure this out

So If I were to create a completely seperated version of it from punbb then the rules of GPL do not apply?

Gameballa I know you are all over my code scraps in here.

Re: You're a genious if you figure this out

towelie wrote:

So If I were to create a completely seperated version of it from punbb then the rules of GPL do not apply?

Yes, if you were to make a standalone script that didn't tie into PunBB at all then it could be released under any license.

25 (edited by towelie 2007-05-28 01:08)

Re: You're a genious if you figure this out

(If I want to sell the script and it is tied into punbb then I have to give them my source free?) or (Do I just need to give them punbb's source? (Obviously I would never attempt to sell punbb, that is just plain f*kin ridiculous lol.))


- edit: figured out new code prob