Nov 21, 2009
Pages: 1, 2

Wierd Problem With $_post/$_get/$_request

free web hosting

Read Latest Entries..: (Post #11) by kelvinmaki on Aug 7 2007, 03:56 PM.
QUOTE(Quatrux @ Aug 7 2007, 11:08 AM) Yeah, I would like to see the full code too, with html, the post data which is sent and how it is gathered and etc. I think it is just a logical mistake somewhere in the code or just it is one of those things which you can't see even if it is so visible ;] I remember I spend some time on such stupid errors, but after a week I just checked with my clear head and found it very fast, in fact, it happened much more times than one Agreeded. I've ...
read more.
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Wierd Problem With $_post/$_get/$_request

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

 

 

 


Comment/Reply (w/o sign-up)

Habble
What's it adding 1 to?

Comment/Reply (w/o sign-up)

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

Comment/Reply (w/o sign-up)

ethergeek
Just a troubleshooting hunch...rewrite it this way:

CODE
if ( ($_POST['final'] == 'yes') AND ($_POST['command'] == 'lol') AND ($_POST['action'] == 'cmd') )

Comment/Reply (w/o sign-up)

SilverFox
@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.

Comment/Reply (w/o sign-up)

TavoxPeru
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,

 

 

 


Comment/Reply (w/o sign-up)

vizskywalker
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

Comment/Reply (w/o sign-up)

kelvinmaki
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

Comment/Reply (w/o sign-up)

SilverFox
@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.

Comment/Reply (w/o sign-up)

TavoxPeru
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,

Comment/Reply (w/o sign-up)

Latest Entries

kelvinmaki
QUOTE(Quatrux @ Aug 7 2007, 11:08 AM) *
Yeah, I would like to see the full code too, with html, the post data which is sent and how it is gathered and etc. I think it is just a logical mistake somewhere in the code or just it is one of those things which you can't see even if it is so visible ;] I remember I spend some time on such stupid errors, but after a week I just checked with my clear head and found it very fast, in fact, it happened much more times than one wink.gif


Agreeded. I've not been coding for long but sometimes do make such mistake that are so visible. And when I show my codes to someone else, they just find out the root cause within a few minutes. So if you want to share your codes, just paste it. Definitely someone will be able to spot something. wink.gif

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Pages: 1, 2
Similar Topics

Keywords : wierd, problem, post, get, request

  1. Script Request
    script request (2)
  2. Some Problems Sometimes On Other Sites!
    Others come up with wierd problems! (2)
    I am not the most regular contributer to PHP Builder but every now and then there is just a question
    from a newbie or someone that can not be fixed. I do not know if it is that they do not know how to
    ask the question but this one has been going on too long. It seemed from the question that they
    asked that they wanted to insert some data froma text file into the MySQL database. So after looking
    at their query (the original question) QUOTE Here's part of my code: Code: $result =
    mysql_query("INSERT INTO AL_BVA (contact, time, phone, address, city, state, zip, ....
  3. Php Regular Expressions
    Request For Help. (11)
    So I'm trying to learn how to pull useful content from a web page. Here's what I got so
    far: CODE $filename = "http://www.forum500.com"; $html = file_get_contents($filename); /*
    **************************************************************** */ /*                              
                                       */ /*             Got this code @ http://www.php.net/            
         */ /*                                                                  */ /*
    **************************************************************** */ // $document should contain an H....
  4. Php Access Log In Reverse Order
    Request For Help. (8)
    So I need help getting data entered into my log correctly. I want the newest entry to be at the
    beginning (top) of the log instead of at the end (bottom). Here's what I have: CODE
    function access_log(){  // Enter data in usage log.     $filename = "access.log";     $entry =
    gmdate("M d, Y H:i:s T").": ". getenv("REMOTE_ADDR").": ". getenv("HTTP_USER_AGENT")." \n";
        fwrite(fopen($filename, "a"), $entry);     fclose(fopen($filename, "a")); }  //  End function
    access_log() ?> And it outputs: Mar 29, 2005 07:57:16 GMT Standard Time: 192.168.1.1: Moz....

    1. Looking for wierd, problem, post, get, request

See Also,

*SIMILAR VIDEOS*
Searching Video's for wierd, problem, post, get, request
advertisement



Wierd Problem With $_post/$_get/$_request

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com