kvarnerexpress
Feb 21 2006, 01:49 PM
I have a piece of code on one server that works and the same piece of code on another server does not. The difference is in the PHP verison & the Linux verison The one that works runs PHP4 on Redhat Linux. The one that doesn't runs PHP5 on SUSE Linux. Not sure if this is where the issue lies or not. I do know that in one case I see an adrress in searchable and in the other case it is null. PHP Code: CODE if ($HTTP_POST_VARS[addr]) { $searchable = $HTTP_POST_VARS[addr]; echo "searchable = ".var_dump($searchable)."</br>"; $stack=array(); ...extra code } else { print("<form method=\"POST\" action=\"ifinfo-single.php\"><table><tr><td><b>Enter IP/range/list: </td><td><input type=\"text\" name=\"addr\"></td><td><input type=\"submit\" value=\"Submit\"></td></tr></table>"); print("<table><tr><td valign=top><b>Valid values: </td><td><font size=\"-1\"><ul><li>Single IP (172.16.32.152)</li><li>Range (172.16.32.140-144)</li><li>Semicolon seperated (172.16.32.140;172.16.32.151;172.16.32.152)</li></ul></td></tr></table>");
}
Any ideas?
Reply
Spectre
Feb 21 2006, 01:55 PM
I would suggest you use $_POST instead of $HTTP_POST_VARS. The former has superceded the latter - to the extent that I think some newer versions of PHP have alltogether dropped support for the previously used variable. Also, I think it would probably a good idea to change the equivalent code above to: CODE if (isset($HTTP_POST_VARS['addr']) && $HTTP_POST_VARS['addr'] != '' ) { $searchable = $HTTP_POST_VARS['addr']; echo 'searchable = '.var_dump($searchable).'</br>'; $stack=array(); ...extra code } ... Remember to always enclose variable indexes (unless they are numeric) in quotes. $variable[index] may work on some systems, but $variable['index'] will work on all, and is a better standard of coding. Note that you should still replace $HTTP_POST_VARS with $_POST in the above block of code; I've just left it as is to make it easy to read. Also, in the last section of your script, don't you think it would be easier to enclose the string in single quotes, and not have to escape every double quote you encounter? CODE print('<form method="POST" action="ifinfo-single.php"><table><tr><td><b>Enter IP/range/list: </td><td><input type="text" name="addr"></td><td><input type="submit" value="Submit"></td></tr></table>'); print('<table><tr><td valign=top><b>Valid values: </td><td><font size="-1"><ul><li>Single IP (172.16.32.152)</li><li>Range (172.16.32.140-144)</li><li>Semicolon seperated (172.16.32.140;172.16.32.151;172.16.32.152)</li></ul></td></tr></table>');
Reply
OpaQue
Feb 21 2006, 06:57 PM
This piece of information might prove helpful.. QUOTE The deprecation of the old $HTTP_*_VARS arrays (which need to be indicated as global when used inside a function or method). The following autoglobal arrays were introduced in PHP » 4.1.0. They are: $_GET, $_POST, $_COOKIE, $_SERVER, $_FILES, $_ENV, $_REQUEST, and $_SESSION. The older $HTTP_*_VARS arrays, such as $HTTP_POST_VARS, still exist and have since PHP 3. As of PHP 5.0.0, the long PHP predefined variable arrays may be disabled with the register_long_arrays directive.
Also, external variables are no longer registered in the global scope by default. In other words, as of PHP » 4.2.0 the PHP directive register_globals is off by default in php.ini
Reply
adly3000
Feb 22 2006, 03:07 PM
i agree with OpaQue: QUOTE The deprecation of the old $HTTP_*_VARS arrays (which need to be indicated as global when used inside a function or method). The following autoglobal arrays were introduced in PHP » 4.1.0. They are: $_GET, $_POST, $_COOKIE, $_SERVER, $_FILES, $_ENV, $_REQUEST, and $_SESSION. The older $HTTP_*_VARS arrays, such as $HTTP_POST_VARS, still exist and have since PHP 3. As of PHP 5.0.0, the long PHP predefined variable arrays may be disabled with the register_long_arrays directive.
Also, external variables are no longer registered in the global scope by default. In other words, as of PHP » 4.2.0 the PHP directive register_globals is off by default in php.ini
just cahnge the ($HTTP_*_VARS arrays i.e. $HTTP_POST_VARS) to ($_* i.e. $_POST) i also agree with Spectre: using isset in trhe if statement is better than just if: CODE if (isset($_POST['addr']) && $_POST['addr'] != '' ) { $searchable = $_POST['addr']; echo 'searchable = '.var_dump($searchable).'</br>'; $stack=array(); ...extra code } ...
the above code better than the following one: CODE if ($_POST['addr']) { $searchable = $_POST['addr']; echo "searchable = ".var_dump($searchable)."</br>"; $stack=array(); ...extra code }
Reply
Recent Queries:--
$http_post_vars not work - 7.79 hr back. (1)
-
php $http_post_vars not work - 9.60 hr back. (1)
-
$http_post_vars not working - 15.74 hr back. (1)
-
$http_post_vars not owrking - 15.75 hr back. (1)
-
php $http_post_vars - 28.73 hr back. (1)
-
work with http_post_vars i need to change php.ini - 30.32 hr back. (1)
-
$http_post_vars not working with php5 - 33.09 hr back. (1)
-
$http_post_vars swf - 35.29 hr back. (1)
-
$http_post_vars is not working in php5 - 40.60 hr back. (1)
-
$http_post_vars is not working in php 5 - 59.55 hr back. (1)
-
$http_post_vars is not working - 59.59 hr back. (1)
-
$http_post_vars - 0.67 hr back. (15)
-
http_post_vars - 2.51 hr back. (14)
-
php http_redirect problem - 72.87 hr back. (2)
Similar Topics
Keywords : problem, http, post, vars
- Http_redirect() [resolved]
(4)
Flash + PHP: How can I transfer vars?
(4) I am making a little section for a friends website. Here is what I have so far. :SWF File here:
And I made it you match the layout of here site. Here As you can see I pretty much have the
layout of it down. Some little bugs to be worked out with characters allowd in the text boxes and
what not. But I have a good platform. NOW for the fun part! Getting vars from flash to send,
via POST, to PHP. I have been trying to find a good tutorial on this online but I am not having such
great outcomes! So if anyone can help me here please go for it! This is ....
Compare Two Vars And Highlight The Differences
(7) I need a script that compares 2 variables, and looks for a difference between them. It will then
highlight the words that are different, as shown in the image below: So in the left cell, the
yellow text is the text that has been removed OR replaced. In the right cell, the green text is the
text that has replaced some text in the left cell, OR new text. This script will be used to
compare 2 versions of a document stored in the database, to see the difference between each change
(all revisions are stored in the database). I know that it's possible with PHP, beca....
Http Authentication Without Using The Popup
(3) As it is mentioned earlier on in this form I am trying to use HTTP authentication to add simple
users control to my site, one thing I like about it is that the username and password are stored
throught the entire session that way I don't have to enter into the realm of cookeis and session
id's. So now I was wondering, a) can I use a standard html forum and place the password and
username values into $_SERVER and $_SERVER so that they will be reembered throuout the
session, and /cool.gif' border='0' style='vertical-align:middle' alt='cool.gif' /> ....
Http Authentication
(2) I have a book called PHP and MySQL for dynamic web sites by Larry Ullman, and it's a very good
book which I would recomend to anyone wanting to learn, but I followed a project in this book, not
letter by letter, and it won' work. I wrote this code to create an authentication script that
will only work with one user but allow the credientals to be passed from one page to another. So
here's the code CODE <?PHP $aut = FALSE; //Check for user variables if (
(isset($_server['PHP_AUTH_USER']) AND isset(....
Quick Question About Session Vars
something I can't find anywhere (1) Can you save stuff like classes and arrays in sessionsvariables?....
Looking for problem, http, post, vars
|
|
Searching Video's for problem, http, post, vars
|
advertisement
|
|