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.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Trying for a one time event

    This is for an RPG game, when a person adventures, i have certain one-time adventures put in the database(for quests). Once a person has encountered this particular adventure, his username, and the id of the adventure is sent to a table(questadvinf). My trouble is that the adventure is not abiding the one-time only rule, and i have no idea why.

    PHP Code:
    $result120 mysql_query("SELECT * FROM questadvinf WHERE area='$area' AND username='".$userinf['username']."'"$db);
    if(
    mysql_num_rows($result120)) {

    while(
    $retval120 mysql_fetch_array($result120)){

    $result mysql_query("SELECT * FROM adventinf WHERE area='$area' AND id!='".$retval120['advent_id']."' ORDER BY RAND() LIMIT 1 "$db);
    $retval mysql_fetch_array($result);

    }
    }else{

    $result mysql_query("SELECT * FROM adventinf WHERE area='$area' ORDER BY RAND() LIMIT 1 "$db);
    $retval mysql_fetch_array($result);


    I've tried so many different ways, and I just cant seem to figure it out.. any help would be greatly appreciated.

  • #2
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm not entirely sure what you mean by 'not abiding by', perhaps you could clarify. But, you used the term 'sent to', and I don't see a single insert statement. All this code does is read information, not add any to a database.

  • #3
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts
    not abiding by means that its not following the one-time only rule... its happening more than one time.. and the sent to database stuff i felt to be irrelevant, because it works, but if it helps, here is the entire code:

    PHP Code:
    $result1337 mysql_query("SELECT * FROM attackminf WHERE username='".$userinf['username']."'"$db);



    $result120 mysql_query("SELECT * FROM questadvinf WHERE area='$area' AND username='".$userinf['username']."'"$db);
    if(
    mysql_num_rows($result120)) {

    while(
    $retval120 mysql_fetch_array($result120)){

    $result mysql_query("SELECT * FROM adventinf WHERE area='$area' AND id!='".$retval120['advent_id']."' ORDER BY RAND() LIMIT 1 "$db);
    $retval mysql_fetch_array($result);

    }
    }else{

    $result mysql_query("SELECT * FROM adventinf WHERE area='$area' ORDER BY RAND() LIMIT 1 "$db);
    $retval mysql_fetch_array($result);

    }





    if(isset(
    $_POST['attack_id'])){
    $id $_POST['attack_id'];
    }elseif(isset(
    $_POST['item_id'])){
    $id $_POST['item_id'];
    }elseif(isset(
    $_POST['run_id'])){
    $id $_POST['run_id'];
    }elseif(
    mysql_num_rows($result1337)) {
    $retval1337 mysql_fetch_array($result1337);
    $id $retval1337['monster_id'];
    }else{
    $id $retval['id'];
    }



    $result mysql_query("SELECT * FROM adventinf WHERE id='$id'"$db);
    if(
    mysql_num_rows($result)) {
    $retval mysql_fetch_array($result);

    if(
    $retval['type'] == 'noncombat' && !isset($_POST['attack_id'])){

    if(
    $retval['once_only'] == 'yes'){

    mysql_query("INSERT INTO questadvinf(username,advent_id,area) VALUES ('".$userinf['username']."','".$retval['id']."','".$retval['area']."')"$db);


    }



  • #4
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    heh I am only a beginner here so I cold be way off but, should the $vars such as $area be in "" double quotes?

    bazz

  • #5
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts
    nah, that shouldnt make a difference, i use single quotes in all my queries

  • #6
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts
    can anyone help?

  • #7
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    mate i may be able to help you.. but i dnt quite understand fully what you are saying


  •  

    Posting Permissions

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