Date: 09/28/00
- Next message: messju mohr: "Re: [phplib] Parse error"
- Previous message: Maurice Jumelet: "Re: [phplib] Parse error"
- In reply to: Peter Bowyer: "[phplib] Parse error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
In PHP4 you can not have anything more complex than a constant as an
initializer of a class variable.
You have to hardcode 'var $HOST = "db.yoursite.f2s.com";' etc.
I did a workaround on one Project where I created the class-definition in
a string a eval'ed it (modified for your example, but untestet :) :
- -- schnipp --
/* hack for php4, since it does not support more complex
initializers than constants */
$tmp=sprintf('class DB_SendCard extends DB_Sql {
var $Host = "%s";
var $Port = "%s";
var $Database = "%s";
var $User = "%s";
var $Password = "%s";}',
$dbhost,
$dbport,
$dbname,
$dbuser,
$dbpassword);
eval($tmp);
$tmp=""; // because of the db-Password lying around in that variable, or
// am I paranoid? we have the pw in $dbpassword anyway :)
- -- schnapp --
But this is a really dirty hack and should be considered as "not the way to
do it". Unfortunately I cannot imagine a Better solution, if you want to keep
your configuration away from your class-Definiton. Does anyone else on the
list have a good recommendation to solve this??
regards
messju mohr
On Thu, 28 Sep 2000, Peter Bowyer wrote:
> Hi,
>
> Can anyone tell me why this is generating a parse error on the line
> marked >>>>>> (and I guess on the following lines as well)?
>
> include ("./db_pgsql.inc");
> include ("./postcard_setup.php");
> include("./class.FastTemplate.php");
>
> class DB_SendCard extends DB_Sql {
> >>>>>> var $Host = $dbhost;
> var $Database = $dbname;
> var $User = $dbuser;
> var $Password = $dbpassword;
> }
> $db = new DB_SendCard ;
>
> The postcard_setup.php file contains the following:
>
> // Enter your database details:
> // Database name:
> $dbname="abcdefg";
> // Username:
> $dbuser="username";
> // Database host:
> $dbhost="db.yoursite.f2s.com";
> // Database password:
> $dbpassword="********";
>
> What's wrong? It works fine on a server running PHP version 3.0.16 and
> PostgreSQL, but not on a server running PHP 4.02 and MySQL.
>
> TIA,
> Peter.
> --oOo--
> Narrow Gauge on the web - photos, directory and forums!
> http://www.narrowgauge.f2s.com
> --oOo--
> Peter's web page - Scottish narrow gauge in 009
> http://members.aol.com/reywob/
> --oOo--
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: phplib-unsubscribe <email protected>
> For additional commands, e-mail: phplib-help <email protected>
>
- --
Matthias Mohr <m.mohr <email protected>> (Software-Entwicklung)
Internet Factory AG, Niederlassung Industriestr. 11, 26121 Oldenburg
Tel: (+49) (0)441 - 77 92 10 Fax: (+49) (0)441 - 77 92 177
http://www.internet-factory.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: public key @ http://messju.internet-factory.de/public.key
iD8DBQE505yNubKPpFA4n0URAjQmAJ4k+bnkEpgFpO14JW/hkBI9cWRzSwCfY+0e
8oEkIlvGejLQXVRMYN7S+DQ=
=D8vW
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>
- Next message: messju mohr: "Re: [phplib] Parse error"
- Previous message: Maurice Jumelet: "Re: [phplib] Parse error"
- In reply to: Peter Bowyer: "[phplib] Parse error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

