[PHP] help confirming a PDO_SQLITE bug

2006-10-30 Thread Rick Fletcher
I've just upgraded to Fedora Core 6 and my personal site broke.  Along 
with the upgrade came PHP 5.1.6 and SQLite 3.3.6.  After the upgrade any 
SELECT returns all its values with the last character missing.


I've filed a bug at pecl.php.net 
(http://pecl.php.net/bugs/bug.php?id=9191), but it doesn't look as 
though that's reviewed very often.  I need help confirming that it is a 
PDO or SQLite bug so that I can begin upgrading or downgrading to avoid it.


If you have matching versions of PHP and/or SQLite, can you try out the 
test script below and see if it's broken in the same way?


Thanks,
Rick Fletcher

Reproduce code:
---
?php
$dbh = new PDO( 'sqlite::memory:' );

$dbh-query( 'CREATE TABLE things ( name VARCHAR NOT NULL )');
$dbh-query( 'INSERT INTO things VALUES ( thing one )');

foreach( $dbh-query( 'SELECT * FROM things' ) as $row ) {
print_r( $row );
}
$dbh = null;
?

Expected result:

Array
(
[name] = thing one
[0] = thing one
)

Actual result:
--
Array
(
[name] = thing on
[0] = thing on
)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] help confirming a PDO_SQLITE bug

2006-10-30 Thread Rick Fletcher
Thanks to anyone who entertained my previous email, but I've solved my 
own problem.


It looks like the bug is in PDO_SQLITE 1.0.1.  I've just compiled from 
that extension from CVS, changing nothing else, and the bug is gone.


--rick

Rick Fletcher wrote:
I've just upgraded to Fedora Core 6 and my personal site broke.  Along 
with the upgrade came PHP 5.1.6 and SQLite 3.3.6.  After the upgrade any 
SELECT returns all its values with the last character missing.


I've filed a bug at pecl.php.net 
(http://pecl.php.net/bugs/bug.php?id=9191), but it doesn't look as 
though that's reviewed very often.  I need help confirming that it is a 
PDO or SQLite bug so that I can begin upgrading or downgrading to avoid it.


If you have matching versions of PHP and/or SQLite, can you try out the 
test script below and see if it's broken in the same way?


Thanks,
Rick Fletcher

Reproduce code:
---
?php
$dbh = new PDO( 'sqlite::memory:' );

$dbh-query( 'CREATE TABLE things ( name VARCHAR NOT NULL )');
$dbh-query( 'INSERT INTO things VALUES ( thing one )');

foreach( $dbh-query( 'SELECT * FROM things' ) as $row ) {
print_r( $row );
}
$dbh = null;
?

Expected result:

Array
(
[name] = thing one
[0] = thing one
)

Actual result:
--
Array
(
[name] = thing on
[0] = thing on
)



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP 5.0.4 not generating /usr/local/bin/pear ?

2005-04-05 Thread Rick Fletcher
Chances are it's not your fault.
The initial release of 5.0.4 was missing the RunTest.php file.  The end 
result of which is that pear isn't installed.  It was noticed a day 
after the initial release, and I believe the 5.0.4 that's on php.net now 
has been fixed.

--Rick
mbneto wrote:
Hi,
I've downloaded the 5.0.4 targz and installed on a new server using
the same ./configure settings I use in a nother server that runs php
5.0.3.
I did a make/make install and everything runs fine excepth the fact
that I can no longer pear install  because there is no pear in
/usr/local/bin.
'./configure' '--with-kerberos' '--with-gd' '--with-apxs2'
'--with-xml' '--with-ftp' '--enable-session' '--enable-trans-sid'
'--with-zlib' '--enable-inline-optimization'
'--with-mcrypt=/usr/local' '--enable-sigchild' '--with-gettext'
'--with-freetype' '--with-ttf' '--with-ftp' '--enable-ftp'
'--with-jpeg-dir=/usr' '--with-mysql=/usr/include/mysql'
'--enable-soap' '--with-pear'
Any ideas?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Randomize an array?

2005-03-07 Thread Rick Fletcher
Brian Dunning wrote:
On Mar 7, 2005, at 7:40 AM, M. Sokolewicz wrote:
array_rand()

But that's likely to give me the same element more than once. I want to 
output the entire array but in a random order, like a shuffled deck of 
cards.
like a shuffled deck of cards?
http://www.php.net/shuffle
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] regular expressions ?

