OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 30 Dec 2005 21:08:55 -0000 Issue 3879

php-general-digest-helplists.php.net
Date: Fri Dec 30 2005 - 15:08:55 CST


php-general Digest 30 Dec 2005 21:08:55 -0000 Issue 3879

Topics (messages 227998 through 228050):

Re: what is the problem with this query?
        227998 by: sunaram patir
        228036 by: Richard Lynch

Re: PHPMailer inserting unwanted spaces
        227999 by: Lam Cheuk Hin

Re: interfaces - your opinion
        228000 by: Jochem Maas
        228003 by: Marco Kaiser
        228033 by: Richard Lynch

Re: php / JS / DOM question
        228001 by: Jochem Maas
        228005 by: Stut
        228006 by: Jochem Maas
        228007 by: Stut
        228027 by: Robert Cummings

HAPPY NEW YEAR!!
        228002 by: Jesús Alain Rodríguez Santos

Re: Strange Right-Shift Problem
        228004 by: Jochem Maas
        228029 by: Richard Lynch
        228048 by: Michael Gross

Re: unable to load perl extension
        228008 by: Jochem Maas
        228034 by: Richard Lynch

Re: Variables and Strings
        228009 by: Jochem Maas
        228011 by: Jay Blanchard
        228013 by: Jochem Maas
        228014 by: Jay Blanchard
        228015 by: John Nichel
        228016 by: Jay Blanchard
        228018 by: John Nichel
        228019 by: Jay Blanchard
        228038 by: Richard Lynch

Which is faster, a MySQL access, or a set of PHP variables?
        228010 by: Dave M G
        228012 by: Jochem Maas
        228017 by: Miles Thompson
        228031 by: Richard Lynch

nifty little tools
        228020 by: tedd
        228021 by: Jochem Maas
        228022 by: Jay Blanchard
        228025 by: tedd
        228026 by: John Nichel

Re: nifty little tools - resposity - evaluations..
        228023 by: tg-php.gryffyndevelopment.com
        228024 by: Jay Blanchard
        228032 by: tg-php.gryffyndevelopment.com

connecting to oracle 9i
        228028 by: Sue Errico
        228030 by: Richard Lynch

Re: XML-RPC problem with long running times
        228035 by: Richard Lynch

Re: XML Reader
        228037 by: Richard Lynch

Re: Location ....
        228039 by: Richard Lynch
        228040 by: Robert Cummings
        228045 by: Richard Lynch

Re: download not working
        228041 by: Richard Lynch

Re: list a query
        228042 by: Richard Lynch

Re: SELECT?
        228043 by: Richard Lynch
        228046 by: Paul Waring

Re: Storing serialized data to DB
        228044 by: Richard Lynch

Re: Varchar "date" to real date?
        228047 by: Richard Lynch

Re: php / mysql / js search result question
        228049 by: Richard Lynch

Re: any https / php gotchas ???
        228050 by: Richard Lynch

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


thanks. i have resolved the problem by replacing 'read' with 'read_it'.
On 12/30/05, Michael Gross <listsmdgrosse.net> wrote:
> "read" is a reserved word in mysql
> (http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html). You have
> to double-quote reserved words:
>
> mysql_query("SELECT * FROM mailbox WHERE \"read\"=''");
>
> Graham Cossey wrote:
> > On 12/29/05, Jay Blanchard <jay.blanchardthermon.com> wrote:
> >> [snip]
> >> could you please tell me what is the problem with this query
> >> mysql_query("SELECT * FROM mailbox WHERE read=''");
> >>
> >> i always get this warning:
> >> Warning: mysql_num_rows(): supplied argument is not a valid MySQL
> >> result resource in index.php on line 24
> >> [/snip]
> >>
> >> THere is no apparent problem with the query, but there is a problem with
> >> mysql_num_rows(). Can you show us he code there?
> >>
> > I would hazard a guess that mysql_num_rows() is not being passed the
> > correct query result handle as a parameter.
> >
> > ie: $result = mysql_query(...);
> > $rows = mysql_num_rows($result);
> >
> > --
> > Graham
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


On Thu, December 29, 2005 7:26 am, sunaram patir wrote:
> could you please tell me what is the problem with this query
> mysql_query("SELECT * FROM mailbox WHERE read=''");

Nope.

Because on the face of it, there is NOTHING wrong with the query
written above, per se.

> i always get this warning:
> Warning: mysql_num_rows(): supplied argument is not a valid MySQL
> result resource in index.php on line 24

While *I* can't tell you what is wrong, and nobody on this entire list
could tell you what is wrong, MySQL and PHP are just BEGGING to tell
you what's wrong:

$result = mysql_query($query) or die(mysql_error());
http://php.net/mysql_error

Actually, there *IS* one obvious thing "wrong" with the query:
You used "SELECT * " and that is a horrible horrible habit to get into.
Don't do it.
Name the columns you actually want.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Can You Write The Strings/Text?

On 12/30/05, René Fournier <m5renefournier.com> wrote:
>
> Has anyone encountered this? I am composing an HTML email with
> PHPMailer, and for some reason PHPMailer is inserted spaces
> periodically, which breaks the formatting. I've looked through the
> docs, but can only find a setting for Word Wrap (which is set to 0).
>
> ...Rene
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
lch2003

attached mail follows:


hi Marco,

I want to apply the idea to interface implementation not
class extension. that is to say I want to be able to make an
interface only implementable by certain (defined) classes (and their
subclasses) with out imposing any restriction on the classes
themselves (like that they must extend a certain base class in order
to have the 'implementable by' check performed.

IFAICT this is not really possible - but maybe somebody sees a way,
then again maybe it's too silly an idea to even consider it.
regardless thanks for your feedback.

rgds,
jochem

Marco Kaiser wrote:
> Hi Jochem,
>
> try this.
>
> <?php
>
> abstract class AClass
> {
> private $allowedClasses = array(
> 'MyClass',
> 'MyOtherClass'
> );
> final public function __construct()
> {
> if (!in_array(get_class($this), $this->allowedClasses)) {
> throw new Exception('not allowed classes: ' . __CLASS__);
> }
>
> // if (($this instanceof MyClass) ||
> // ($this instanceof MyOtherClass)) {
> // throw new Exception('not allowed class: ' . __CLASS__);
> // }
> }
> }
>
>
> class MyClass extends AClass {}
>
> class MyOtherClass extends AClass {}
>
> class NotMyClass extends AClass {}
>
> new MyClass();
> new MyOtherClass();
> new NotMyClass();
>
>
> --
> Marco Kaiser

attached mail follows:


Hi Jochem,

i know what you mean, but you can't define code in interfaces to implement a
logic. You should use an abstract class to restrict the access. I think a
interface should just define a rude prototype of function ....

--
Marco Kaiser

attached mail follows:


On Thu, December 29, 2005 10:31 am, Jochem Maas wrote:
> anyone here work with Interfaces? I do and I like them alot;
>
> I recently ran into a situation where it would be nice to be able to
> specify
> that a given interface is only allowed to be implemented by a certain
> class (and all subclasses thereof) - Anyone have an idea as to how
> to implement such a restraint in a clean way? does anyone think that
> this
> is generally useful?
>
> maybe it's something that should not be done at all.
> maybe the implementation belongs in the engine (with some new syntax)
> e.g:
>
> class MyClass {}
> class MySubClass extends MyClass {}
> class MyOtherClass {}
> class SomebodyElsesClass {}
>
> interface MyIface validfor MyClass, MyOtherClass
> {
> abstract function blabla();
> }
>
> // SomebodyElsesClass would not be able to implement MyIface
>
>
> interested to know if anyone has an opinion on this.

I don't use Interfaces and all that stuff, but...

Seems to me that every explanation I've ever heard for using
Interfaces in the first place was to provide an abstract definition of
what a class was supposed to implement, and that any class that
implemented the required functionality should, in some theoretical
la-la land, be a suitable replacement for any other class.

Seems to me that if you restrict the implementation to a specific
branch of classes, you're kinda defeating the whole purpose of an
Interface, based on my rudimentary understanding of what an Interface
is supposed to be.

I'm sure it makes perfect sense in the context you need, but...

Makes me think maybe an Interface isn't what you ought to be using in
the first place...

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Al wrote:
> jonathan wrote:
>
>> I know that this is more of a Javascript / DOM question but I cannot
>> for the life of me figure this out:
>>
>> I have this form:
>>
>> <form name="query_form">
>> <input type="text" name="q"></input>
>> <input type="button" onclick="drawImg('A',document.forms
>> ['query_form'].elements['q']);" value="Search"></input>
>> </form>

