Jump to content


Photo

Difference with PHP Version


  • Please log in to reply
2 replies to this topic

#1 calcio22

calcio22
  • New Members
  • Pip
  • Newbie
  • 6 posts
  • LocationRTP, NC

Posted 24 May 2006 - 04:51 PM

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');
?>]


#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 24 May 2006 - 05:31 PM

Your version of PHP5 most probably has a setting called register_long_arrays 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.

#3 calcio22

calcio22
  • New Members
  • Pip
  • Newbie
  • 6 posts
  • LocationRTP, NC

Posted 24 May 2006 - 07:47 PM

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.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users