Welcome Guest ( Log In | Register )



2 Pages V   1 2 >  
Reply to this topicStart new topic
> Wierd Problem With $_post/$_get/$_request
SilverFox
post Aug 1 2007, 07:39 PM
Post #1


Premium Member
Group Icon

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
Go to the top of the page
 
+Quote Post
Habble
post Aug 2 2007, 06:23 AM
Post #2


Premium Member
Group Icon

Group: [HOSTED]
Posts: 286
Joined: 17-June 07
From: Tasmania
Member No.: 22,699



What's it adding 1 to?
Go to the top of the page
 
+Quote Post
kelvinmaki
post Aug 2 2007, 09:13 AM
Post #3


Advanced Member
Group Icon

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.
Go to the top of the page
 
+Quote Post
ethergeek
post Aug 3 2007, 04:55 PM
Post #4


Premium Member
Group Icon

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
Go to the top of the page
 
+Quote Post
SilverFox
post Aug 3 2007, 06:37 PM
Post #5


Premium Member
Group Icon

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
Go to the top of the page
 
+Quote Post
TavoxPeru
post Aug 3 2007, 11:34 PM
Post #6


Super Member
Group Icon

Group: [HOSTED]
Posts: 763
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579



QUOTE(SilverFox @ Aug 1 2007, 02:39 PM) *
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,
Go to the top of the page
 
+Quote Post
vizskywalker
post Aug 4 2007, 01:50 AM
Post #7


Techno-Necromancer
Group Icon

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]");
If I remember correctly, you cannot, at least in PHP 5, which we now use, and I'm pretty sure in PHP 4 as well, assign to $_POST, $_GET, $_REQUEST, and the like. So you would have to assigne $_POST['command'] to something else, then try to strip them. Also, how do you know it is adding a one? What debugging code for that check do you have?

~Viz
Go to the top of the page
 
+Quote Post
kelvinmaki
post Aug 4 2007, 05:01 AM
Post #8


Advanced Member
Group Icon

Group: Members
Posts: 170
Joined: 30-July 07
Member No.: 23,704



QUOTE(SilverFox @ Aug 3 2007, 06:37 PM) *
@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
Go to the top of the page
 
+Quote Post
SilverFox
post Aug 7 2007, 02:19 AM
Post #9


Premium Member
Group Icon

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.
Go to the top of the page
 
+Quote Post
TavoxPeru
post Aug 7 2007, 06:41 AM
Post #10


Super Member
Group Icon

Group: [HOSTED]
Posts: 763
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579



QUOTE(SilverFox @ Aug 6 2007, 09:19 PM) *
@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,
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Free Online Speed Test(16)
  2. Graphics Driver Out...(1)
  3. Freewebhosting: Ml01172.astahost.com(0)
  4. Pc Problem(8)
  5. Help! Problem With My Flash-Drive(1)
  6. Blue Screen - irql_not_less_or_equal(35)
  7. Problem With Div's In Ie6 And Lower(4)
  8. Photoshop Cropping Problem(7)
  9. Spam Problem On My Forums(26)
  10. Need Help?(9)
  11. Counter-Strike Source Clans - Post Your Server IPs(15)
  12. Win Rar Password Problem(7)
  13. Problem With Drag And Drop (or So It Seems).(11)
  14. Trojan / Virus Problem ,please Help(18)
  15. I Cannot Embed A Google Video In A Joomla Post(5)
  1. Administrator Account Problem In Microsoft Xp [solved](20)
  2. Error 406 - Problem In My Phpbb Forum(8)
  3. A Gaiaonline Problem(9)
  4. Need To Hack An Admin Account On Xp... No Problem!(61)
  5. Request Form Site Suspended(4)
  6. Fedora Core 6 Install Problem(6)
  7. Internet Explorer 7 Problem(8)
  8. Problem: I Need Urgent Help. Can't Boot.(9)
  9. Frustrating Problem With XP On Laptop(19)
  10. Problem With Move_uploaded_file()(5)
  11. XP Problem: Clicking On Folder Opens Search(4)
  12. Einstein Quiz(29)
  13. Problem With The ReadOnly Property(3)
  14. Mozilla Firefox And Runescape(10)
  15. Hdd Stuck On Post(9)


 



- Lo-Fi Version Time is now: 12th October 2008 - 06:18 AM