get firefox and learn to use the javascript console, the DOM inspector and
the javascript debugger in that order - in this case the DOM inspector
would have been your biggest friend as it would have shown you 'correct'
name for the element (object) whose value you were trying to grab - in general
the DOM inspector is very handy for learning more about the structure
and the content of the DOM.

>>
>> When the user clicks on the button, I want the text that is in input
>> elment 'q' to be sent to the Javascript function drawImg but when I
>> debug it via alerts, it appears to be NULL. Looking at the examples
>> online, I feel like this should work. Does anybody know why this
>> might not be working correctly?
>>
>> -jonathan
>
>
> You need to ask in the JAVASCRIPT newsgroup. This is not a php question.

anyone every noticed that the question as to where a good javascript mailing
can be found comes up every week or so. and nobody ever has an answer.

so where the **** is this 'JAVASCRIPT newsgroup' ??

<wait thats not a php question either - maybe we can ask John Nichel
to ajudicate the validity of the question in light of the 'somehow
related to IBM' criteria [which is in fact the true measure of a relevant
question on this list]> ;-)

>

attached mail follows:


Jochem Maas wrote:

> Al wrote:
>
>> You need to ask in the JAVASCRIPT newsgroup. This is not a php
>> question.
>
>
> anyone every noticed that the question as to where a good javascript
> mailing
> can be found comes up every week or so. and nobody ever has an answer.
>
> so where the **** is this 'JAVASCRIPT newsgroup' ??

comp.lang.javascript

Damn, that was hard to find!

-Stut

attached mail follows:


I eat my shoe. ;-)

... but is comp.lang.javascript any good?

Stut wrote:
> Jochem Maas wrote:
>
>> Al wrote:
>>
>>> You need to ask in the JAVASCRIPT newsgroup. This is not a php
>>> question.
>>
>>
>>
>> anyone every noticed that the question as to where a good javascript
>> mailing
>> can be found comes up every week or so. and nobody ever has an answer.
>>
>> so where the **** is this 'JAVASCRIPT newsgroup' ??
>
>
> comp.lang.javascript
>
> Damn, that was hard to find!
>
> -Stut

attached mail follows:


A: Yes I did.
Q: Did you fix the to posting?

Jochem Maas wrote:

> Stut wrote:
>
>> Jochem Maas wrote:
>>
>>> Al wrote:
>>>
>>>> You need to ask in the JAVASCRIPT newsgroup. This is not a php
>>>> question.
>>>
>>>
>>>
>>>
>>> anyone every noticed that the question as to where a good javascript
>>> mailing
>>> can be found comes up every week or so. and nobody ever has an answer.
>>>
>>> so where the **** is this 'JAVASCRIPT newsgroup' ??
>>
>>
>>
>> comp.lang.javascript
>>
>> Damn, that was hard to find!
>>
>> -Stut
>
> I eat my shoe. ;-)
>
> ... but is comp.lang.javascript any good?

Pass, but for what should be obvious reasons I would ask JS questions
there before here.

-Stut

attached mail follows:


On Fri, 2005-12-30 at 07:45, Jochem Maas wrote:
> Al wrote:
> > jonathan wrote:
> >
> >> I know that this is more of a Javascript / DOM question but I cannot
> >> for the life of me figure this out:
> >>
> >> I have this form:
> >>
> >> <form name="query_form">
> >> <input type="text" name="q"></input>
> >> <input type="button" onclick="drawImg('A',document.forms
> >> ['query_form'].elements['q']);" value="Search"></input>
> >> </form>
>
> get firefox and learn to use the javascript console, the DOM inspector and
> the javascript debugger in that order - in this case the DOM inspector
> would have been your biggest friend as it would have shown you 'correct'
> name for the element (object) whose value you were trying to grab - in general
> the DOM inspector is very handy for learning more about the structure
> and the content of the DOM.