2005-01-27 Thread Rick Fletcher
Robin Vickery wrote:
On Thu, 27 Jan 2005 16:56:05 +0100, Zouari Fourat [EMAIL PROTECTED] wrote:
this is working fine :
if (eregi(^-?([1-3])+$,$x)
echo x is 1 or 2 or 3;
i forgot to say that doesnt work with 1-20 :(
how to do it ?

if (preg_match('/^(20|1[0-9]|1-9])$/', $candidate)) {
   // $candidate is a decimal integer between 1 and 20 inclusive with
no leading zeros.
}
/^(1?[1-9]|[12]0)$/ works too.  The first part covers 1-9, 11-19; the 
second part gets you 10 and 20.

Plus, it's ever so slightly shorter!  And isnt' that what's most 
important? :P

--Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Sigh....regex - need to search/replace string for anything but numbers

2005-01-25 Thread Rick Fletcher
Matt Babineau wrote:
Ahh so the regex gods are pissed at me. This is simple (I think), but I need
to figure out how to strip out everything in a string that is not a number.
Any takers?
I appear to have written that last snippet without really even looking 
at it.  This one works.

?php
$string = asd98.a98asd/7987asd;
$numbers = preg_replace( /[^0-9]/, , $string );
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Sigh....regex - need to search/replace string for anything but numbers

2005-01-25 Thread Rick Fletcher
Matt Babineau wrote:
Ahh so the regex gods are pissed at me. This is simple (I think), but I need
to figure out how to strip out everything in a string that is not a number.
Any takers?
?php
$string = asd98.a98asd/7987asd;
$numberless = preg_replace_all( /[^0-9]/, , $string );
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] String to Date and Date to String Functions?

2005-01-24 Thread Rick Fletcher
Ben Edwards wrote:
The format I am
interested in is DD-MM- which is the way dates are specified in
the UK, strtodate() cant handle this.
Ben, there is no (built in) string-timestamp function that takes a 
format.  strtotime() is pretty smart about interpreting your input, but 
it's limited to the GNU date input formats: 
http://www.gnu.org/software/tar/manual/html_chapter/tar_7.html

The topmost comment on the strtotime() manual page 
(http://us2.php.net/manual/en/function.strtotime.php) describes the 
function you're looking for, and links to it: 
http://www.evilwalrus.com/viewcode.php?codeEx=627

--Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] php editor

2005-01-15 Thread Rick Fletcher
I had been using Zend Studio, but I've just about made the switch to 
Eclipse with the TruStudio PHP plugin.

Eclipse: http://www.eclipse.org
TruStudio: http://www.xored.com/trustudio/
Mostly running it in Linux (Fedora Core 3), but I've used that 
combination in Windows and OSX, too.

--Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Install PHP4 on a Apache2 + PHP5 system

2004-12-20 Thread Rick Fletcher
I have a server on which Apache2 and PHP5 are functioning well, but I 
also want to build in support for PHP4 because the webmail package I use 
isn't compatible with PHP5... So, I need to install PHP4 next to PHP5, 
and make my Directory in httpd.include use PHP4 for my webmail 
directory...
I've never run this setup myself, but I just test this out and it worked 
for me.  (I put it inside a VirtualHost, but you should be ok to put it 
in the Default server context too)

# set up an alias to the php4 cgi binary
ScriptAlias /cgi-bin/php4 /path/to/php4cgi
# i want files in http://example.com/mail/ to be parsed with php4
Location /mail/
   Action php4-script /cgi-bin/php4
   AddHandler php4-script .php
/Location
You could use Directory too, but give it a file path, not a url.
--Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] regex issue

2004-11-30 Thread Rick Fletcher
[EMAIL PROTECTED] wrote:
All I want to do is capture the keyword (array, break, echo, etc) and color
it.

