PDA

View Full Version : What Wrong With This Code


wolfe
09-08-2002, 10:55 PM
i am making a riddle answers hack

but this code is playing up



if (($threadinfo[forumid]) && $isfirst) {
if (($answer1 == '') && ($answer2 == '') && ($answer3 == '')) {
$DB_site->query("DELETE FROM riddle WHERE threadid='$threadid'");
} else {
$riddle=$DB_site->query_first("SELECT answer1,answer2,answer3 from riddle WHERE threadid=$threadid");
if (($riddle['answer1'] != '') && ($riddle['answer2'] != '') && ($riddle['answer3'] != '')) {
$DB_site->query("UPDATE riddle SET answer1='".addslashes($answer1)."',answer2='".addslashes($answer2)."',answer3='".addslashes($answer3)."' WHERE threadid='$threadid'");
} else {
$DB_site->query("INSERT INTO riddle (threadid,answer1,answer2,answer3) VALUES('$threadid','".addslashes($answer1)."','".addslashes($answer2)."'),'".addslashes($answer3)."'");
}
}
}



The problem is i am trying it out to edit the answers but it DELETES it but it won't INSERT it any ideas :D please help me

wolfe
09-08-2002, 10:55 PM
can u plase help :D

g-force2k2
09-08-2002, 11:31 PM
well are all of your answer fields empty? regards...

g-force2k2

wolfe
09-08-2002, 11:32 PM
no d00d

i have edited the post to change the answer and what it does is deletes it but it don't INSERT a new answer :( is the code right to INSERT and UPDATE and DELETE

g-force2k2
09-08-2002, 11:38 PM
well it seems the answers aren't inputted correctly... else you wouldn't get the DELETE as stated by your if else statements... regards...

g-force2k2

wolfe
09-08-2002, 11:39 PM
d00d it don't seem to be working :(