Re: PHP uses parameters' names instead of values



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
.



Relevant Pages

  • Re: PHP-mySQL connection being refused
    ... I have a script running that accesses a mysql database on a shared ... On my ISP's server status page, ... RaQ08 is experiencing problems with its backnet connection to ...
    (comp.lang.php)
  • automate csv upload to mysql database
    ... I am tring to automate the process of uploading data from a csv file to ... I cannot connect directly to the mysql server from anything other then ... how can I automate importing the data into the mysql database. ...
    (comp.unix.shell)
  • Re: apt-get mysql-server
    ... install mysql-server-5.0 on the second server but apt-get couldn't find the ... I'm not sure how I got version 5 on the first server. ... deb http://security.debian.org/ stable/updates main ... mysql database common files ...
    (Debian-User)
  • PHP-mySQL connection being refused
    ... I have a script running that accesses a mysql database on a shared server. ...
    (comp.lang.php)