$txt = this is an array('test');
$pattern = /(array|break|echo|continue)([\(.|\s.|\;.])/;
echo preg_replace($pattern, 'font color=red$0/font', $txt);

This captures array( though and I just want array.
That's because you're using $0 in the replacement.
The value of $0 is the entire string being matched by the regex.  In 
this case, array(.  You only want to put the keyword submatch inside 
the font tag, then the rest of the matched string after it.

That wasn't a very good explanation.  Sorry, I'm tired.
Anyway, change the preg_replace line to:
echo preg_replace($pattern, 'font color=red$1/font$2', $txt);
--Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] print_r() and SimpleXML

2004-11-30 Thread Rick Fletcher
[snip]
when using print_r on a SimpleXML object that has
attributes, the attributes are not shown.
I would propose that this is not the desired response. When using
print_r on an object, it should display all available information
(even, as the manual indicates, private and/or protected properties).
[snip]
Now, if people agree with me, that this is infact not the desired
response. Is this a 'bug' with SimpleXML or print_r?
On the SimpleXML-attributes documentation page 
(http://www.php.net/manual/en/function.simplexml-element-attributes.php) 
you'll find this note:

SimpleXML has made a rule of adding iterative properties to most 
methods. They cannot be viewed using var_dump() or anything else which 
can examine objects.

A pain? Maybe. A bug? No.
There are a couple of user functions in the SimpleXML documentation 
comments that will convert a SimpleXML object to an array.  You can then 
pass that array to print_r for debugging.

Find the code here: http://www.php.net/manual/en/ref.simplexml.php
Cheers,
  Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] RM file - play time

2004-11-24 Thread Rick Fletcher
Alexander Kleshchevnikov wrote:
Can I get the information about paly time of the RM file by PHP?
IIRC, the getID3 library has support for reading RealAudio/Video.  You 
can find it here: http://getid3.sourceforge.net/

--Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Auto-load class if it doesn't exists!

2004-11-16 Thread Rick Fletcher
is it possible to have a solution that works like an autoloader... for 
example:

$myclass = new class();
but if this class wasn't loaded yet, it loads by itself... egg:
if(class_exists(class))
{
 $myclass = new class();
}
else
{
 require_once(PATH_DIR.'class.class.php');
$myclass = new class();
}
PHP5 has a callback for just this purpose.
A special function named __autoload() is called whenever an attempt is 
made to instantiate an undeclared class.  The function should then 
define the needed class.

I've been using it for months without any issue.
I just did a search and was suprised to see it's missing from the docs 
at php.net.  It's mentioned on zend.com though: 
http://www.zend.com/php5/articles/engine2-php5-changes.php#Heading19

--Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] calling function from function?

2004-11-11 Thread Rick Fletcher
 db( $defined[0], $defined[1], $defined[2], $defined[3] );
 which tells me that the $db handle is not being returned when called
 from the db() function from within the logs() function and I am not
 sure why?
it's being returned, you've just forgotten to assign it.  add a $db =  
to the beginning of that line and you should be good to go.

--Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Url encoding awry

2004-11-11 Thread Rick Fletcher
I have a dynamically created image labeled:
stories  critiques.jpg
I have use url encode on it when saving it, and it is stored on the server 
as:
stories+%26+crtitiques.jpg
[snip]
If I just put the path into the browser directly it also 404's
If I rename the file in any way that removes the % it works...
I thought % was a legal URL encoding character?
URL encoding the file's name on disk is causing your problems.  If you 
really want to keep it that way, you'll have to double encode the 
request, so that when it's decoded once you end up with 
stories+%26+crtitiques.jpg.  That's pretty needlessly complex.

Why not just leave the file named stories  critiques.jpg on disk and 
change your image tag to img src=stories amp; critiques.jpg/ ?

--Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] calling function from function?

2004-11-11 Thread Rick Fletcher
function db( $host, $user, $pass, $dbnam ) {
 $db = @mysql_pconnect( $host, $user, $pass )or die( mysql_error( $db ));
   @mysql_select_db( $dbnam )or die( mysql_error( $db ) );
 return $db;
}
function logs() {
 global $defined;
 db( $defined[9], $defined[1], $defined[2], $defined[3] );
 ... do some processing ...
}
what am i missing here? i get errors if i try to pass $db to logs. i.e. 
logs( $db );
What's missing?  The error message.  Include it, and the offending 
line(s) of code, and ask again.

--Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Programmatic Browser Rendering Engine?

2004-11-10 Thread Rick Fletcher
You might want to look at webthumb http://www.boutell.com/webthumb/
It is a linux command line utility that creates thumbnails of webpages. 
or khtml2png: http://www.babysimon.co.uk/khtml2png/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] $_FILES Not Populating On File Upload

