I am having a problem with PHP, an inconsistency in which code that executes just fine on my development server is misbehaving on the server on which my client is attempting to deploy it.
The php code fetches data from a hosted database which happens to be a FileMaker database; it’s the same database in both cases (not a copy of, but literally the same database, which is hosted on a third server at a hosting service).
There are three php files involved here, which I will refer to as FileOne.php, FileTwo.php, and FileThree.php; those aren’t their real names but the real names to not use any reserved characters or terms. FileOne.php in turn, contains 3 php variables.
Let’s start with the first php variable in FileOne.php, $LinkBase, defined as the value fetched from a database field.
$LinkBase = $record->getField(‘ItemLinkField’);
*(for those of you familiar with php but who are not familiar with the
FileMaker php API, trust me on this; it's a different nomenclature
than querying a SQL data source).*
The value in a specific database record for the field ItemLinkField happens to look like this:
Then a second variable, $LinkFwd, is defined in terms of $LinkBase, like so:
if ( strpos ($LinkBase, “php”)>0) {
$LinkFwd = $LinkBase. ‘&pkval=’ . $PrimaryKey;
} else {
$LinkFwd = $LinkBase;
}
This enables the database to contain a forwarding link that is, itself, a php address that in turn contains some parameters; and, if so, the above code appends an additional parameter, the primary key of the record from which that value was fetched.
Then another, third, variable, $Livelink, is defined in terms of $LinkFwd as follows:
if ($LinkBase !=‘’) {
$Livelink = 'FileTwo.php?ts='.$now.'&o='.$LinkOwner.'&nextURL='.$LinkFwd;
}
Later, farther down, in the table HTML, the php inserts the link, causing it to be what happens when the end user clicks on the Item Name:
echo ‘<td>’ .‘<a href=’.$Qmk.$LiveLink.$Qmk.‘>’. $ItemName .‘</a><p> ‘. $ItemDescr.’ </p></td>’;
($Qmk is a literal quotation mark in case you’re wondering; and $ItemName and $ItemDescr are fetched from the same database).
SO… clicking on this link would send the user to FileTwo.php, which in turn would parse the value in the nextURL parameter and after recording various bits of info, forwards the user onwards to FileThree.php:
(forwarding code from FileTwo.php):
echo ‘<meta http-equiv=’ . $Qmk . ‘refresh’.$Qmk.’ content=‘.$Qmk.‘0; url=’ . $nextURL.$Qmk.’>';
… $LinkBase is always some variation on “FileThree.php?x=this&y=that&z=somethingelse”. Hence $LinkFwd is always something like “FileThree.php?x=this&y=that&z=somethingelse&pkval=12345” and the final destination would always be FileThree.php with various & assorted parameters passed to it.
OK, now onward to the problem. (If you aren’t with me at this point you may as well bail out now).
On MY server, the php file when loaded in a web browser (and the php executed by my server’s php engine, etc) results in an ITEM with this as the attached clickable link:
http://localhost/~ahunter3/client_xxx_devfolder/FileTwo.php?d=12345&e=67890&nextURL=http://www.xxx.com/FileThree.php?**aa=aBcDE&bb=**fGHij&pkval=876
But when this exact php file is uploaded to my CLIENT’S server, which is running PHP version 5.2.17 and is a Linux box, that exact same item loads with THIS as the attached clickable link INSTEAD:
in other words, on the client’s server, somehow one critical ampersand is being eaten for lunch! The link doesn’t work properly because FileThree.php can’t properly trap for the variable that is being passed along as bb=fGJij…
what the heck could be causing that? And what do I do about it???