Re: [PHP] Installing PEAR

2001-03-22 Thread Paul rees

In article [EMAIL PROTECTED], [EMAIL PROTECTED] writes
Ok, IM a bit confused as to how PEAR is installed. I read through the README 
file in the php source but found no explanation. 

I am tryin to use the PEARs DB abstracion. I have DB.php and DB/ in 
/usr/local/lib/php. I added: 'include_once(DB/mysql.php);' to the top of my 
script but it failed since it is not finding it. Do I need to assign a path in 
the php.ini file or have I missed an installation step? 

Can somebody please explain or point me to some docs on how I get up and going 
with PEAR.

Hi,

Try something like:

?php
require_once ('DB.php');


// connection
$db_type = "mysql";   // type of database - must correspond to a PEAR type
$db_user = "user";// database access username
$db_pswd = "password";// database access password
$db_host = "localhost";   // hostname of database
$db_name = "you_db_name"; // database name

$db_connectString = "$db_type://$db_user:$db_pswd@$db_host/$db_name"; // the above,
collected here for convenience

$usePersistentConnects = true; // true - uses persistent connects to the database
(always leaves a link open, false - not)

if (! $db_con)
$db_con = DB::connect ($db_connectString, $usePersistentConnects);

$sql = "SELECT column FROM $tableName WHERE whatever = '$whatever'";

if (DB::isError ($result = $db_con - query ($sql)))
handle_db_error ($result);
else
$resultArray = $result - fetchRow (DB_FETCHMODE_ASSOC);

$db_con - commit();

if ($db_con  (! $usePersistentConnects))
$db_con - disconnect();

?
I hope the line wraps still leave the above readable.

I made a separate function of my own, handle_db_error (), to handle errors - you
might like to do something like:

echo DB::errorMessage($result);

... instead.

I recommend putting all the db connection stuff in a file which resides outside of
the document root and including it where you need it.

The following links may prove useful - the user comments in the phpbuilder article
were particularly helpful in pointing me in the right direction.

http://cvs.php.net/viewcvs.cgi/php4/pear/DB/
http://www.phpdoc.de/pear/index2.html
http://www.phpbuilder.com/columns/allan20010115.php3
http://pear.php.net
http://www.php.net/manual/en/pear.php

All the best,
-- 
Paul Rees

Web Application Programmer/Developer

surfEU.com GmbH

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] get_meta_tags bug?

2001-03-20 Thread Paul rees

In article 997dil$t5u$[EMAIL PROTECTED], Yasuo Ohgaki
[EMAIL PROTECTED] writes

 "Paul Rees" [EMAIL PROTECTED] wrote in message
 r19NDKAFmot6Ew$[EMAIL PROTECTED]">news:r19NDKAFmot6Ew$[EMAIL PROTECTED]...
  Hi,
 
  The php function 'get_meta_tags' doesn't work when the meta tag name/
  content values are single quoted. It's fine for double quotes. I've had
  a look but can't find anything on the w3 site to say whether or not
  double quotes are required in meta tags. Does anyone know what the rule
  is?
 
  (php v 4.04pl1, apache, linux 2.2.18)

FYI:
Looks like it is fixed in CVS version and get_meta_tags() now accepts single
quotes.
(I still recommends to use double quotes for your application, but we cannot
force
others and single quotes should be accepted for older HTML versions)

Yes, you're right. Thanks very much. Out of interest, why do you
recommend the use of double quotes? It's so much easier to use single
quotes in these sort of cases:

echo "INPUT type='text' name='name' value='value'\n";

rather than:

echo "INPUT type=\"text\" name=\"name\" value=\"value\"\n";

or:

echo 'INPUT type="text" name="name" value="value"' . "\n";

...and according to this:

http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2

... double, single, and (sometimes) no quotes are all acceptable.

All the best,
-- 
Paul Rees

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] get_meta_tags bug?

2001-03-19 Thread Paul Rees

Hi,

The php function 'get_meta_tags' doesn't work when the meta tag name/
content values are single quoted. It's fine for double quotes. I've had
a look but can't find anything on the w3 site to say whether or not
double quotes are required in meta tags. Does anyone know what the rule
is?

(php v 4.04pl1, apache, linux 2.2.18)

All the best
-- 
Paul

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]