2004-10-22 Thread Rick Fletcher
ApexEleven wrote:
I've googled the question and found no answer that has fixed my
problem. I also searched this list to try and find the answer to no
avail.
My problem is that after my form submits data to another script the
$_FILES global returns nothing but array() when I try to print_r()
it. 
[snip]
upload_tmp_dir=/tmp
Check to make sure the server has permission to write to /tmp.  I just 
took away write permission to my upload_tmp_dir and tested this scenario 
on my machine, and it behaved the way you're describing.

--Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Remote grabbed images are blank

2004-10-12 Thread Rick Fletcher
Mag wrote:
Hi,
I got a pretty good code snippet from Zend to grap a
remote image and save it to disk, the problem is, when
it saves to my disk i am unable to open the
images...they are blank and the file matches the
remote images filesize...
[snip]
  ob_start(); 
  readfile($url); 
  $img = ob_get_contents(); 
  ob_end_clean(); 
  $size = strlen($img); 

  [EMAIL PROTECTED]($filename, a); 
  fwrite($fp2,$img); 
  fclose($fp2); 
I'm not sure what the problem is, but simplifying the code will help you 
track it down.  Rather than messing with output buffering and 
fopen/fwrite/fclose, I'd suggest using the copy() function.

This line replaces the 8 lines above:
copy( $url, $filename );
--Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: OT gmail accounts

2004-09-20 Thread Rick Fletcher
Ricardo Cezar wrote:
I have some invitations too! If you wants one, ask me off list.
Limited supply, first requests, etc, like Greg said!
Greg Donald [EMAIL PROTECTED] escreveu na mensagem
news:[EMAIL PROTECTED]
I have some gmail accounts of anyone wants one.  Email me off list.
Limited supply, first requests, etc..
Please stop talking about gmail invites on the list.  Anyone who wants 
one, or who has some to give away, just do a google search for a place 
to get or give them.

Sites like this one (the 3rd result for free gmail invites) are acting 
as a proxy for free invites: http://isnoop.net/gmailomatic.php

--Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: OT gmail accounts

2004-09-20 Thread Rick Fletcher
Greg Donald wrote:
On Mon, 20 Sep 2004 12:15:18 -0700, Rick Fletcher [EMAIL PROTECTED] wrote:
Please stop talking about gmail invites on the list.  Anyone who wants
one, or who has some to give away, just do a google search for a place
to get or give them.
Sites like this one (the 3rd result for free gmail invites) are acting
as a proxy for free invites: http://isnoop.net/gmailomatic.php
You are a hypocrite.
You say to please stop talking about gmail invites, and then you
proceed to talk about where to get free ones, and even post a URL, as
if my free ones weren't good enough.  Pffft.

Meanwhile you offered no insight into my query about echo and print usage.
I think offering free email accounts to people who use email often is
very on-topic.  It's not like I posted a link to an ebay page.  GMail
has message threading, something every list serve member should be
using, and not all email clients support very well.
I didn't reply to your email.  The email I replied to mentioned nothing 
related to PHP.

When I replied I was trying to provide a pointer that would help out 
anyone who might have been interested by your thread, and at the same 
time, end it.

It's a PHP list.  If javascript related questions don't belong here (and 
there were a few just today that were ended with such a reply), then 
neither do gmail invite threads.

--Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: OT gmail accounts

2004-09-20 Thread Rick Fletcher
Greg Donald wrote:
I didn't reply to your email.  The email I replied to mentioned nothing
related to PHP.
Exactly.. you probably don't use a threaded email client, else you
might have noticed the thread was on-topic when I started it.  The
recursion is killing me here.  Need a GMail account?
I do use a threaded client, actually.  You're the one who didn't notice 
I replied to someone other than yourself.

When I replied I was trying to provide a pointer that would help out
anyone who might have been interested by your thread, and at the same
time, end it.
Hypocrasy..  all you wanted was the last word.
The last word?  Well, yeah.  I did say I was trying to end the thread.
It's a PHP list.  If javascript related questions don't belong here (and
there were a few just today that were ended with such a reply), then
neither do gmail invite threads.
Yeah, well.. you'll get over it.
Just for clarity, I don't personally have a problem with javascript 
questions on this list.  Sometimes they're pretty closely tied to 
something someone is trying to do in PHP.  I've never asked that a 
javascript thread be taken off list.

Unless you're working on PHP gmail APIs (as I bet someone is), gmail 
isn't at all tied to PHP.

