Jump to content


This topic is now archived and is closed to further replies.


Difference with PHP Version

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.

Insert new category information into the category table.
Checks for errors during the insert.

echo"$POVendorName $PONum $ POAmount $POVendorPhone POVendorDesc POExpDate";

$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.';
echo "Add category did not work properly, please try again later.";


Share this post

Link to post
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_GET_VAR becomes $_GET

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.

Share this post

Link to post
Share on other sites

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.

Share this post

Link to post
Share on other sites


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.