calcio22 Posted May 24, 2006 Share Posted May 24, 2006 The following code successfully inserts into a MySQL DB on PHP 4.x, however, I am currently running PHP 5.1.2 and it is resorting to the ELSE statement and not inserting into the database. Does anyone have any thoughts on what could be wrong, or what I may need to change in my PHP.ini file? Thank you in advance.[/**********************************************Sets passed values to local variables to be used.**********************************************/$POVendorName=$HTTP_POST_VARS['POVendorName'];$PONum=$HTTP_POST_VARS['PONum'];$POAmount=$HTTP_POST_VARS['POAmount'];$POVendorPhone=$HTTP_POST_VARS['POVendorPhone'];$POVendorDesc=$HTTP_POST_VARS['POVendorDesc'];$POExpDate=$HTTP_POST_VARS['POExpDate'];/*********************************************Insert new category information into the category table.Checks for errors during the insert.*********************************************/echo"$POVendorName $PONum $ POAmount $POVendorPhone POVendorDesc POExpDate";mysql_select_db('PO');$query = "INSERT INTO PO (POVendorName, PONum, POAmount, POVendorPhone, POVendorDesc, POExpDate) VALUES ('$POVendorName', '$PONum', '$POAmount', '$POVendorPhone', '$POVendorDesc', '$POExpDate')";$result = mysql_query($query);if ($result){echo "<span class='headtitle'>Add Blanket PO Results <br /><br /></span>";echo mysql_affected_rows(). ' category sucessfully inserted into the database.';}else{echo "Add category did not work properly, please try again later.";}require('footer.inc');?>] Quote Link to comment https://forums.phpfreaks.com/topic/10364-difference-with-php-version/ Share on other sites More sharing options...
wildteen88 Posted May 24, 2006 Share Posted May 24, 2006 Your version of PHP5 most probably has a setting called [b]register_long_arrays[/b] turned off in the php.ini which means your $HTTP_*_VAR's are not being recognised/populated by PHP. Instead you'll want to strip HTTP and _VAR from your variable names so:$HTTP_POST_VAR becomes $_POST$HTTP_GET_VAR becomes $_GET$HTTP_COOKIE_VAR becomes $_COOKIE$HTTP_SESSION_VAR becomes $_SESSION$HTTP_SERVER_VAR becomes $_SERVERetc.Your script should now work with PHP5 and 4 too when the changes are made. You should really use the newer superglobal arrays rather than the old depereciated ones. Quote Link to comment https://forums.phpfreaks.com/topic/10364-difference-with-php-version/#findComment-38646 Share on other sites More sharing options...
calcio22 Posted May 24, 2006 Author Share Posted May 24, 2006 Hi,My INI file actually has long arrays turned on, and I changed the calls to just $_POST, with no success. Any other thoughts as to the problem. I imported the database using PHPMyAdmin and everything appears to be the same. Quote Link to comment https://forums.phpfreaks.com/topic/10364-difference-with-php-version/#findComment-38688 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.