Once again though, I didn't reply to your email.  Your gmail invite 
email (whose subject line was gmail accounts, not print() vs echo(), 
in case you'd forgotten) did have it's token I-better-throw-in-some-PHP 
content, after all.

BTW, trying to stay on-topic here.. did you prefer echo or print in
PHP?  Some of us old Perl guys kinda like print sometimes instead of
echo.  How about you?
Yeah, just like that.
At any rate, I'm done with this thread now.  In case you haven't had 
your fill of flaming someone for asking that the list be kept on topic, 
try one of the half dozen other authors of emails to that effect that 
have come through the list in the last day or two.

Cheers.
--Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] replace accents

2004-09-14 Thread Rick Fletcher
Diana Castillo wrote:
Anyone know of any function to replace letters with accents with just the 
regular letter, for instance replace  with a,
 with c,  with n ?
found this on the strtr() manual page (http://php.net/strtr):
?php
function removeaccents($string){
  return strtr(
strtr( $string,
  '',
  'SZszYAACNOOYaacnooyy' ),
   array(
 '' = 'TH', '' = 'th', '' = 'DH', '' = 'dh',
 '' = 'ss', '' = 'OE', '' = 'oe', '' = 'AE',
 '' = 'ae', '' = 'u' )
);
}
?
--rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] extended class question

2004-09-13 Thread Rick Fletcher
Ed Lazor wrote:
How come the output to this script is World Trade Center instead of Pizza
Delivery?
Thanks,
Ed

?php
class test {
private $var1;

function __construct() {
$this-var1 = World Trade Center;
}

function get_var1() {
return $this-var1;
}

function set_var1($data) {
$this-var1 = $data;
}
}
class testing extends test {
function __construct() {
parent::__construct();
$this-var1 = Pizza Delivery;
}
}
$test2 = new testing();
print var1 =  . $test2-get_var1() . br;
?
Because test's var1 is private.
test-var1 isn't accessible by class testing, so the assignment you're 
doing in testing's constructor is assigning Pizza Delivery to 
testing-var1 instead.

When you call $test2-get_var1() you're calling the parent's get_var1() 
method, which prints out the parent's var1 property. (which hasn't been 
touched.)

Change test's var1 to protected and it'll work.
--rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Looking for a TODO: parser.

2004-08-26 Thread Rick Fletcher
I'm looking for a program that will run through a directory tree and parse
all the files (ideally by extension, like *.php, *.js, *.html, *.c) and give
me a formatted output (or HTML table or something useful).
It should include the //TODO of course, the path/file, the line(s), and
perhaps other things I'm overlooking. Maybe last time file changed/file
date, and possibly the comments immediately below the //TODO: (as sometimes
they take up more than a single line).
Anyone know of or have built something like this... That is before I go and
re-invent the wheel.
This recursively gets you file path/name, line number, the matching line 
and the 2 that follow it.

$ grep -HrnA 2 TODO: /path/to/code/root
--rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Looking for a TODO: parser.

2004-08-26 Thread Rick Fletcher
This recursively gets you file path/name, line number, the matching 
line and the 2 that follow it.

$ grep -HrnA 2 TODO: /path/to/code/root
I get a parse error when I put that in my PHP file...
That's not PHP code.  It's the syntax for using a program called grep 
on the command line which would produce most of the results that Daevid 
was looking for.

More info on using grep can be found here: 
http://www.google.com/search?q=man%20grep

--rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] SimpleXML

2004-08-20 Thread Rick Fletcher
Daniel Schierbeck wrote:
I am having some problems with the XML features (I use the fancy new 
SimpleXML). It works like a dream when I'm retrieving information from 
an XML document, but when I want to insert new tags it screws up. I'm 
trying to create a function that saves error logs in an XML file, which 
should look like this:

?xml version='1.0' standalone='yes'?
errors
error
number2/number
stringCould not bla bla/string
filefilename.php/file
line56/line
/error
error
number1/number
stringFailed to bla bla/string
filefilename2.php/file
line123/line
/error
/errors
I tried to use SimpleXML myself and had some strange behavior, so I 
ended up switching to DOM.  I was already basically familiar with DOM 
anyway from javascript so development went quickly.  You should take a 
look: http://www.php.net/dom

There's more than one way to do it, of course, but code to add an 
element to this tree could look something like this:

