Re: PHP uses parameters' names instead of values
- From: "Rik Wasmus" <luiheidsgoeroe@xxxxxxxxxxx>
- Date: Thu, 21 Feb 2008 02:49:48 +0100
On Thu, 21 Feb 2008 01:42:33 +0100, virgindog <billbois@xxxxxxxxx> wrote:
We moved to a new server and a sporadic problem started. Sometimes a
function works correctly but sometimes it'll use the name of the
parameter passed to it rather than the value. Sometimes it will
simply lose the value of the parameter.
For instance, the function that connects to our MySQL database accepts
four parameters: the username, the password, the server name and the
database name. We use default values for each of them and the
defaults are global constants defined elsewhere, so the function
declaration looks like:
public function w_connect($username=DB_USER, $password=DB_PASS,
$server=DB_MASTER, $db=DB_NAME){....
It usually works fine and uses the values we pass, or the constants if
nothing is passed. However, a few times a day, it will try connecting
with a username of "DB_USER," a password of "DB_PASS," etc.
This is just one example. There are other spots where parameters have
the value of their names or no value at all. We're comparing the two
servers to see what's different, but has anyone seen anything like
this before? Can you point us in the right direction?
If the constants are not defined, PHP will issue an error (with high enough error_reporting), and assume a string of the same name.
So either your defines go wrong, or a possible the include of a file holding those defines goes wrong or is not being done entirely. Try to check wether everything is defined() as it should be, and log if they aren't. Also, be sure to require needed files instead of including. This will not solve your problem probably, but the code will fail more transparantly earlier on, giving you a better chance to catch the source..
--
Rik Wasmus
.
- Prev by Date: Re: mod_rewrite and /
- Next by Date: Re: Different MSSQL output date format from the same PHP script
- Previous by thread: Setting Array Internal Pointer
- Next by thread: Re: PHP uses parameters' names instead of values
- Index(es):
Relevant Pages
|