Just a comment on Firefox, I've been doing a lot of Javascript lately
(I'm working on a sub windowing library and I must say firefox/mozilla
are render pigs. I attach more than 3 on move listeners to move with the
dragged pane and firefox becomes choppy crap soup. Opera and even
Internet Exploder can easily handle 50, and show a bit of lag when I
increase to 100 listener objects. Opera owns for speed though.

For debugging I use a custom data browser service that works in the 3
main browsers which has the nice advantage of seeing all the lovely
different field names that each browser uses *lol*.

http://www.interjinn.com/jinnDocJavaScript/interJinnJavaScript.class.JinnDataBrowser.phtml

And similar for debug echos:

http://www.interjinn.com/jinnDocJavaScript/interJinnJavaScript.class.JinnOutputDebugger.phtml

I just wish all these damn browsers would work the same way for DHTML :(

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


Happy New Year for all.
I weish you the best in this new 2006.
Regards. Alain
--
Este mensaje ha sido analizado por MailScanner
en busca de virus y otros contenidos peligrosos,
y se considera que está limpio.

attached mail follows:


Michael Gross wrote:
> Hello
> I have to migrate a PHP-application to a new Linux-Box. Both the old and
> the new system are Linux and PHP 5.1.1. (the old one has a Pentium 4,
> the new one two Xeon CPUs). I have a problem using the
> Crypt_Xtea-Extension. I narrowed it down to the following right-shift

looking at the class I draw the conclusion that it reqires the use of
[some] data in 'long' format (i.e. integers) and the code requires and
assumes that such integers are 32bits long ... which they are on 32bit
systems ... but not on 64bit systems . here in lies the problem, you need
someone more knowledgable than I to give you an actual solution though.

> operation:
>
> (-3281063054 >> 11) produces different results:
> Old System: 495070

this is what you get with a 32bit CPU

> New System: -1048576

this is what you get with a 64bit CPU

>
> I understand that both results are "wrong", but everything worked with
> the old behavior and I need that behavior back very urgent.
>
> Maybe someone can explain me in which way the bits are shifted so that
> the result is 495070? If I understand it, I implement my "own" shift

$a << $b Shift left Shift the bits of $a $b steps to the left (each step means "multiply by two")
$a >> $b Shift right Shift the bits of $a $b steps to the right (each step means "divide by two")

> function.
>
>
> thanks a lot
> Michael Gross
>

attached mail follows:


On Thu, December 29, 2005 5:37 pm, Michael Gross wrote:
> Hello
> I have to migrate a PHP-application to a new Linux-Box. Both the old
> and
> the new system are Linux and PHP 5.1.1. (the old one has a Pentium 4,
> the new one two Xeon CPUs). I have a problem using the
> Crypt_Xtea-Extension. I narrowed it down to the following right-shift
> operation:
>
> (-3281063054 >> 11) produces different results:
> Old System: 495070
> New System: -1048576
>
> I understand that both results are "wrong", but everything worked with
> the old behavior and I need that behavior back very urgent.
>
> Maybe someone can explain me in which way the bits are shifted so that
> the result is 495070? If I understand it, I implement my "own" shift
> function.

Assuming the previous hypothesis that it's 32-bit versus 64-bit
machines at work...

If you can determine the number of bits on your system, you could use
a different number from 11 on the two systems to get the answer you
want.

if (is_32_bit_machine()){
  $y = $x >> 11;
}
else{
  $y = $x >> 43; //11 + 32 (guess)
}

One hack for detecting 32-bit machine might be this:

function is_32_bit_machine(){
  return mt_getrandmax() == 0xffffffff;
}

I suppose if you're going to do this right, what you REALLY should do
is code it to determine the number of bits, no matter how large, and
then bit-shift the correct amount based on that.

So when the 128-bit machines come out in a few years, you aren't
re-coding this same damn problem AGAIN.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Hello
Thanks for your answers. I now implemented everything new, with the
mcrypt-extension. However, I use the crypt_xtea still for a
compatibility mode. I had to implement the right-shift and other bit
operations. If someone is interested:

The problem occurred always when a number exceeded the 32bit and is
negative. The old behavior was to take 32bits and ignore the other bits
(therefore the sign could change in the rshift-operation). The following
simulates the old behavior:
   function getbits($i) {
       $bits = array();
       while (abs($i) > 1) {
           $f1 = floor($i / 2.0);
           $f2 = ceil($i / 2.0);
           if ($f1!=$f2) {
               array_push($bits, 1);
           } else {
               array_push($bits, 0);
           }
           $i = $f1;
       }
       return $bits;
   }

   function convertto32($i) {
       $bits = getbits($i);
       $i = 0;
       if ($bits[ 0]) $i|=0x00000001;
       if ($bits[ 1]) $i|=0x00000002;
       ....
       if ($bits[31]) $i|=0x80000000;
       return $i;
   }

   function rshift($i, $n) {
       if ($i < -2147483648) {
           $i = convertto32($i);
       }
       return $i >> $n;
   }

thx
   Michael Gross

Richard Lynch wrote:
> On Thu, December 29, 2005 5:37 pm, Michael Gross wrote:
>> Hello
>> I have to migrate a PHP-application to a new Linux-Box. Both the old
>> and
>> the new system are Linux and PHP 5.1.1. (the old one has a Pentium 4,
>> the new one two Xeon CPUs). I have a problem using the
>> Crypt_Xtea-Extension. I narrowed it down to the following right-shift
>> operation:
>>
>> (-3281063054 >> 11) produces different results:
>> Old System: 495070
>> New System: -1048576
>>
>> I understand that both results are "wrong", but everything worked with
>> the old behavior and I need that behavior back very urgent.
>>
>> Maybe someone can explain me in which way the bits are shifted so that
>> the result is 495070? If I understand it, I implement my "own" shift
>> function.
>
> Assuming the previous hypothesis that it's 32-bit versus 64-bit
> machines at work...
>
> If you can determine the number of bits on your system, you could use
> a different number from 11 on the two systems to get the answer you
> want.
>
> if (is_32_bit_machine()){
> $y = $x >> 11;
> }
> else{
> $y = $x >> 43; //11 + 32 (guess)
> }
>
> One hack for detecting 32-bit machine might be this:
>
> function is_32_bit_machine(){
> return mt_getrandmax() == 0xffffffff;
> }
>
> I suppose if you're going to do this right, what you REALLY should do
> is code it to determine the number of bits, no matter how large, and
> then bit-shift the correct amount based on that.
>
> So when the 128-bit machines come out in a few years, you aren't
> re-coding this same damn problem AGAIN.
>

attached mail follows:


dev lamp wrote:
> On 12/29/05, Jochem Maas <jochemiamjochem.com> wrote:
>
>>dev lamp wrote:
>>
>>>Hi
>>>
>>>I am unable to call perl code from PHP, since the extension does not
>>>get loaded !
>>>
>>>Scenario 1:
>>>use dl('perl.so'); in the php code and invoke the script from the command line
>>>The script works fine and the perl code gets executed as well.
>>
>>so the extension is not being loaded automatically right?
>>but if you dl() it everything is fine, right?
>>then double check the 'right' ini file is being used!
>>
>
>
> There is only one php.ini
> I have checked the extensions path information using phpinfo().

you not only have to specify the correct extension dir you
also have to specify [in your php.ini] each and every extension that you want
to load e.g:

extension=perl.so

or alternatively (no need for the extension dir to be set):

extension=/complete/path/to/your/perl.so

>
> Is there something else that I need to checkout ?
>
>
>>is the apache module using the php.ini that you think it is ?? -
>>that kind of thing has caught me out more than once!
>>
>>
>
> How do I check that ?
> I downloaded apache sources and compiled it.
> Why do I need to specify the path of the php.ini file to the apache web server ?

the php apache module needs to know where the php.ini can be found - usually
set at compile time - the place it's kept varies from OS to OS (which has caught me out
before!).

>
>
> Dev.
>

attached mail follows:


On Thu, December 29, 2005 9:17 am, dev lamp wrote:
> I am unable to call perl code from PHP, since the extension does not
> get loaded !
>
> Scenario 1:
> use dl('perl.so'); in the php code and invoke the script from the
> command line
> The script works fine and the perl code gets executed as well.
>
> Scenario 2:
> the perl extension does not get loaded and the PHP script crashes.

Define "crashes"...

Does it literally crash the PHP/Apache process, or does it just print
out "Not loaded"?

Either way, crank up your error settings to E_ALL and check your
Apache error log to find out *WHY* it's not getting loaded.

Could you live with:
<?php
  exec("/usr/local/bin/perl script.pl", $output, $error);
  $output = implode("<br />\n", $output);
  if ($error) die("OS Error: $error<br />\n$output");
  echo $output; //probably do something more interesting here
?>

> I have read the article
> http://www.zend.com/php5/articles/php5-perl.php
>
> If anybody has faced this issue, please share how you solved the
> problem ?
>
> Thanks in advance.
> ----
> Here are the environment Details:
> RHEL 4.0
> PHP 5.0.5 (self compiled)
> PECL/PERL package checked out from CVS
>
> PHP 5.0.5 compilation details
> ---------------------------
> ./configure --with-apxs2=/usr/local/apache2/bin/apxs
> --with-mysql=/usr/bin/mysql_config
> --with-mysqli=/usr/bin/mysql_config --with-openssl-dir=/usr/local/ssl
> --with-libxml-dir=/usr/lib --enable-soap --enable-sockets
> --enable-sqlite-utf8 --enable-wddx --with-gnu-ld --with-gd
> --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/local/lib
> --with-zlib-dir=/usr/local/lib --with-gd=/usr/local
> --enable-gd-native-ttf --enable-maintainer-zts --with-pear
> make
> make install
>
>
> pecl/perl package compilation details
> -------------------------
> export PHP_PREFIX="/usr/local"
> export PERL_PREFIX="/usr"
> echo $PHP_PREFIX
> echo $PERL_PREFIX
> $PHP_PREFIX/bin/phpize
> ./configure --with-perl=$PERL_PREFIX
> --with-php-config=$PHP_PREFIX/bin/php-config
> make
> make install
>
> entries in php.ini file
> --------------
>
> extension_dir = "/usr/local/lib/php/extensions/no-debug-zts-20041030/"
> extension=perl.so
>
>
> sample test code is as follows -
> <?php
> if (!extension_loaded('perl'))
> {
> print "perl extension not loaded";
> exit;
> }
> ?>
>
> --
> Dev.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Jim Moseby wrote:
>>Thanks for the responses guys, but what i'm saying is i would

...

>
> I believe what Jochem is trying to tell you is that when you assign the
> string variable, the variable names are expanded to their values, so the
> names are no longer available.

exactly - nicely put Jim.

>
> Consider this:
>
> $partname='widget';
> $amount=100;
>
> $string="This $partname costs $amount dollars";
>
> /*
> $string now equals "This widget costs 100 dollars", so when you pass it to
> your function, it has no way to know for sure what the variables were, or
> that there even were ANY variables involved in the generation of the string.
>
> The variable NAMES are not passed because PHP expands them to their values
> and sets $string accordingly.
> */
>
> $string='This $partname costs $amount dollars';
>
> $string now equals "This $partname costs $amount dollars". In this case, I
> used single quotes. The values are not expanded and the variable NAMES are
> passed. The VALUE of the variables are not. So you could then have a
> function look for any word that starts with a $ and return an array of
> names.

hopefully thats clear to the OP now - and he can [re]state his goal in
order that we might point him into a more fruitful direction!

>
> That all being said, what in the world are you trying to do with this? I
> bet you $1.78 (the change in my desk drawer) there is a much better way to
> solve whatever problem it is than the way you are trying here.

yeah 'Superman' explain what it is you want to do AND why - then maybe we can
give you some help - what you are currently asking is impossible (well actually
Jay Blanchard hinted at a way to do it but I firmly believe that its conceptually
over your head atm and very probably not a good solution to what you want to acheive -
which is not to say that Jays hint was crap or wrong; more like the problem you
posed originally is moot.)

>
> JM
>
> Because it ruins the flow of the conversation.

evil genius ;-)