?php
  // load the existing tree
  $doc = new DOMDocument();
  $doc-load( errors.xml );
  // count the number of existing error nodes
  $errors_node = $doc-documentElement;
  $error_count = $errors_node-getElementsByTagName( error )-length;
  // create the new error node...
  $error_node = $doc-createElement( error );
  // ...and its children
  $number_node = $doc-createElement( number, $error_count + 1 );
  $string_node = $doc-createElement( string, New error message );
  $file_node   = $doc-createElement( file,   foo.php );
  $line_node   = $doc-createElement( line,   32 );
  // add the children to the error node
  $error_node-appendChild( $number_node );
  $error_node-appendChild( $string_node );
  $error_node-appendChild( $file_node );
  $error_node-appendChild( $line_node );
  // add the new error node to the tree
  $doc-documentElement-appendChild( $error_node );
  // save back to the file
  $doc-save( errors.xml );
?
-- Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Anyone have experiences with OCI9 and PHP ??

2004-06-18 Thread Rick Fletcher
 is it possible to use an actuall Oracle-Client (Version = 9) 
 with PHP ??
 
 Dose anyone habe experiences here ?

It's absolutely possible, and where most of my work lies day to day.  Our
DBA has chosen to hold off upgrading to 10g until it's better tested, so we
still use 9i. (He cites a past experience of upgrading a prior company to 8i
early on in its life and managing to insert duplicate primary keys.)

For PHP 9i support you'd still compile using the --with-oci8 option.  Once
built PHP's oci8 functions still apply to 9i.

There are some 9i related comments on the php.net oci8 page:
http://us4.php.net/manual/en/ref.oci8.php

Cheers,
Rick

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Unexpected behaviuor with __CLASS__

2004-06-17 Thread Rick Fletcher
 on RedHat with PHP 4.3.6 the following code produces 'test' - 
 I'm expecting
 'test2':
 
 class test {
 function printClass() {
 echo __CLASS__;
 }
 }
 
 class test2 extends test {
 }
 
 test2::printClass();
 
 
 I would like to get/echo the name of the class calling the 
 method - in my case test2. Any ideas?

__CLASS__, and the other PHP magic constants are resolved at compile time.
The behavior you've experienced here is the correct one.

AFAIK there is no way to achieve your desired result without creating an
instance of test2 or overriding printClass() in test2.

Cheers,

Rick

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Syntax Help, Please

2004-06-15 Thread Rick Fletcher
 I've forgotten how to assign something like this...
 
 $someStr = EOF
   bunch of raw non-echo'd html
 
 EOF;
 
 But can't seem to get the right syntax. Tried looking in the 
 manual, but
 don't even know what I'm looking for!

You're looking for a heredoc.

http://www.php.net/manual/en/language.types.string.php#language.types.string
.syntax.heredoc

Cheers,

Rick

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Unit Testing

2004-06-15 Thread Rick Fletcher
Has anyone done any PHP unit testing? I've been looking around for a unit
testing library to try out. Below are the ones I've found so far:

SimpleTest: http://www.lastcraft.com/simple_test.php
PHPUnit (dead?): http://phpunit.sourceforge.net/
Pear PHPUnit: http://pear.php.net/package/PHPUnit
Generic PHP Framework (dead?): http://gpfr.sourceforge.net/

SimpleTest looks the most complete and the most active, so that's where I'm
leaning. Anyone have any experience with any of these libraries, or have any
comments on PHP Unit testing in general?

Thanks.

Rick

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Undiscovered Firefox...

2004-06-11 Thread Rick Fletcher
When you pasted that PHP code firefox did a google I'm feeling lucky
search on it.  If you go to google and manually do the I'm feeling lucky
search you should end up at the same place.

Yet another reason firefox deserves the top of the heap.

--Rick

 -Original Message-
 From: John Nichel [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, June 10, 2004 8:15p
 To: PHP List
 Subject: [PHP] Undiscovered Firefox...
 
 Okay, I'm sitting at home, writing a bit of code for one of 
 my personal 
 sites, and I'm currently working on a function to detect different 
 browser types.  Well, I think I have the URL to a page on one of my 
 boxes which echo's out the HTTP_USER_AGENT in my clipboard.  However, 
 what I have there is
 
 elseif ( preg_match ( /Firefox/, $_SERVER['HTTP_USER_AGENT'] ) ) {
 
 Well, I paste this into Firefox's URL bar and hit enter 
 before my brain 
 can tell my hands that this is not what I want to do.  Do I 
 get a could 
 not find server error from Firefox?  Nope.  It forwards me 
 to this page
 
 http://itangersjack.com/oddball/cheese.htm
 
 Nothing really special about the page, except it's revealing 
 source code 
 to something I'm currently working on (not in the way I'm 
 doing it, but 
 it's there).  Okay, it's late, and I'm easily amused. ;)
 
 -- 
 By-Tor.com
 It's all about the Rush
 http://www.by-tor.com
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] How to check for a $_GET without throwing a Notice?

2004-05-26 Thread Rick Fletcher
 How do I check for the presence of an optional $_GET param without 
 throwing a Notice: Undefined index when the param is not present?
 
 Tried all three of these, they all produce the Notice when 
 the param 
 is not passed:
 
 if ($_GET['id'])
 if ($_GET['id'] != )
 if (isset $_GET['id'])
 

 if (isset( $_GET['id']))

As a general note, isset( $array[key] ) returns false if $array[key] ===
NULL.  You should use array_key_exists( key, $array ) instead.

--Rick

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: clearing new pages

2004-05-26 Thread Rick Fletcher
  Hi,
   a file called a.php prints hello to the browser then calls 
  b.php which prints goodbye to the browser.
  the output looks like this:
 
  hello
  goodbye
 
  how do I clear the screen so the end results looks like this:
 
 a.php:
 
 echo 'hello';
 header('location: b.php'); exit;

That actually wouldn't work, because once there's output (echo) you can't
send a header.

--Rick

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] find out ip address [beginner]

2004-05-24 Thread Rick Fletcher
 hi, i need some code to find out the ip address of a server. 
 just a simple dns query.
 
 how do i do that? i'm a beginner, please help.

$ip = gethostbyname( www.php.net );

http://www.php.net/manual/en/function.gethostbyname.php

--Rick

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: Remove cahracters in string

2004-05-10 Thread Rick Fletcher
   Below is string let's name it A.
   
 ttPhiladelphiaFirstadate05Oct2004ttt
   ttt
  
   I want to get string B. That looks like
   PhiladelphiaFirstadate05Oct2004
  
   No characters before Philadelphia and after 20004
 
 Is the character you want to remove ('t') always the same?
 
 No. It just an example

An accurate example of what you're actually going to be doing would help.

For this example I would have suggested:

?php
  $str = PhiladelphiaFirstadate05Oct2004;

  $str = trim( $str, t );

  print( $str ); // outputs PhiladelphiaFirstadate05Oct2004
?

Cheers,
  Rick

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: Remove cahracters in string

2004-05-10 Thread Rick Fletcher
 For this example I would have suggested:
 
 ?php
$str = PhiladelphiaFirstadate05Oct2004;
 
$str = trim( $str, t );
 
print( $str ); // outputs PhiladelphiaFirstadate05Oct2004
 ?
 
 Cheers,
Rick
 

 t is not static character.  My example isn't correct
 
 Correct Example:
 tdahregdgfdhPhiladelphiaFirstadate05Oct2004ahahrehbGSG

Ok.

What do you know for certain about the leading and trailing garbage? For
Example: Is it always lowercase? Is it always the same number of characters?
Will the trailing garbage always begin after a 4 digit number?

There has to be some known characteristic of the junk before you can trim it
programmatically. Otherwise you'll never be able to trim it with absolute
accuracy.

Hope that makes sense.

Rick

(Please reply to the list, by the way.  Otherwise it doesn't help anyone
else.)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] virtual domain own php.ini

2004-04-22 Thread Rick Fletcher
 on most servers ini_set will be the best you can hope for
 
 security settings won't allow alternative php.ini file reads

If we're talking about Apache, you can place php config commands in an
.htaccess or httpd.conf file.  Those files can easily be associated with a
particular VirtualHost.

Check out: http://www.php.net/configuration.changes for more info.

--Rick

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Relative Url

2004-04-01 Thread Rick Fletcher
 Is there anyway that i can get a url relative to my server 
 for a script that is being run??
 
 The script is being included in mulitple files and 
 $_SERVER['SCRIPT_NAME'] just gives me the name of the file 
 that is including the other scripts.
 Also $_SERVER['SCRIPT_FILENAME'] is returning nothing.

I'm not completely sure I know what you're after.  If you're looking to get
the http path to an included file, this should work:

?php

$http_path = http://; . $_SERVER['SERVER_NAME'] .
 str_replace( $_SERVER['DOCUMENT_ROOT'], , __FILE__ );

?

If you're in windows I don't think the replace would work, because the
docroot's slashes go one way and the __FILE__ slashes go the other.  You'd
use something like strtr( __FILE__, \\, / ) before the replacement to
fix that.

Cheers,
Rick


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] blocking warning: Warning: fclose()

2004-03-30 Thread Rick Fletcher
 The problem is when the query does not succeed it outputs this:
 
 Warning: fclose(): supplied argument is not a valid stream 
 resource in c:\php\www\test-scripts\index.php on line 42
 
 is there any way to block just this warning while keeping 
 all other error handling as is?

Yes, the error control operator (@).

?php @fclose( $fp ); ?

Reference: http://www.php.net/manual/en/language.operators.errorcontrol.php

Though as another poster pointed out, adding some checking would be a better
approach.  You could simply test to see whether it is a resource, or even go
so far as to check that it's a file resource.

?php
if( is_resource( $fp )  get_resource_type( $fp ) == file ) {
  fclose( $fp );
}
?

Cheers,

Rick

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] SimpleXML node detection.

2004-03-24 Thread Rick Fletcher
   My peoblem is that i have something like the following xml...
 
 ~section
 ~namefoo/name
 ~contentfoo/content
 ~ignore /
 ~/section

   Any ideas on how i can check to see it the ignore node 
 exists or not?

You can't.  This is a bug that just recently came to the developers
attention, and is currently being discussed on the internals list.

Cheers,

Rick

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] $_POST not working with str_replace

2004-03-24 Thread Rick Fletcher
 Ok here's the deal, I cut out the middle man, went straight 
 to the script, assigned my variable a string, and loaded the 
 rtf page, NADA, ZIP, ZILCH!!

At least as far as this test is concerned, I hope you have a nice soft desk
to bang your head on.  Check your assignment operator one more time.

 ?php
 //print_r($_POST);
 //$na = $_GET['f'];
 $na == Me;

If your script has the same == where a plain ol' = should be, that'd
account for the replacement being empty (since it's replaced with $na, which
wasn't assigned).

As far as the original troubles you're trying to diagnose, I loosely
replicated your setup and everything worked as expected. (I just made up a
Lettertest.rtf file.)  Below are the working files, see if they work for
you:

Cheers,

Rick

Form.html:
=
HTML
BODY
FORM action=rtf1.php method=POST
INPUT type=text name=fname
INPUT type=submit value=Test
/FORM
/BODY
/HTML
=

rtf1.php:
=
?php
$name = $_POST['fname'];

$filename = Lettertest.rtf;

header( 'Content-Type: application/msword' );
header('Content-Disposition: inline, rtftest.rtf');

$fp = fopen( $filename, r );

$output = fread( $fp, filesize( $filename ) );

$output = str_replace( 'FNAME', $name, $output );

echo $output;
?
=

Lettertest.rtf:
=
a line of test
Hello, FNAME
another line
=

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Getting an Email into a PHP/pl script

2001-10-04 Thread rick fletcher

There's a good php POP3 class available here:
http://www.thewebmasters.net/php/POP3.phtml

That will enable you to log into your mail server and retrieve a mail
message from it.

 -Original Message-
 From: Chris Aitken [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, October 04, 2001 2:54 PM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: [PHP] Getting an Email into a PHP/pl script
 
 Hi all,
 
 I have looked into the archives but im not sure what im searching for
so I
 decided to ask here.
 
 What I want to do is, on my FreeBSD box running PHP and MySQL, to have
a
 system which will take any email sent to a specific address, and pipe
the
 body of the email to PHP (or even to a perl script). Once I have the
body
 of the email as a variable, I can do all my parsing and extracting etc
to
 do with it as I need, but im baffled on where to start looking to get
this
 done.
 
 Any help would be greatly appreciated.
 
 
 
 Cheers
 
 
 Chris
 
 
 
  Chris Aitken - Administration/Database Designer - IDEAL Internet
   email: [EMAIL PROTECTED]  phone: +61 2 4628   fax: +61 2 4628
8890
   __-__
 It is said that if you line up all the cars in the world end to
end,
   some moron in a rotary will still to try and pass them
 
 
 --
 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 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]