Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-10-2008, 09:32 PM   PM User | #1
king2k5
Regular Coder

 
Join Date: Jan 2006
Posts: 189
Thanks: 1
Thanked 0 Times in 0 Posts
king2k5 is an unknown quantity at this point
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.
king2k5 is offline   Reply With Quote
Old 01-10-2008, 10:10 PM   PM User | #2
Death_oClock
New to the CF scene

 
Join Date: Jan 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Death_oClock is an unknown quantity at this point
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.
Death_oClock is offline   Reply With Quote
Old 01-10-2008, 10:32 PM   PM User | #3
king2k5
Regular Coder

 
Join Date: Jan 2006
Posts: 189
Thanks: 1
Thanked 0 Times in 0 Posts
king2k5 is an unknown quantity at this point
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);


}


king2k5 is offline   Reply With Quote
Old 01-10-2008, 10:34 PM   PM User | #4
bazz
Master Coder

 
Join Date: Apr 2003
Location: in my house
Posts: 5,211
Thanks: 39
Thanked 201 Times in 197 Posts
bazz will become famous soon enoughbazz will become famous soon enough
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
bazz is offline   Reply With Quote
Old 01-10-2008, 10:37 PM   PM User | #5
king2k5
Regular Coder

 
Join Date: Jan 2006
Posts: 189
Thanks: 1
Thanked 0 Times in 0 Posts
king2k5 is an unknown quantity at this point
nah, that shouldnt make a difference, i use single quotes in all my queries
king2k5 is offline   Reply With Quote
Old 01-11-2008, 03:41 PM   PM User | #6
king2k5
Regular Coder

 
Join Date: Jan 2006
Posts: 189
Thanks: 1
Thanked 0 Times in 0 Posts
king2k5 is an unknown quantity at this point
can anyone help?
king2k5 is offline   Reply With Quote
Old 01-11-2008, 04:05 PM   PM User | #7
andre3
New to the CF scene

 
Join Date: Jan 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
andre3 is an unknown quantity at this point
mate i may be able to help you.. but i dnt quite understand fully what you are saying
andre3 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:26 AM.


Advertisement
Log in to turn off these ads.