>
>>Why is top posting a bad thing?
>
>

attached mail follows:


[snip]
yeah 'Superman' explain what it is you want to do AND why - then maybe we
can
give you some help - what you are currently asking is impossible (well
actually
Jay Blanchard hinted at a way to do it but I firmly believe that its
conceptually
over your head atm and very probably not a good solution to what you want to
acheive -
which is not to say that Jays hint was crap or wrong; more like the problem
you
posed originally is moot.)
[/snip]

We actually wrote a little code doohickey called Variable Hunter in which
the doohickey could be run within a project folder and locate all of the
variables with their respective name spaces and lines numbers. Nifty little
tool.

attached mail follows:


Jay Blanchard wrote:
> [snip]
> yeah 'Superman' explain what it is you want to do AND why - then maybe we
> can
> give you some help - what you are currently asking is impossible (well
> actually
> Jay Blanchard hinted at a way to do it but I firmly believe that its
> conceptually
> over your head atm and very probably not a good solution to what you want to
> acheive -
> which is not to say that Jays hint was crap or wrong; more like the problem
> you
> posed originally is moot.)
> [/snip]
>
> We actually wrote a little code doohickey called Variable Hunter in which
> the doohickey could be run within a project folder and locate all of the
> variables with their respective name spaces and lines numbers. Nifty little
> tool.

ah heck is that the same code that _we_ (Jay and me, etc) played with to find SQL queries?
or something that was based on it?
I remember Robin Vickery coming up with a token based variant which was rather nifty -
must look into that agian sometime!

rgds,
JOchem

>

attached mail follows:


[snip]
ah heck is that the same code that _we_ (Jay and me, etc) played with to
find SQL queries?
or something that was based on it?
I remember Robin Vickery coming up with a token based variant which was
rather nifty -
must look into that agian sometime!
[/snip]

They are all variants of that. All nifty little tools. We should gather
those up someplace...shouldn't we?

attached mail follows:


Jay Blanchard wrote:
> [snip]
> yeah 'Superman' explain what it is you want to do AND why - then maybe we
> can
> give you some help - what you are currently asking is impossible (well
> actually
> Jay Blanchard hinted at a way to do it but I firmly believe that its
> conceptually
> over your head atm and very probably not a good solution to what you want to
> acheive -
> which is not to say that Jays hint was crap or wrong; more like the problem
> you
> posed originally is moot.)
> [/snip]
>
> We actually wrote a little code doohickey called Variable Hunter in which
> the doohickey could be run within a project folder and locate all of the
> variables with their respective name spaces and lines numbers. Nifty little
> tool.
>

I wrote a doohickey once which searched for all variable searching
doohickies.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
jnicheldotcomholdingsofbuffalo.com

attached mail follows:


[snip]
I wrote a doohickey once which searched for all variable searching
doohickies.
[/snip]

I cannot tell you how happy I am to see you use the past perfect tense
correctly there.

attached mail follows:


Jay Blanchard wrote:
> [snip]
> ah heck is that the same code that _we_ (Jay and me, etc) played with to
> find SQL queries?
> or something that was based on it?
> I remember Robin Vickery coming up with a token based variant which was
> rather nifty -
> must look into that agian sometime!
> [/snip]
>
> They are all variants of that. All nifty little tools. We should gather
> those up someplace...shouldn't we?
>

Well, I just purchased some domains for that. Who wants to develop it? ;)

phpdepository.com
phpdepository.org
phpdepository.net

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
jnicheldotcomholdingsofbuffalo.com

attached mail follows:


[snip]
> They are all variants of that. All nifty little tools. We should gather
> those up someplace...shouldn't we?
>

Well, I just purchased some domains for that. Who wants to develop it? ;)

phpdepository.com
phpdepository.org
phpdepository.net
[/snip]

I'll contribute.......

attached mail follows:


On Thu, December 29, 2005 3:31 pm, PHP Superman wrote:
> Thanks for the responses guys, but what i'm saying is i would like to
> return
> all the variable names i have in a string,
> $String="Blah Blah Blah $VarName Blah Blah Blah";

$VarName = 'xyz';
$String now has "Blah Blah Blah xyz Blah Blah Blah" in it.

There is *NOTHING* left to indicate that xyz came from a variable.

You simply do not have the context available to do what you want.

Now, you *COULD* do like this:

$VarName = 'xyz';
$Template = 'Blah Blah Blah $VarName Blah Blah Blah';

Note the use of single quotes that does NOT interpret variables.

You now have a $Template from which, with luck, you could:
A) compose $String using:
eval('$String = "$Template";');

B) use something not unlike this:
preg_match_all('/\\$([a-z0-9_]+/sU', $Template, $variables);
foreach($variables[1] as $varname){
  echo "$varname = ", $$varname;
}

I'll warn you right now that whatever it is you are doing, there is
PROBABLY a better easier way to do it, but you've put on blinders to
other solutions and only asked us how to do what you think you want to
do, which is probably not what you really want to do...

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


PHP General,

        I have a site where I will set the interface up to be multilingual.
This means that all the snippets of text which make up the menu and
other elements of navigation common to most pages will be stored as
variables.

        In most web site set ups that I have seen, especially on forums, the
text is stored in a PHP script which is just a long list of variables.

        I wondered if there was any downside to storing the list of interface
texts in a MySQL database, then calling them as an array when the page
loads?

        This would have one minor advantage, which is that as I expand to new
languages, I could build a simple web interface where people could input
new languages into a form.

        However, is it a drag on a server to have to reach into the MySQL
database to retrieve the array of texts each time the page loads? Note
that the texts will be something like 20 to 30 small one to four word
phrases like "contact" and "previous page" and that sort of thing.

        On the surface, it doesn't seem like this would be much different than
accessing a PHP script with a list of variables. But then, I figured
there might be a reason why I've never seen it done this way.

        Opinions would be much appreciated.

--
Dave M G

attached mail follows:


Dave M G wrote:
> PHP General,
>
> I have a site where I will set the interface up to be multilingual.
> This means that all the snippets of text which make up the menu and
> other elements of navigation common to most pages will be stored as
> variables.
>
> In most web site set ups that I have seen, especially on forums, the
> text is stored in a PHP script which is just a long list of variables.
>
> I wondered if there was any downside to storing the list of interface
> texts in a MySQL database, then calling them as an array when the page
> loads?
>
> This would have one minor advantage, which is that as I expand to new
> languages, I could build a simple web interface where people could input
> new languages into a form.

true - rather than trying to writing an interface thats _properly_ capable
tf editing phpb-like language files - which although not impossible is a lot
more difficult to make fool-proof than one first imagines (I have very
ingenious 'fools' who want to edit stuff like that!)

>
> However, is it a drag on a server to have to reach into the MySQL
> database to retrieve the array of texts each time the page loads? Note
> that the texts will be something like 20 to 30 small one to four word
> phrases like "contact" and "previous page" and that sort of thing.

using var_export() you can write the array to a file on a TMPFS filesystem
(e.g. /dev/shm) as a cache and have a cmdline script or something that you run
whenever you want the lang itmes to be updated - reading a single small file in off
disk (which in the case of TMPFS is in RAM - bonus!!!) will be faster in general
than querying MySQL and building the array.

essentially this gives you the best of both world - with the added bonus of
begin able to easily control publication of updates to the lang items.

>
> On the surface, it doesn't seem like this would be much different than
> accessing a PHP script with a list of variables. But then, I figured
> there might be a reason why I've never seen it done this way.

basically unless you have some killer site thats taking a beating and
needs to take performance very seriously in order to stay in the air then either
way will do fine. a DB call on every request is somewhat wasteful but a low traffic
site won't mind one little bit.

>
> Opinions would be much appreciated.
>
> --
> Dave M G
>

attached mail follows:


At 10:32 AM 12/30/2005, Dave M G wrote:

>PHP General,
>
> I have a site where I will set the interface up to be multilingual.
>This means that all the snippets of text which make up the menu and
>other elements of navigation common to most pages will be stored as
>variables.
>
> In most web site set ups that I have seen, especially on forums, the
>text is stored in a PHP script which is just a long list of variables.
>
> I wondered if there was any downside to storing the list of interface
>texts in a MySQL database, then calling them as an array when the page
>loads?
>
> This would have one minor advantage, which is that as I expand to new
>languages, I could build a simple web interface where people could input
>new languages into a form.
>
> However, is it a drag on a server to have to reach into the MySQL
>database to retrieve the array of texts each time the page loads? Note
>that the texts will be something like 20 to 30 small one to four word
>phrases like "contact" and "previous page" and that sort of thing.
>
> On the surface, it doesn't seem like this would be much different
> than
>accessing a PHP script with a list of variables. But then, I figured
>there might be a reason why I've never seen it done this way.
>
> Opinions would be much appreciated.
>
>--
>Dave M G

Dave,

I did that for an online auction site, now defunct, where the languages
could be German or English. To expand to Spanish one had only to supply the
structure and have someone who knew one of the other languages to enter the
correct terms. That would be pasted into the script and run, presto, the
site was available in Spanish.

Database hits ere not a problem, as all of the content on the page came
from a database, none of the content was static.

That was three years ago, and it was done that way because native language
support was "wobbly" in both PHP and Apache.

Joachem's solution is probably better for today.

Cheers - Miles Thompson

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.371 / Virus Database: 267.14.9/216 - Release Date: 12/29/2005

attached mail follows:


On Fri, December 30, 2005 8:32 am, Dave M G wrote:
> I wondered if there was any downside to storing the list of interface
> texts in a MySQL database, then calling them as an array when the page
> loads?

If you are already connecting to the database, then you are comparing
an extra query or two to loading a file from the hard drive and the
database wins on performance.

Unless you are already loading some file where it would be convenient
to stick the text, and then the variables win.

Actually, this all depends on your hardware and database/drive
performance setup...

There really is NOT a good answer to this question from a
"performance" stand-point.

But then it's not a good question, really, unless you REALLY expect
your site to get a ton of traffic, because the performance of the
machine will probably not be a big factor in your success, compared to
maintainability of code, feature-set of the site, cool-ness and
prettiness and marketing and... All of those will matter more to your
success than raw performance.

> This would have one minor advantage, which is that as I expand to new
> languages, I could build a simple web interface where people could
> input
> new languages into a form.

Something to consider:

Can you get data in other character sets into and out of your database
and web application?

If you plan to support 2-byte (or more) character sets, this is not
trivial at all -- or maybe it is, but you have to at least plan ahead
for it from the get-go.

> However, is it a drag on a server to have to reach into the MySQL
> database to retrieve the array of texts each time the page loads? Note
> that the texts will be something like 20 to 30 small one to four word
> phrases like "contact" and "previous page" and that sort of thing.
>
> On the surface, it doesn't seem like this would be much different
> than
> accessing a PHP script with a list of variables. But then, I figured
> there might be a reason why I've never seen it done this way.

Generally, on most projects, the people who are contributing the
translations of internal things like "contact" and "previous page" are
developers who are comfy with editing a text file, and putting them in
as text files with, say CVS or subversion, gives the developers
control over versioning etc.

That's not to say you COULDN'T do something similar with the database,
or run hourly dumps of (some) tables into CVS or something.

I don't think it's going to matter much which way you do this, so long
as you can plan ahead for all the character-encodings you will ever
need, and make sure you can handle them all.

Perhaps try it with a test phrase like "Hello" which you can probably
find in every language fairly easily.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


>They are all variants of that. All nifty little tools. We should gather
>those up someplace...shouldn't we?

In similar light, what development environments do you people program
in? How do you run and test your code?

tedd

PS: This is my first posting to this group.
--
--------------------------------------------------------------------------------
http://sperling.com/

attached mail follows:


tedd wrote:
>> They are all variants of that. All nifty little tools. We should gather
>> those up someplace...shouldn't we?
>
>
> In similar light, what development environments do you people program
> in? How do you run and test your code?

of late I have been testing Zend IDE - the integrated debugger is the biggest + point
for me.

I also use UltraEdit and TextPad [vi, aee, nano on linux].

test code with:
        php -l
        echo/var_dump()/print_r()
        Zend IDE
        xdebug
        browser ;-)

your question has been asked before - you might find the list archives
gives you more insight into other peoples work envs.

>
> tedd
>
> PS: This is my first posting to this group.

attached mail follows:


[snip]
>They are all variants of that. All nifty little tools. We should gather
>those up someplace...shouldn't we?

In similar light, what development environments do you people program
in? How do you run and test your code?

tedd

PS: This is my first posting to this group.
[/snip]

Welcome to the insanity.

I use Eclipse. For testing I have a test server where all of the code gets
hammered using a combination of automated and live user units. I am in a
microsoft shop, but have migrated web app servers to Apache (save for one
that I just cannot get rid of yet due to legacy ASP).

attached mail follows:


>Welcome to the insanity.

Thanks -- been there for a while.

>your question has been asked before - you might find the list archives
>gives you more insight into other peoples work envs.

Yep, you're right.

http://news.php.net/php.general

I probably should have looked there first. Sorry.

Pardon me for being a novice about this, but besides Google, is there
a way to search the archives? Over 200k of postings is a lot to look
through.

tedd
--
--------------------------------------------------------------------------------
http://sperling.com/

attached mail follows:


tedd wrote:
>> Welcome to the insanity.
>
>
> Thanks -- been there for a while.
>
>> your question has been asked before - you might find the list archives
>> gives you more insight into other peoples work envs.
>
>
> Yep, you're right.
>
> http://news.php.net/php.general
>
> I probably should have looked there first. Sorry.
>
> Pardon me for being a novice about this, but besides Google, is there a
> way to search the archives? Over 200k of postings is a lot to look through.
>
> tedd

http://marc.theaimsgroup.com/?l=php-general&r=1&w=2

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
jnicheldotcomholdingsofbuffalo.com

attached mail follows:


Wasn't this just brought up on another thread? "nifty little tools" that is and a repository for such things.

There are lots of code repositories but none that I go directly to right off. Usually I hit Yahoo/Google and do a search for what I'm looking for and find whatever looks best for my situation. That way, in theory, I find some of the newest/freshest ideas and techniques. Not always the best, but it's usually a starting place.

<tangent>
Since you asked..

I use Zend Studio (http://www.zend.com) and Crimson Editor (http://www.crimsoneditor.com)... if not just Notepad/vi/other-generic-text-editor-native-to-OS>. My workmate uses Komodo (http://www.activestate.com/Products/Komodo/).
</tangent>

I've found that people ask these kinds of questions over and over again.. and there are so many great websites out there with great code snippets or information in general. And never a lack of people who give opinions on what their favorite is... be it framework, php editor, or favorite brand of shiraz.

So a little while ago I registered userrated.com (nothing there now but an image cropping test script done in PHP...with an awesome pic of a pirate llama... you heard me!).

Anyway, my idea for this site is to create a review site for such things like PHP editors or even someone's favorite wine, restaurent, flea market, whatever. So when someone on the PHP list asks about flea markets...err... editors.. You can say "Go to userrated.com and hit the PHP section".

The idea would be to enter just about anything and have properties associated with the item that can be itemized or just rated.

PHP Editors:
  Version [free entry]
  OS's supported [list]
  Ease of Use [1-5]
  IDE? [Y/N/Partial?]
  Debugger? [Y/N/Partial?]
  Stability [1-5]
  Overall impression [1-5]

Wine:
  Type [free entry or checkbox?]
  Origin [free entry]
  Dry-Sweet [1-5]
  Year
  Vineyard
  Color
  Whatever-else-wine-snobs-judge-by :)

And the other thing I'd like to do with it is be able to show all ratings/reviews/comments or filter by date range because sometimes things become outdated or obsolete or were great a year ago and now aren't supported anymore. So if you showed "all dates" it may say "Average rating 7.5" but if you showed the 100 ratings giving in the last 2 months, it may drop to "4.0".

Just throwing this out there in case anyone has any thoughts or comments or hell.. maybe a site already exists that does all this.

Two things inspired this idea... (1) the constant weekly "What PHP editor do you use? What's the best?" questions (hah) and (2) my lack of ability to remember all the odd restaurants, wines, beers, camping spots, dog groomers, whatever that my girlfriend and I check out. Was that Indian restaurant in Baltimore any good? Was it the one on Charles Street or down near Lexington Market that was the good one with the all-you-can-eat curry at lunch on weekends? (*shiver* scary hah)

