...

View Full Version : Trying for a one time event



king2k5
01-10-2008, 10:32 PM
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.


$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.

Death_oClock
01-10-2008, 11:10 PM
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.

king2k5
01-10-2008, 11:32 PM
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:



$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);


}

}

bazz
01-10-2008, 11:34 PM
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

king2k5
01-10-2008, 11:37 PM
nah, that shouldnt make a difference, i use single quotes in all my queries

king2k5
01-11-2008, 04:41 PM
can anyone help?

andre3
01-11-2008, 05:05 PM
mate i may be able to help you.. but i dnt quite understand fully what you are saying



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum