|
|
|
|
![]() ![]() |
Aug 1 2007, 07:39 PM
Post
#1
|
|
|
Premium Member Group: Members Posts: 206 Joined: 26-February 07 From: Texas Member No.: 20,598 |
I'm having a bad problem and no idea how to fix it...it's setting my back on my PHP work.
I have 7 if statements that do something depending on what $_POST['command'] is, it works for the first 6th and on the last one it adds a 1 (only ads the 1 at the end IF its the one in the if statement). Example of the failing line: CODE if ($_POST['final'] == 'yes' AND $_POST['command'] == 'lol' AND $_POST['action'] == 'cmd') { The other ifs are like that, just $_POST['command'] == other things. Those if statements work. It does this with $_GET and $_REQUEST. It does this no matter what I put in the statement and if i make it blank it puts a 1 anyways. I even put this before the if statement: CODE $whattostrp2 = array("1"); $_POST['command']= str_replace($whattostrp2, "", "$_POST[command]"); STILL adds a 1. I have it echoing the $_POST['command'], hence how I know this. What I don't understand its WHY it does this ONLY on the 7th if statement and not the others. I tried to make it where $_POST['command'] == 'lol1' and it adds ANOTHER 1. It also does this with else if and elseif. If I redo the IF statement like this: CODE if ($_POST['command'] == 'lol') { It still fails. Any ideas? This is really bugging me and I have found NOTHING on it. This post has been edited by SilverFox: Aug 1 2007, 08:12 PM |
|
|
|
Aug 2 2007, 06:23 AM
Post
#2
|
|
|
Premium Member Group: [HOSTED] Posts: 286 Joined: 17-June 07 From: Tasmania Member No.: 22,699 |
What's it adding 1 to?
|
|
|
|
Aug 2 2007, 09:13 AM
Post
#3
|
|
|
Advanced Member Group: Members Posts: 170 Joined: 30-July 07 Member No.: 23,704 |
Can you paste the whole code or rather the rest of the if statements? So you trying to get the $_POST data from a form? And for the 'command', what is it? eg. Radio, text input, drop down box.
If you could put some codes from the form till the form action and then the if else statement. Might get some clues on why this happen. |
|
|
|
Aug 3 2007, 04:55 PM
Post
#4
|
|
|
Premium Member Group: [HOSTED] Posts: 393 Joined: 9-March 07 From: Tucson, AZ Member No.: 20,794 |
Just a troubleshooting hunch...rewrite it this way:
CODE if ( ($_POST['final'] == 'yes') AND ($_POST['command'] == 'lol') AND ($_POST['action'] == 'cmd') )
This post has been edited by ethergeek: Aug 3 2007, 04:56 PM |
|
|
|
Aug 3 2007, 06:37 PM
Post
#5
|
|
|
Premium Member Group: Members Posts: 206 Joined: 26-February 07 From: Texas Member No.: 20,598 |
@kelvinmaki: Its a text box, and final/action are hidden. The reason I didn't post the whole code is its around 50 lines long or so and if I was to have ALL the if statements around 200 lines. I know its relatively small but its a lil big for a forum post. Also its not an error in the html form, I know how to make an html form correctly and it ONLY happens on the FINAL if statement (although I never tried adding an extra one to see if its the 7th or the last). I'll post more of the code if I can get around to it, I'm pretty busy right now trying to finish this update and working around the house.
@ether: I'll try that out, what I did was just ditch it above 6 for now. This post has been edited by SilverFox: Aug 3 2007, 06:38 PM |
|
|
|
Aug 3 2007, 11:34 PM
Post
#6
|
|
|
Super Member Group: [HOSTED] Posts: 763 Joined: 8-April 06 From: Lima - Peru Member No.: 12,579 |
I'm having a bad problem and no idea how to fix it...it's setting my back on my PHP work. I have 7 if statements that do something depending on what $_POST['command'] is, it works for the first 6th and on the last one it adds a 1 (only ads the 1 at the end IF its the one in the if statement). Example of the failing line: CODE if ($_POST['final'] == 'yes' AND $_POST['command'] == 'lol' AND $_POST['action'] == 'cmd') { The other ifs are like that, just $_POST['command'] == other things. Those if statements work. It does this with $_GET and $_REQUEST. It does this no matter what I put in the statement and if i make it blank it puts a 1 anyways. I even put this before the if statement: CODE $whattostrp2 = array("1"); $_POST['command']= str_replace($whattostrp2, "", "$_POST[command]"); STILL adds a 1. I have it echoing the $_POST['command'], hence how I know this. What I don't understand its WHY it does this ONLY on the 7th if statement and not the others. I tried to make it where $_POST['command'] == 'lol1' and it adds ANOTHER 1. It also does this with else if and elseif. If I redo the IF statement like this: CODE if ($_POST['command'] == 'lol') { It still fails. Any ideas? This is really bugging me and I have found NOTHING on it. Do you try to do the same thing but instead of using the operator '==' use the operator '===' that also compares if both sides are of the same type. Best regards, |
|
|
|
Aug 4 2007, 01:50 AM
Post
#7
|
|
|
Techno-Necromancer Group: Members Posts: 1,018 Joined: 13-January 05 From: The Net Member No.: 2,127 |
Also, you said you tried
QUOTE(SilverFox) CODE $whattostrp2 = array("1"); $_POST['command']= str_replace($whattostrp2, "", "$_POST[command]"); ~Viz |
|
|
|
Aug 4 2007, 05:01 AM
Post
#8
|
|
|
Advanced Member Group: Members Posts: 170 Joined: 30-July 07 Member No.: 23,704 |
@kelvinmaki: Its a text box, and final/action are hidden. The reason I didn't post the whole code is its around 50 lines long or so and if I was to have ALL the if statements around 200 lines. I know its relatively small but its a lil big for a forum post. Also its not an error in the html form, I know how to make an html form correctly and it ONLY happens on the FINAL if statement (although I never tried adding an extra one to see if its the 7th or the last). I'll post more of the code if I can get around to it, I'm pretty busy right now trying to finish this update and working around the house. SilverFox, Let me get it correctly, you are passing a textbox over by the $_POST, and only at the last IF statement, you are getting the value 1. So at the last IF statement, what you printed out is value 1 am I right. It could be an empty array in the $_POST. When its an empty array, using echo, print or print_r, it will gives you a 1. If that's no the problem, you can pm me with the html codes and the script of IF ELSE. I can test it in my system. That will be easy to debug rather than speculating all the possible reason. CHEERS |
|
|
|
Aug 7 2007, 02:19 AM
Post
#9
|
|
|
Premium Member Group: Members Posts: 206 Joined: 26-February 07 From: Texas Member No.: 20,598 |
@tav: That is a good idea, I had to do that before. I'll try that out.
@vizy: Yes but it still shouldn't do that (add the 1 without the stripping). @Kelvin: Its not empty. I'll get back on this. Really busy. |
|
|
|
Aug 7 2007, 06:41 AM
Post
#10
|
|
|
Super Member Group: [HOSTED] Posts: 763 Joined: 8-April 06 From: Lima - Peru Member No.: 12,579 |
@tav: That is a good idea, I had to do that before. I'll try that out. @vizy: Yes but it still shouldn't do that (add the 1 without the stripping). @Kelvin: Its not empty. I'll get back on this. Really busy. Ok, but i think that if you post your complete code it would be better to us to help you. Best regards, |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 12th October 2008 - 06:18 AM |