So when I get un-lazy and stop playing World of Warcraft long enough to do some PHP projects.. is this something anyone would find useful? I'd like to open it up so just about anyone can create a category and add "properties" to the item being rated. Probably have to approve items so it doesn't get crazy, but still might be cool.

Ok... off to stare at the pirate llama for a bit so I don't have to do real work.

-TG

= = = Original message = = =

[snip]
>They are all variants of that. All nifty little tools. We should gather
>those up someplace...shouldn't we?

In similar light, what development environments do you people program
in? How do you run and test your code?

tedd

PS: This is my first posting to this group.
[/snip]

Welcome to the insanity.

I use Eclipse. For testing I have a test server where all of the code gets
hammered using a combination of automated and live user units. I am in a
microsoft shop, but have migrated web app servers to Apache (save for one
that I just cannot get rid of yet due to legacy ASP).

___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

attached mail follows:


[snip]
A buncha' top posted stuff....
[/snip]

I like the idea....and the llama.

attached mail follows:


Haha.. well, with any luck, 10 years from now I'll have as much content. hah (or even ANY code written)

= = = Original message = = =

I sort of had the same idea almost a decade ago...

http://l-i-e.com/compare/

You can see how well I've kept it up :-v

On Fri, December 30, 2005 10:33 am, tg-phpgryffyndevelopment.com wrote:
> Wasn't this just brought up on another thread? "nifty little tools"
> that is and a repository for such things.
>
> There are lots of code repositories but none that I go directly to
> right off. Usually I hit Yahoo/Google and do a search for what I'm
> looking for and find whatever looks best for my situation. That way,
> in theory, I find some of the newest/freshest ideas and techniques.
> Not always the best, but it's usually a starting place.
>
> <tangent>
> Since you asked..
>
> I use Zend Studio (http://www.zend.com) and Crimson Editor
> (http://www.crimsoneditor.com)... if not just
> Notepad/vi/other-generic-text-editor-native-to-OS>. My workmate uses
> Komodo (http://www.activestate.com/Products/Komodo/).
> </tangent>
>
> I've found that people ask these kinds of questions over and over
> again.. and there are so many great websites out there with great
> code snippets or information in general. And never a lack of people
> who give opinions on what their favorite is... be it framework, php
> editor, or favorite brand of shiraz.
>
>
> So a little while ago I registered userrated.com (nothing there now
> but an image cropping test script done in PHP...with an awesome pic of
> a pirate llama... you heard me!).
>
> Anyway, my idea for this site is to create a review site for such
> things like PHP editors or even someone's favorite wine, restaurent,
> flea market, whatever. So when someone on the PHP list asks about
> flea markets...err... editors.. You can say "Go to userrated.com and
> hit the PHP section".
>
> The idea would be to enter just about anything and have properties
> associated with the item that can be itemized or just rated.
>
> PHP Editors:
> Version [free entry]
> OS's supported [list]
> Ease of Use [1-5]
> IDE? [Y/N/Partial?]
> Debugger? [Y/N/Partial?]
> Stability [1-5]
> Overall impression [1-5]
>
> Wine:
> Type [free entry or checkbox?]
> Origin [free entry]
> Dry-Sweet [1-5]
> Year
> Vineyard
> Color
> Whatever-else-wine-snobs-judge-by :)
>
> And the other thing I'd like to do with it is be able to show all
> ratings/reviews/comments or filter by date range because sometimes
> things become outdated or obsolete or were great a year ago and now
> aren't supported anymore. So if you showed "all dates" it may say
> "Average rating 7.5" but if you showed the 100 ratings giving in the
> last 2 months, it may drop to "4.0".
>
> Just throwing this out there in case anyone has any thoughts or
> comments or hell.. maybe a site already exists that does all this.
>
> Two things inspired this idea... (1) the constant weekly "What PHP
> editor do you use? What's the best?" questions (hah) and (2) my lack
> of ability to remember all the odd restaurants, wines, beers, camping
> spots, dog groomers, whatever that my girlfriend and I check out. Was
> that Indian restaurant in Baltimore any good? Was it the one on
> Charles Street or down near Lexington Market that was the good one
> with the all-you-can-eat curry at lunch on weekends? (*shiver* scary
> hah)
>
> So when I get un-lazy and stop playing World of Warcraft long enough
> to do some PHP projects.. is this something anyone would find useful?
> I'd like to open it up so just about anyone can create a category and
> add "properties" to the item being rated. Probably have to approve
> items so it doesn't get crazy, but still might be cool.
>
> Ok... off to stare at the pirate llama for a bit so I don't have to do
> real work.
>
> -TG
>
> = = = Original message = = =
>
> [snip]
>>They are all variants of that. All nifty little tools. We should
>> gather
>>those up someplace...shouldn't we?
>
> In similar light, what development environments do you people program
> in? How do you run and test your code?
>
> tedd
>
> PS: This is my first posting to this group.
> [/snip]
>
> Welcome to the insanity.
>
> I use Eclipse. For testing I have a test server where all of the code
> gets
> hammered using a combination of automated and live user units. I am in
> a
> microsoft shop, but have migrated web app servers to Apache (save for
> one
> that I just cannot get rid of yet due to legacy ASP).
>
>
> ___________________________________________________________
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

attached mail follows:


I am running php 5.0
apache 2.0
oracle 9i on a windows platform
 
receiving the following error:
 
Fatal error: Call to undefined function oci_connect() in C:\Program Files\Apache Group\Apache2\htdocs\Sue\testoci.php on line 3

I edited the php.ini
I uncommenting the extension=php_oci8.dll (removed ;)
and changed the
extension_dir = "C:/php/ext"
 
I stopped and stopped apache and it still get the same error
can you please help or direct me to someone that can?
Thanks!
Happy New Year!

attached mail follows:


First, use <?php phpinfo()?> to determine several things:

Where does PHP think your php.ini file should be?
Move your php.ini file there, and then change it.
Changes to other php.ini files in other places is pointless.
There is a new-fangled Apache directive to tell PHP where to find
php.ini, but it's easier to just move the darn thing.

After you re-start Apache (again) does <?php phpinfo();?> show that
Oracle is available? It will either be listed in that page, or it
ain't there.
Until Oracle is listed as installed, oci_connect() will remain undefined.

Check the 'extensions_directory' in php.ini to be sure it's right.

On Fri, December 30, 2005 12:16 pm, Sue Errico wrote:
> I am running php 5.0
> apache 2.0
> oracle 9i on a windows platform
>
> receiving the following error:
>
> Fatal error: Call to undefined function oci_connect() in C:\Program
> Files\Apache Group\Apache2\htdocs\Sue\testoci.php on line 3
>
> I edited the php.ini
> I uncommenting the extension=php_oci8.dll (removed ;)
> and changed the
> extension_dir = "C:/php/ext"
>
> I stopped and stopped apache and it still get the same error
> can you please help or direct me to someone that can?
> Thanks!
> Happy New Year!
>
>

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


If you can't get at the PHP internal time-out...

First, file a bug report "Feature Request" and ask for it to be
exposed. You won't be the only one who needs it.

Second, for the short term, you may be stuck with rolling your own
XMLRPC interface, or using one of the others "out there" as raw PHP
that will perhaps give you more control of stream time limits.

You MIGHT be able to dig through PHP source and alter the time-out and
re-compile... But remembering to do that on an upgrade would be a
PITA.

On Thu, December 29, 2005 8:58 am, Andreas Schlicker wrote:
> Of course, fflusch($log); should be fflush($log);
>
> I just found out that $xmlResponse really is empty.
> However, connection_status() returns 0, so I assume that the script is
> not interrupted by a timeout.
>
> Why does xmlrpc_server_call_method($xmlServer, $xmlRequest, NULL)
> return
> nothing if the call takes longer than 5 minutes and there is no
> interrupt? Is there some "special" XMLRPC timeout?
>
> Any idea?
>
> Andreas
>
>
> Andreas Schlicker schrieb:
>> Hi all,
>>
>> I'm using Apache/1.3.33 (Unix), PHP/5.0.3, mod_ssl/2.8.22,
>> OpenSSL/0.9.6a.
>>
>> I wrote a dummy script that is called by a Java program via XML-RPC,
>> waits for some time and replies the start and end times.
>>
>> <?php
>> set_time_limit(500);
>> $xmlServer = xmlrpc_server_create();
>>
>> function process() {
>> $result = ini_get('max_execution_time') . "\n";
>> $result = $result . date("H:i:s") . "\n";
>> sleep(0);
>> $result = $result . date("H:i:s") . "\n";
>> return $result;
>> }
>>
>> xmlrpc_server_register_method($xmlServer, 'process', 'process');
>> $xmlRequest = $HTTP_RAW_POST_DATA;
>> $xmlResponse = xmlrpc_server_call_method($xmlServer, $xmlRequest,
>> NULL);
>>
>> #$log = fopen($filename, 'a');
>> #fwrite($log, $xmlResponse);
>> #fflusch($log);
>> #fclose($log);
>>
>> echo $xmlResponse;
>> xmlrpc_server_destroy($xmlServer);
>> ?>
>>
>> If the script sleeps for up to 5 minutes, it works perfectly fine.
>> However, I my real application will run probably an hour or so. If
>> the
>> script takes more than 5 minutes to execute, the client receives an
>> empty response, even the header is missing. If I try to write the
>> $xmlResponse to a file, the client receives a null message.
>>
>> I wrote a small script without XMLRPC that acted the same way when
>> called by a browser. This worked perfectly (I tested it up to 20
>> minutes
>> waiting time) even if I used set_time_limit(5) and sleep(500).
>>
>> Does anybody have an idea how to solve this problem? Thanks in
>> advance.
>>
>> Andreas
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Thu, December 29, 2005 12:40 am, benc11gmail.com wrote:
> Is there any easy php script to run to view an xml file such as new
> headlines like so: http://news.google.com/?output=rss or can anyone
> point
> me in the right direction for good online tutorials or books.

If you mean to just READ the XML, do this:
<?php
  $xml = file_get_contents("http://news.google.com/?output=rss") or
die("Unable to read Google RSS at this time. Please try again
later.");
?>

If you need to get just the headlines, you could do:
<?php
  preg_match_all("/<title>([^<]*)<\\/title>/sU", $xml, $headlines);
  var_dump($headlines[1]);
?>

You could do similar work to get any of the content you wanted from
the XML.

Or you could use Google to search for "PHP RSS parser" and find
innumerable solutions.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Wed, December 28, 2005 8:15 am, Christian Ista wrote:
> PHP? I tried this code : header("Location: mypage.php");
>
> But in some case, I have error message "headers already sent". Then I

You know the old saying, "You can't step in the same stream twice"?

Think about it.

Really think about it.

Now...

The data being sent to the browser from Apache/PHP is a stream.

Its raw output looks something like this:

---------------------------------------------------------------
HTTP/1.1 200 OK
Date: Fri, 30 Dec 2005 19:52:44 GMT
Server: Apache/1.3.34 (Unix) DAV/1.0.3 PHP/4.4.1 mod_ssl/2.8.25
OpenSSL/0.9.7d-p1
X-Powered-By: PHP/4.4.1
Connection: close
Content-Type: text/html

<HTML>
        <HEAD>
                <TITLE>Lynch Interplanetary Enterprises</TITLE>
        </HEAD>
.
.
.
</HTML>
---------------------------------------------------------------
Now, pay VERY close attention to that blank line right after the
Content-type: text/html
line.

That BLANK line marks the end of the "headers"

Everything above the blank line is in the "headers"
Everything below is the "body" of the HTTP, which is what the browser
shows you with "View Source"

Now, imagine all that output, headers and blank line and body,
streaming out from your server, like water from a garden hose.

There's a lot you can do to it before the water gets shot out the end
of the nozzle.

You could add a water heater and treat your lawn to a warm shower
instead of cold.

You could add a filtration system and give your lawn distilled water.

You could add a plant food system to give it yummy chemicals.

Buuuuuuuuuuuuuuuuuuuuuut

Once that water leaves the host, you don't have a lot of control over it.

It's gone.

Beyond re-calling.

In the same way, once PHP sends the BLANK LINE to denote the end of
headers, you can't send more headers.

This works:

---------------------------------------------------------------
HTTP/1.1 200 OK
Date: Fri, 30 Dec 2005 19:52:44 GMT
Server: Apache/1.3.34 (Unix) DAV/1.0.3 PHP/4.4.1 mod_ssl/2.8.25
OpenSSL/0.9.7d-p1
X-Powered-By: PHP/4.4.1
Connection: close
Content-Type: text/html
Location: mypage.php

<HTML>
        <HEAD>
                <TITLE>Lynch Interplanetary Enterprises</TITLE>
        </HEAD>
.
.
.
</HTML>
---------------------------------------------------------------

This can NOT work:

---------------------------------------------------------------
HTTP/1.1 200 OK
Date: Fri, 30 Dec 2005 19:52:44 GMT
Server: Apache/1.3.34 (Unix) DAV/1.0.3 PHP/4.4.1 mod_ssl/2.8.25
OpenSSL/0.9.7d-p1
X-Powered-By: PHP/4.4.1
Connection: close
Content-Type: text/html

<HTML>
Location: mypage.php
        <HEAD>
                <TITLE>Lynch Interplanetary Enterprises</TITLE>
        </HEAD>
.
.
.
</HTML>
---------------------------------------------------------------

Look carefully for the position of the line
Location: mypage.php

See the difference?

If you try to call the header() function AFTER some content has been
sent, then you get the error message.

Move the header() line earlier in your PHP code, and it will work fine.

PS
Blank lines and spaces COUNT as "output".

So this:
<?php $x = 1; ?> <?php header("Location: mypage.php");?>
will NOT work because that space "counts"

This will work:
<?php $x = 1; ?><?php header("Location: mypage.php");?>

Similarly, watch out for BLANK LINES after the last ?> in your files.

They will trip you up for header()

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Fri, 2005-12-30 at 15:04, Richard Lynch wrote:
> On Wed, December 28, 2005 8:15 am, Christian Ista wrote:
> > PHP? I tried this code : header("Location: mypage.php");
>

*LOL* That was one of the best write-ups I've ever read concerning the
headers already sent error message.

> Similarly, watch out for BLANK LINES after the last ?> in your files.
>
> They will trip you up for header()

Regarding that last ?> in scripts, the PHP engine intentionally supports
it's omission so that you don't have to think about whether there's an
invisible trailing space after it.

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


On Fri, December 30, 2005 2:16 pm, Robert Cummings wrote:
>> Similarly, watch out for BLANK LINES after the last ?> in your
>> files.
>>
>> They will trip you up for header()
>
> Regarding that last ?> in scripts, the PHP engine intentionally
> supports
> it's omission so that you don't have to think about whether there's an
> invisible trailing space after it.

I'm old.

In PHP 3.0, it would mess you up.

Particularly fun was the EMACS setting that automagically added a
newline for any text file you edited that didn't have one at the
end...

*THAT* sure caused a lot of "fun" on this list back in the day. :-)

Old habits die hard.

Plus, somewhere, I probably have a PHP 3.0 install still running on
some old box... Not tied directly to the 'net nor in production, but
still... :-)

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Wed, December 28, 2005 6:10 am, Ross wrote:
> $query= "SELECT * FROM publications WHERE alphabet='a'";
>
> $result= mysql_query($query);
> while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
>
> $row['pdf_size'] = $row['pdf_size']/ 1024;
> $row['pdf_size']= number_format($row['pdf_size'], 0);
> $size= $row['pdf_size'];
> $name = str_replace("_", " ", $row['pdf_name']);
> $name = str_replace(".pdf", "", $name);
> $link= $row['content'];

You are echo-ing out these lines whether $_GET['id'] isset or not.

Which means that your PDF isn't starting with:
%PDF3.1
.
.
.

> echo "<span class=\"pdflinks\">$name</span>";
> echo "&nbsp;&nbsp;";
> echo "<span class=\"sizes\">($size kb)</span>";

Your PDF now looks like:
<span class="pdflinks">foo</span>
&nbsp;&nbsp;
<span class="sizes">(25 kb)</span>
%PDF3.1
.
.
.

And that's a pretty corrupt PDF, eh?

For the future:

#1. Always use 'vi' or some kind of text editor to view your "corrupt"
files that PHP sends out. Invariably you'll smack yourself in the
forehead and be back in business in minutes.

> ob_clean();
> header("Content-length: $pdf_size");
> header("Content-type: $pdf_type");

#2. You can also comment this out until you get it looking right,
rather than go through the process of downloading and opening and all
that. You'll just see a lot of weird stuff in your browser, but
that's okay.

> header("Content-Disposition: attachment; filename=$pdf_name");

CHANGE THIS TO:

header("Content-type: application/octet-stream");

if you want this to work in ALL browsers.

The Content-Disposition stuff is johnny-come-lately made-up junk that
will NOT be reliable.

To force the filename to be what you want, just take on "/$pdf_name"
to the URL.

I've ranted enough about this before, so you should be able to find
more detail on how to make this really slick with ForceType and
URL-munging.

Search archives for:
"Richard Lynch pathinfo.inc ForceType" and it should come up.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Wed, December 28, 2005 5:53 am, Ross wrote:
> What does 'list' do in a php query?

'list' is kind of like an array de-constuctor.

<?php
$example = array(1, 2, 3);
list($x, $y, $z) = $example;
echo "x: $x y: $y z: $z\n\n";
?>
x: 1 y: 2 z: 3

> $result = mysql_query($query) or die('Error, query failed');
> list($name, $type, $size, $content) = mysql_fetch_array($result);

$result is an array:

array('Ross', 'Hosting Company', 'Comfy', 'aztechost.com');

'list' is tearing that array apart into individual variables.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Wed, December 28, 2005 2:50 am, William Stokes wrote:
> I have one MySQL table with about 500 rows. I need to read the table
> one row
> at a
> time, make some changes to data in one field and then store the
> changed data
> to another table.
>
> I'm using PHP to change the data but I have no idea how to select one
> row at
> a time from the DB table. There's one auto-increment id field in the
> table
> but the id's doesn't start from 1 and are not sequential.

The suggestions so far are good, but watch out for this:

If you do one record at a time, and are using LIMIT, and then
something gets inserted into the original table...

Boom!

Ordering by the auto_increment will "work" to make sure the new rows
are at the end, but that's kind of icky to rely on in production code.

Your best bet probably is to just get all 500 records and process them
in one batch.

After that, adding a column to mark records "done" or not is good.

Relying solely on LIMIT and auto_increment is only okay for a quick
one-time hack you'll never need again... And still kind of icky.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On 12/30/05, Richard Lynch <ceol-i-e.com> wrote:
> The suggestions so far are good, but watch out for this:
>
> If you do one record at a time, and are using LIMIT, and then
> something gets inserted into the original table...
>
> Boom!

You could always lock the tables whilst performing the update - not
very useful if the database has to be up all the time but it's
probably the safest way of doing it.

Paul

--
Data Circle
http://datacircle.org

attached mail follows:


On Tue, December 27, 2005 7:11 pm, Sumit Chachra wrote:
> Not very php specific so please pardon me if I am posting in the wrong
> forum.
>
> I have a chunk of data which I am trying to cache. I serialize this
> data
> using the serialize() function in php. I am wondering what would be a
> good
> attribute type in my DB to store such (potentially long) strings? Some
> types
> have 4000 character limits and hence I get JDBC exceptions. I am using
> Oracle DB.

My first answer would be:

Don't put it in the database. Throw it in /tmp or a disk file
somewhere and put the file path into the database.

If you HAVE to put it in the database, then you'd better:
1. Determine the MAXIMUM size of the serialize($chunk) of data.
2. Double that.
3. Find a data type in your database that is BIGGER than that.
4. The only answer is probably a BLOB.

Internally, the database engine is most likely storing the BLOB as a
separate file anyway, and you're getting very very very little gain
out of putting it into the database. See first answer. :-)

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Tue, December 27, 2005 8:01 am, William Stokes wrote:
> I have a DB that has dates stored in a table. The date field type is
> Varchar
> (don't ask why... :( The dates are stored using european date format
> DD.MM.YYYY. I need somehow convert the dates to the format MySQL uses
> (YYYY-MM-DD) and re-store them to a table which has a real date column
> for
> them.

alter table crappy add whatdate date;
update crappy set date = ws_cat('-', substring(eurodate,
7,4),substring(eurodate,3,2),substring(eurodate,1,2));

Once you have a REAL date column, date_format from
http://dev.mysql.com/ is your friend.

> If I can get this done how can I still display the dates in european
> format
> at my web page? Do I have to break the date to pieces and some how
> re-arrange it to the DD.MM.YYYY format or is the some clever function
> for
> this that can automatically do this?

select date_format(whatdate, '%d.%m.%Y') from nice_table;

Personally, it's given the *WORLD* wide web, I'd suggest letting the
visitor choose their date format, rather than forcing them to use the
format that happens to be in vogue in the country hosting the site...
:-)

Not that I've ever had time to do that, mind you, but it's what I'd
recommend :-) :-) :-)

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Tue, December 27, 2005 2:03 am, Dave Carrera wrote:
> I have a very long list of customer names which i know is easy to get
> from a mysql result using php, no prob there.

How long is very long?...

> But what i would like to do is offer input box and when the user
> enters
> a letter, i think this will require client side onchange(), the full
> list, i think might be in an iframe, will move to the first instance
> of
> user input.
>
> Example:
>
> 1 Alpha Customer
> 2 Apple Customer
> 3 Beta Customer
> 4 Crazy customer
> 5 Doppy customer
>
> User input is "a" so the list moves to first instance of "a". User
> continues to input "ap" so the list moves to "2 Apple Customer" and so
> on.

*IF* your visitor is using a decent browser and OS, then that's
EXACTLY how this works:

<select size="10">
  <option>Alpha Customer</option>
  <option>Apple Customer</option>
  .
  .
  .
</select>

On crappy systems, only the FIRST letter they type "counts". So they
can jump to "A" but not to "Ap" for Apple. Ugh.

But you should not be dumping a VERY long list to the browser --
Anything more than a few hundred (and that's pushing it) should
probably not be in a list of choices.

I've got one such list with 2000 in it, but ONLY for an Intranet where
I know it's always high-bandwidth and trusted/trained users.

At any rate, this is all browser side, and so it has NOTHING to do
with PHP.

You'll need to research JavaScript and Flash choices to get on to the
browser side of things.

I've also had good luck with giving an 'a b c d e ... z' and paging
navigation for larger sets. Up to a point.

At some point, you really do need to have a search input box and go
from there.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Mon, December 26, 2005 1:42 am, Dave Carrera wrote:
> Are there any https / php gotchas to take into consideration for an
> app
> i am writing that will run within a https environment ???
>
> Thank you in advance for any advice or links regarding this question.

HTTPS can be considerably slower than HTTP.
Clearly divide your application pages into HTTPS and HTTP pages.

Then you need to be SURE all your links and FORM ACTION= into and out
of HTTPS do the right thing to minimize the time in HTTPS land.

Real Users (tm) get nervous earlier than they should about the little
lock icon in their browser not being locked.

For a shopping cart, put the whole thing into HTTPS, if you can, even
if you really don't need to from a security stand-point. That goes
against the minimalization advice above, but...
"Contact" page, no HTTPS. Shopping Cart, HTTPS.
You'll figure out the rest. :-)

Some (and in trying to sell things, "some" is "too many" no matter how
small "some" may be)... Some will abandon the cart when they don't
see the "locked" icon.

Ugly garish logos of how "secure" your site is (ugh!) must also
impress users, for reasons beyond my ken, because I sure see a lot of
those.

Make a fake certificate and test and re-test on your development box
for all the HTTPS stuff.

You do NOT want to leave that as last-minute, even if it "seems" to be
working on the dev site, even though you have no actually HTTPS set
up. It *will* bite you in the butt somehow if you don't actually run
HTTPS and work with it.

--
Like Music?
http://l-i-e.com/artists.htm