Jump to content

Recommended Posts

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');
?>]
Link to comment
https://forums.phpfreaks.com/topic/10364-difference-with-php-version/
Share on other sites

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 $_SERVER
etc.

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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.