[PHP] Re: Apache

2013-09-23 Thread Tim Streater
On 23 Sep 2013 at 11:37, Domain nikha.org  wrote: 

> The problem is the weak PHP upload mechanism! 

I'd have said the problem is weak metadata provision - overloading the filename 
for other purposes.

--
Cheers  --  Tim

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

[PHP] Re: Friday's Question

2013-09-20 Thread Tim Streater
On 20 Sep 2013 at 18:20, Jen Rasmussen  wrote: 

> -Original Message-
> From: Tedd Sperling [mailto:t...@sperling.com]

> 70Toothpaste, Deodorant, Aftershave, Minoxidil, Preparation-H, Bag
> Bomb, Fixodent

> LOL. What in the heck is a Bag Bomb?

I have no idea what most of these items are except the toothpaste.

--
Cheers  --  Tim

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

[PHP] Re: Friday's Question

2013-09-20 Thread Tim Streater
On 20 Sep 2013 at 17:51, Tedd Sperling  wrote: 

> Age: Fast approaching doddering old fossil stage
> Mousepad: Yes. I use an Apple Mighty Mouse so that I can scroll my Excel 
> spreadsheet in two directions at once while moving the mouse pointer across 
> the screen. The optics works slightly better on the pad (covered in butterfly 
> pix) than it would on the pine desktop.


--
Cheers  --  Tim

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

[PHP] Re: exec and system do not work

2013-08-26 Thread Tim Streater
On 26 Aug 2013 at 22:01, PhD Ethan Rosenberg  
wrote: 

>>> if( !file_exists("/var/www/orders.txt"));

^
|
What's the semicolon doing there ---+

>>> {
>>> echo system("touch /var/www/orders.txt", $ret);
>>> echo system("chmod 766 /var/www/orders.txt", $ret);
>>> echo 'file2';
>>> echo file_exists("/var/www/orders.txt");
>>> }

> If you would point out my syntax errors, I will fix them.

See above.

--
Cheers  --  Tim

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

[PHP] Re: PHP vs JAVA

2013-08-21 Thread Tim Streater
On 20 Aug 2013 at 23:59, PHP List  wrote: 

> While I don't have any references to back it up - my guess would be that
> Java may be seen as more versatile in general programming terms.  A
> staggering number of enterprise level web applications are built with
> Java, add to that the possibility of writing Android apps with the same
> knowledge.

To me the salient point is, does java has as extensive a library or set of 
interfaces to other packages (such as SQLite, mysql, etc)?

> I would say that, in general, the other teacher is incorrect speaking
> strictly in terms of web development.  PHP has already won that crown
> many times over.  That said, when I was in University, it was difficult
> to find a programming class that taught anything but Java - and that was
> 10yrs ago now.  I chalked it up to the education bubble not being able
> to see what the rest of the world is actually doing.

Was PHP OOP-capable at the time? Perhaps the edu-bubble was simply looking down 
its nose at PHP. There being lots of courses proves nothing in and of itself. 
20 years ago, there were lots of PC mags you could buy, which caused some folks 
to say "look how much better the PC is supported than other platforms". Truth 
was, at the time, such support was needed given the mess of 640k limits, DOS, 
IRQs and the like, most of which issues have ceased to be relevant.

Anyway, why should one need a course to learn PHP, assuming you already know 
other languages. It's simple enough.

--
Cheers  --  Tim

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

[PHP] Re: how to see all sessions sets in server

2013-08-04 Thread Tim Streater
On 04 Aug 2013 at 11:28, Ashley Sheridan  wrote: 

> Like Matijn said, unless you're using some kind of client-side method to
> continually poll the server, you can't know if they've just closed their
> browser. There are Javascript events for exiting a page, but they don't
> work correctly on Safari and iOS Safari.

onbeforeunload works fine in Safari; I use it all the time.

--
Cheers  --  Tim

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

[PHP] Re: Foreach and mydql_query problem

2013-07-22 Thread Tim Streater
On 22 Jul 2013 at 12:56, Karl-Arne Gjersøyen  wrote: 

> Yes, i know that only one a singe row is updated and that is the problem.
> What can I do to update several rows at the same time?

Which several rows? The row that will be updated is that (or those) that match 
your WHERE clause. Seems to me you should make sure your WHERE is correct.

--
Cheers  --  Tim

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

[PHP] Re: htaccess

2013-07-08 Thread Tim Streater
On 07 Jul 2013 at 21:22, Tedd Sperling  wrote: 

> Confirmed. Those two lines cause the problem.
>
> However, commenting out those lines causes other problems.
>
> Are there similar statements to these:
>
>   AddType application/x-httpd-php .php .htm .html

This one tells apache to recognise .php, .htm, and .html as suffixes of files 
that need to be sent to PHP. You probably don't want to remove that [1].

>   AddHandler x-httpd-php5-cgi .php .htm .html

Dunno what this one does.

[1] But, having said that, realise that *all* files with those suffixes will be 
sent to PHP by apache, whether they contain any PHP code or not. Is that what 
you want? If I have an html file that contains some PHP code, I tend to use 
.phtml as suffix and so my AddType looks like:

 AddType application/x-httpd-php .php .phtml

--
Cheers  --  Tim

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

[PHP] Re: mongo usage

2013-07-06 Thread Tim Streater
On 06 Jul 2013 at 23:27, Tim Dunphy  wrote: 

> | You seem to spell the variable differently (1 'd' vs. 2 'd's)?
>
> Thanks! Fixed the type-o. Still no change.
>
>   $connection = new Mongo();
>
>$db = $connection->jfdb;
>
>//$collection = $db->addresses;
>
>$adresses = $connection->jfdb->addresses;

 ~

>
> Any other suggestions? Appreciated.

Fix the other typo.

--
Cheers  --  Tim

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

[PHP] Re: One more newbie question. About foreach..

2013-06-23 Thread Tim Streater
On 23 Jun 2013 at 16:11, Karl-Arne Gjersøyen  wrote: 

> // Foreach get all given serialnumbers as I want it
>foreach($serialnumber as $snr){
>
> // I got the number of serialnumbers given in the array
>   $count = count($serialnumber);

Why not do this *before* the foreach loop?

> // I thought that a for loop would do the trick together with foreach
> // And repeat the $sql = SELECT below but that did not happen.
>for($i = 0; $i <= $count; $i++){
>
>
> // Connect and get only those records with given serialnumber
> $sql = "SELECT * FROM explosive WHERE serialnumber = '$snr'";
>} // End of for loop
>} // End of foreach loop

All this for loop does is overwrite $sql each time.

> $result = mysql_query($sql, $connect) or die(mysql_error());
> $count = mysql_num_rows($result);

You need to have your mysql_query *inside* the for loop. Then, what are you 
doing with the results of the mysql_query? Nothing?

Also, why do you need the for loop anyway? What is it supposed to do?

--
Cheers  --  Tim

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

[PHP] Re: Undefined index....

2013-03-15 Thread Tim Streater
On 15 Mar 2013 at 13:10, Jay Blanchard  
wrote: 

> I have inherited a mess of a home-grown PHP framework that literally
> fills the error_log with 100's of thousands of messages each day. First
> order of business was rotating the logs, now we are working through each
> error to solve them. This is a fairly basic error, but I for the life of
> me cannot remember what the solution is.
>
> I have a recursive function that reads from XML files and replaces xi:
> include directives. It looks like this -
>
> function includeXML($file, $locale, $url, $level = 1) {
> // stuff
> while(($line = fgets($fp)) !== false) {
> if($pos === false) {
> $xml .= $line;
> } else {
> includeXML('repository/' . $included, $locale, (int)$level
> + $pos - 1);
> }
> }
> }
>
> Why do I get the notice that $xml is an undefined index?

Because it's undefined. So is $pos. From what you've written above, both are 
local to includeXML. But neither is passed in as a parameter, nor is global. 
You can't initialise it within the function, it seems to me.

If $xml is supposed to be appended to and grown as you recurse up and down, 
then you have two choices:

1) Make them global
2) Pass both as extra parameters to includeXML

In both cases, each needs to be initialised before the first call to the 
recursive function

Solution (1)


$xml = '';
$pos = 0;// Presumably.
includeXML ($file, $locale, $url, 1);

...

function includeXML ($file, $locale, $url, $level = 1) {

global  $xml, $pos;

// stuff
while(($line = fgets($fp)) !== false) {
if($pos === false) {
$xml .= $line;
} else {
includeXML ('repository/' . $included, $locale, (int)$level
+ $pos - 1);
}
}
}

Solution (2)


$xml = '';
$pos = 0;// Presumably.
includeXML ($xml, $pos, $file, $locale, $url, 1);

...

function includeXML (&$xml, $pos, $file, $locale, $url, $level = 1) {// 
Note the & on the first parameter
// stuff
while(($line = fgets($fp)) !== false) {
if($pos === false) {
$xml .= $line;
} else {
includeXML ($xml, $pos, 'repository/' . $included, $locale, 
(int)$level
+ $pos - 1);
}
}
}


BTW it seems to me that you'll have the same problem with $included unless 
there's other code in includeXML that you've omitted.

--
Cheers  --  Tim

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

[PHP] Re: rather a HTML Q; however 2-FRAME

2013-03-15 Thread Tim Streater
On 15 Mar 2013 at 11:00, tamouse mailing lists  wrote: 

> Frames are not only deprecated, they are unsupported entirely in HTML5
> (not that browsers won't continue to display them; just that they
> won't validate).

Meaning, in other words, that they *are* supported. It's unlikely in any case 
that any feature will ever be removed from a browser.

--
Cheers  --  Tim

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

[PHP] Re: Populate input from another form

2013-03-08 Thread Tim Streater
On 08 Mar 2013 at 19:45, John Taylor-Johnston 
 wrote: 

> I have a form
>
>  target="_CRTP">
>
> OnSubmit, I want to include data from another form (form="DPRform").
>
>  value="">
>
> I should use a hidden identical field and use form="CRTP_Query":
>
> ">

What purpose does this field serve?

> But I have no idea how to populate the hidden field with the data from
> the viewable field. PHP cannot do this onsubmit, can it?

You mean the script that processes the submitted page? No. Submitting causes 
your page to get replaced by the form's action, CRTP_Query.php in this case. 
Hmm, although it looks like you want a frame to receive the new page rather 
than replace the page. You'd probably need JavaScript to do that.

> Do I need to use jquery?

Avoid, IMO.

--
Cheers  --  Tim

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

[PHP] Re: Open form in new window

2013-03-04 Thread Tim Streater
On 04 Mar 2013 at 20:17, Paul M Foster  wrote: 

> On Mon, Mar 04, 2013 at 05:39:00PM +0000, Tim Streater wrote:

>> Personally I never submit forms. I use ajax to communicate with PHP
>> scripts and do something with the data that is returned by the script.
>> You can see a simple example at http://www.clothears.org.uk

> I'm trying to figure out where the net gain in that is. The PHP file
> being called via AJAX is doing its processing on the server either way.
> So it appears the only difference is an asynchronous Javascript/AJAX
> call or a synchronous PHP call (on a standard PHP form submission). What
> am I missing?

ISTM it's better for the user if, rather than reloading a whole page, you can 
get some bits of data from the server and use them to just alter the parts of 
the page that need updating.

--
Cheers  --  Tim

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

[PHP] Re: Open form in new window

2013-03-04 Thread Tim Streater
On 04 Mar 2013 at 17:10, John Taylor-Johnston 
 wrote: 

> Submit will not
> submit the form contents.

Nothing to stop your OpenWindow() function doing a submit as in:

Submit


function OpenWindow (formPtr)
 {

 // Some actions

 formPtr.submit ();

 }


Personally I never submit forms. I use ajax to communicate with PHP scripts and 
do something with the data that is returned by the script. You can see a simple 
example at http://www.clothears.org.uk

--
Cheers  --  Tim

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

[PHP] Re: Strip emails from a document

2013-01-26 Thread Tim Streater
On 26 Jan 2013 at 16:24, Tedd Sperling  wrote:

> I thought I had a function to strip emails from a document, but I can't find
> it.
>
> So, before I start writing a common script, do any of you have a simple script
> to do this?

I have a function that will take a comma separated string consisting of emails 
in these formats:

 "Soap, Joe" 
 Joe Soap  
 (Joe Soap) joe.s...@example.com

and turn them into a list where all the above examples are converted to:

 Joe Soap  

but it won't handle things like:

 "joe@soap"@example.com

which I understand is also valid.

You are welcome to it if you wish.

Cheers,

--
Cheers  --  Tim

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

[PHP] Re: Boolean type forced on string assignment inside if statement

2013-01-02 Thread Tim Streater
On 02 Jan 2013 at 16:05, Stephen  wrote: 

> On 13-01-02 10:53 AM, Marc Guay wrote:
>> Hi folks,
>>
>> if ($a = "foo" && $b = "bar"){
>>  echo $a."".$b;
>> }
>>
>> Returns:
>> 1
>> bar
>>
>> I expect:
>> foo
>> bar
>>
>> Is this documented?
>>
>
> && takes precedence over =
>
> http://php.net/manual/en/language.operators.precedence.php
>
> You may want to use brackets

OP may want to avoid doing something unusual which may confuse a casual reader.

--
Cheers  --  Tim

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

[PHP] Re: Strange string stuff -- maybe everything is ending...

2012-12-22 Thread Tim Streater
On 22 Dec 2012 at 16:50, Tedd Sperling  wrote: 

> On Dec 21, 2012, at 8:06 PM, Jim Giner  wrote:
>>> That actually makes sense tho.  Afterall, a string is truly only one memory
>>> allocation whereas array elements are basically multiple vars having the
>>> same name.  So - how can you unset one char in a string?
>
> It depends upon the language -- while it is true that the start of a string is
> located at a memory address, the chars of the string are identical to the
> chars in an array. As such, you can view a string as an array. Each index is
> representative of a char (one byte) in the string.

That is explicitly documented here:



String access and modification by character

Characters within strings may be accessed and modified by specifying the 
zero-based offset of the desired character after the string using square array 
brackets, as in $str[42]. Think of a string as an array of characters for this 
purpose. The functions substr() and substr_replace() can be used when you want 
to extract or replace more than 1 character.

--
Cheers  --  Tim

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

[PHP] Re: Switch - Case Statement Questions

2012-11-19 Thread Tim Streater
On 18 Nov 2012 at 14:44, Jim Giner  wrote: 

> 2. Using Switch {ALWAYS FIRST CASE!!!}
>
> //$boxes = 1;
> //switch ($count) {
> //case ($count > 14):
> //$boxes = 3;
> //break;
> //case ($count > 7 && $count <= 14):
> //$boxes = 2;
> //break;
> //case ($count <= 7):
> //default :
> //$boxes = 1;
> //break;
> //}


> To answer Iñigo's comment - the OP's version is very much like an
> If-ElseIF structure, and nothing like a Switch.

Just so. Perhaps those who are not grasping the point could re-read their copy 
of "The Elements of Programming Style" by Kernighan and Plauger where this sort 
of issue is covered.

See, it's all about expectations. When I worked at SLAC, there was a wise guy 
there who had removed the catalytic converter from his Scirocco and who though 
it clever to race up 280 from San Jose to SLAC at 100mph, sometimes 
slipstreaming behind another idiot doing the same. If I look in my rear-view 
mirror, I expect those I can see to be doing 70mph tops (that's what a lot of 
people did 30 years ago on 280), not 100, and to make judgements accordingly. 
Equally, I have certain expectations when I see a switch statement; it trying 
hard to look like if-elseif-etc is not one of them.

--
Cheers  --  Tim

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

[PHP] Re: Switch - Case Statement Questions

2012-11-17 Thread Tim Streater
On 17 Nov 2012 at 01:33, Iñigo Medina  wrote: 

> On Fri, 16 Nov 2012, Jim Giner wrote:

>> Maybe I'm way out of touch, but when I look at php.net for the syntax of the
>> switch statement I see:
>> switch($var){
>>  case (value):
>>  (do something)
>>  case (other value):
>>  (do something else)
>> }
>>
>> IN your example, you are using a switch syntax that is nothing like that.  I
>> think that your "case " statements are not actually evaluating the value of
>> $count, but are themselves evaluating to a true value that has nothing to do
>> with $count.
>
> That `switch` is evaluating to true each case. It's an alternative of using
> if-elseif structure.

It may be an alternative, but it breaks the principle of least surprise. If I'm 
looking through someone's code, and I see a switch, I expect to see it used as 
Jim described. If the writer needs a different type of logic to make a 
decision, that is what the cascaded if-elseif-elseif construct is for, when the 
tests don't fall into a simple set-of-values choice.

The job of a programmer is not to be "clever" with a view to impress those who 
follow, but to achieve the desired outcome while at the same time making life 
easy for those who follow.

--
Cheers  --  Tim

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

[PHP] Re: Switch - Case Statement Questions

2012-11-16 Thread Tim Streater
On 16 Nov 2012 at 12:10, Omar Muhsin  wrote: 

> Hello,
>
> I was just wondering after writting the code in version 2 here below, it turns
> out in testing that it actually PHP is not validating the expressions instead
> always I get the first case.
>
> 1.Using nested if statement {THE INTENDED BEHAVIOR}:
>if ($count > 14)
>$boxes = 3;
>elseif($count > 7 && $count <= 14)

You don't need the count<=14 part as you will *only* get there if $count<=14.

>$boxes = 2;
>else
>$boxes = 1;
>
> 2. Using Switch {ALWAYS FIRST CASE!!!}
>
> //$boxes = 1;
> //switch ($count) {
> //case ($count > 14):
> //$boxes = 3;
> //break;
> //case ($count > 7 && $count <= 14):
> //$boxes = 2;
> //break;
> //case ($count <= 7):
> //default :
> //$boxes = 1;
> //break;
> //}
>
>
> Does anyone know the answer why using the Switch it always execute the first
> case ?

As has been pointed out you need switch(true).

That's a strange way of writing a switch, IMO. You should be using the if 
version.

--
Cheers  --  Tim

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

[PHP] Re: appreciation

2012-10-12 Thread Tim Streater
On 12 Oct 2012 at 12:36, Maciek Sokolewicz  wrote: 

> However, this is likely not what the OP wants. What he likely does want
> is to check if the filename is not '.' or
> '..'. Of course, there are numerous ways to do this. From very simple
> things like:
> if ( $filename != '.' && $filename != '..')

Personally if I have a loop looking at filenames in a directory, I'll start it 
with:

while (something)
 {

 if  ($filename=='.' || $filename=='..')  continue;

 // rest of loop

 }


That way, the unwanted cases don't clutter up the logic for the cases I 
do/might want.

--
Cheers  --  Tim

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

[PHP] Re: limiting

2012-10-10 Thread Tim Streater
On 10 Oct 2012 at 19:53, David McGlone  wrote:

> On Wednesday, October 10, 2012 07:36:00 PM Tim Streater wrote:
>> On 10 Oct 2012 at 19:17, David McGlone  wrote:

>>>> BTW - in any of your other computer languages didn't they utilize a
>>>> 'return' statement?  PHP's is no different.

>>> back in  like '85, I learned Pascal that's the only language I learned and
>>> I don't recall if it used return.

>> Mmmm. There's the problem. Pascal doesn't *have* a return statement. The one
>> time I *had* to use Pascal as that was the only option, I simply put a 999:
>> label at the end of the function and did goto 999 wherever I wanted to do a
>> return. Simples!
>
> goto was the thing that got on my nerves. Even to this day I hate that word
> with a passion.

Hu! Apart from what I described above, I haven't needed to use GOTO since I 
stopped writing FORTRAN in 1978.

--
Cheers  --  Tim

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

[PHP] Re: limiting

2012-10-10 Thread Tim Streater
On 10 Oct 2012 at 19:17, David McGlone  wrote:

>>
>> BTW - in any of your other computer languages didn't they utilize a
>> 'return' statement?  PHP's is no different.
>
> back in  like '85, I learned Pascal that's the only language I learned and I
> don't recall if it used return.

Mmmm. There's the problem. Pascal doesn't *have* a return statement. In Pascal, 
implicitly, you return when execution reaches the end of a function. In fact 
the same is true of PHP and JavaScript, but in those languages you can return 
early just by saying return.

IMO, this is a major limitation of Pascal. I use returns wherever I feel like 
it - if I detect there's nothing more for the function to do, I return. Purists 
object to this; they say you should enter a function at one place and leave at 
one place. Well, that's a point of view. But more often that not it just leads 
to convoluted code in order to achieve that. The one time I *had* to use Pascal 
as that was the only option, I simply put a 999: label at the end of the 
function and did goto 999 wherever I wanted to do a return. Simples!

--
Cheers  --  Tim

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

[PHP] Re: limiting

2012-10-09 Thread Tim Streater
On 09 Oct 2012 at 20:46, Matijn Woudt  wrote:

> For example your previous post, you
> could have just looked up what the 'echo' and 'return' statements do
> in the PHP manual, and they are probably explained pretty OK in those
> books you own too. You probably could have answered the questions you
> posted here yourself, after reading PHP manual carefully.

Here, the phrase "PHP manual" means:

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

which I consider to be an excellent written resource for the language. In fact, 
I own no PHP books at all (whereas I do for JavaScript/HTML/CSS/SQLite) so that 
must say something about the quality of the on-line documentation. Further, it 
is written in a straightforward way, not trying to be clever (unlike some 
languages I could mention), so I can recommend it. It's available in languages 
other than English, too.

--
Cheers  --  Tim

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

[PHP] Re: Differences

2012-10-04 Thread Tim Streater
On 04 Oct 2012 at 01:48, David McGlone  wrote:

> Hi everyone, I have been playing around with some code the list helped me with
> a while back and I'm not grasping the concept between return and echo and the
> PHP manual doesn't answer this, unless I'm missing something. There is an
> example at the very bottom of PHP's return manual, but it's confusing.

It's a poor example, for one thing. As others have said, echo and return have 
nothing to do with each other.

> So now I'm left wondering why return will only give me the first result in an
> array, but echo will give me all the results of the array. Using stuart's
> example he had sent me a while back I've messed around with it and modified it
> to better understand it:
>
> function filename($prefix)
> {
>  $matches = glob('images/property_pics/'.$prefix.'*');
>  foreach($matches as $filename){
>  return $filename;
> }
> }
>
> echo completeImageFilename($row['MLS_No']);
>
> With the above code I only get the first image of each picture name, but when
> I change return to echo, it groups and displays all the pics that have the
> same picture name.

I assume that where you have "function filename" above, you really mean 
"function completeImageFilename".

Why do you think that the return you have coded above should give more than one 
filename when you've written "return $filename"? That's one filename. You then 
echo that out with your echo statement (because it's the return value of the 
function), and that's what you see. If you change the return to an echo, then 
instead of returning after once round your while loop, the while loop goes 
round and round dealing with each filename you have in $matches, and echoes out 
each one. When the while loop has completed, the function returns, but returns 
nothing at all. So your original echo then does nothing at all. And so you see 
the observed behaviour.

--
Cheers  --  Tim

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

[PHP] Re: problem with my login script

2012-10-02 Thread Tim Streater
On 02 Oct 2012 at 12:07, Maciek Sokolewicz  wrote:

> On 02-10-2012 11:59, Bálint Horváth wrote:
>> The problem was already solved. I forgot to send a copy to the list...
>>
>> Rodrigo, break!? Ohh man, it's a crazy idea... A developer DOES NOT use
>> break at all (in a loop)... (switch is an exception)
>
> I personally find this statement to be utter bullshit. There is nothing
> wrong with using break. There is a very good reason why it's available
> in the language. In very many cases, it costs a lot less code to add a
> break than to add additional clauses to your while-conditional.

Agree 100%.

--
Cheers  --  Tim


[PHP] Re: PHP Re: PHP Bounce messages

2012-09-21 Thread Tim Streater
On 21 Sep 2012 at 20:56, tamouse mailing lists  wrote: 

> On Fri, Sep 21, 2012 at 4:17 AM, Tim Streater  wrote:
>> On 21 Sep 2012 at 08:40, Lester Caine  wrote:
>>
>>> I know that the php list are one of the 'reply to sender' email handling
>>> camp rather than reply to list.
>>
>> I don't understand this. I reply (not that I mail that often) just to the
>> list, if possible. Why would I do anything else?
>
> I believe Lester is referring to the behaviour of the Reply-To: field
> sent by the list serv, which is the sender's address. Some other
> listservs put the list reply address in Reply-To:

Thanks, I'm with you now. And I also do the To: cc: musical chairs.

--
Cheers  --  Tim

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

[PHP] Re: PHP Bounce messages

2012-09-21 Thread Tim Streater
On 21 Sep 2012 at 08:40, Lester Caine  wrote: 

> I know that the php list are one of the 'reply to sender' email handling camp
> rather than reply to list.

I don't understand this. I reply (not that I mail that often) just to the list, 
if possible. Why would I do anything else?

--
Cheers  --  Tim

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

[PHP] Re: PHP Re: Programmers and developers needed

2012-09-19 Thread Tim Streater
On 19 Sep 2012 at 16:32, Matijn Woudt  wrote: 

> "unless they were a majority" is the thing that bothers me. Getting a
> majority is hard, take for example the Dutch Politics [1]. Our country
> is now led by a parliament of 10 different political parties. Getting
> things done now is really hard, because each party has their own goals
> and finding a majority is for almost impossible. If all the parties
> were strictly following their own will, there would probably only a
> handful things done. The only way to get things done now is by making
> compromises.

And so Dutch governments only last short periods of time, and it takes a long 
time to create a coalition. This is why Proportional Representation is such a 
bad idea. Better to have strong government with a clear mandate, and if you 
don't like it, vote it out next time.

By the way what does any of this have to do with PHP? Nothing, I think.

--
Cheers  --  Tim

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

Re: [PHP] What do you call the end-user?

2012-07-20 Thread Tim Streater
On 19 Jul 2012 at 18:26, Tedd Sperling  wrote: 

> First question:
>
> What do you call the people who ultimately use your code?

I expect I'll call her "Dear". See, my app, a replacement for Eudora, is used 
by yours truly only at the mo. However, come time to upgrade SWMBO's Mini, 
which will run Lion or perhaps ML, Eudora will cease to function and I'll move 
her onto my app.

> This question transcends your code working correctly, accurately, and securely
> -- no need to comment on those aspects. But rather more specifically do you
> consider how easily your "whomever" can use your work efforts?

In principle, yes. But that's a bit hard at the moment.

--
Cheers  --  Tim

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

Re: [PHP] Creating drop-down menus

2012-07-17 Thread Tim Streater
On 17 Jul 2012 at 21:58, Paul M Foster  wrote: 

> On Wed, Jul 18, 2012 at 08:45:34AM +1200, James Newman wrote:
>
>> Just to put my 2cents in, you might want to try jQuery if you're going to
>> go down the AJAX road.
>
> JQuery is a LOT of code to include if you're just going to do an AJAX
> call or two. There are examples of doing straight AJAX with Javascript
> on the 'Net. Once you work through them, you find that there's a
> "static" part that you can include in all the files you want to make
> AJAX calls. And then there's the part that deals directly with the data
> you get back from whatever PHP or other script is feeding you data from
> outside the website. That's the part that needs custom work. I *hate*
> Javascript, but I managed to figure it out.

I agree about JQuery. You can look here:

  http://www.clothears.org.uk/examples-ajax.php

to see a simple example of how to use AJAX.

--
Cheers  --  Tim

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

Re: [PHP] Creating drop-down menus

2012-07-16 Thread Tim Streater
On 16 Jul 2012 at 21:19, Jen Rasmussen  wrote: 

> Sometimes I need to use javascript to fill a drop down box based on the
> value of a previous drop down box.  However, the information to fill the
> latter is stored in mysql and can be a lot, what I have been doing is that,
> using PHP, I create hidden fields with all the possible information that
> might be needed to fill the second drop down.
>
> For example, the user chooses a bank from a drop down, and then a list of
> clients is displayed on the following drop down.  I use PHP to read all
> clients from all the banks and put that as hidden fields on the html page.
> It is very cumbersome.

Well it would be. This approach doesn't scale.

> I do not want to read the database (which changes dynamically) from
> javascript directly due to confidentiality and because a lot of care has
> been taken to create the appropriate  queries with checks and protect misuse
> of the information using PHP.

I doubt if you can read it from JavaScript.

> My questions are:
> 1) Do people just normally use hidden fields to store possible information
> to fill the drop downs?
> 2) any suggestions?

You could use ajax to request the information needed to load the second drop 
down. Once the user chooses their bank, then your JavaScript makes an ajax 
request to a PHP script that returns the clients list. You use this to populate 
the second drop down.

--
Cheers  --  Tim

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

Re: [PHP] Unexpected Notice message

2012-07-04 Thread Tim Streater
On 04 Jul 2012 at 16:51, Marc Guay  wrote: 

>> Notice: Use of undefined constant QUERY_STRING - assumed 'QUERY_STRING' in
>
> I would guess that it's asking you to add quotes around QUERY_STRING...?

As in:

if (strlen($_SERVER['QUERY_STRING']) > 0) {


--
Cheers  --  Tim

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

Re: [PHP] embedding php inside of php

2012-07-01 Thread Tim Streater
On 01 Jul 2012 at 01:00, Tim Dunphy  wrote: 

> I am trying to get the hang of php using some examples that I found
> in a book. I've been making progress lately, but one thing has me a
> bit stumped.
>
> In an HTML form that I am echoing through PHP I would like to embed
> smaller chunks of php in the code like so:
>
>
> echo '
>
>Subject of email:
>
>Body of email:
> cols="40">""   
>
>';


You don't need the nested echoes. Just concatenate instead:

echo '
   
   Subject of email:
   
   Body of email:
   "' . $text . '"   
   
   ';

In short you're doing this :

echo 'Some HTML text here ' . $subject . ' some more HTML text ' . $text . ' 
and finally other stuff here';

--
Cheers  --  Tim

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

Re: [PHP] Hungarian Notation interest with PHP

2012-06-04 Thread Tim Streater
On 04 Jun 2012 at 15:43, Mihamina Rakotomandimby  wrote: 

> I have a colleague stuck with this thing named "Hungarian Notation"
> http://goo.gl/xYv8O
>
> We try to define our internal coding standards, which is very close to
> the Symfony ones http://goo.gl/f2rcO
>
> But we're in conflict because the colleague really argue about his
> "Hungarian Notation".

This simply adds far too much noise to code. If I need to know what type a 
variable has, I'll look at its declaration, if any.

--
Cheers  --  Tim

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

Re: [PHP] Re: Function size

2012-06-03 Thread Tim Streater
On 03 Jun 2012 at 10:02, Tony Marston  wrote: 

> "tamouse mailing lists"  wrote in message
> news:cahuc_t__sw-_yhrw4n4uqr-fa46+cebunzgehboaatrafla...@mail.gmail.com...

>> There is a point: if you are unfamiliar with code, wading through
>> screens and screens of a function to find things like block
>> beginning/ends makes for difficult time finding places where changes
>> need to be made.
>
> I *never* have huge numbers of lines between a block beginning and end. Even
> if I did my IDE can quickly find the other end of the block for me.

E.g. TextWrangler does this easily enough: just double-click immediately after 
an opening brace, and everything is highlighted to the closing brace.

>>> - all those functions should be arranged in alphabetical order within
>>> their containing file - having them in a random sequence makes it
>>> difficult to find the one you want.
>>
>> Also correct; this is a key point in making sure your scripts are
>> maintainable.
>
> Ah-ha! So someone agrees with me on that point after all.

+1

>>> - when browsing through the code you have to keep jumping to another
>>> function, and then returning to where you came from.
>>>
>>> I don't know about you, but I would rather use the scroll wheel on my
>>> mouse
>>> than keep jumping from one position in the file to another.
>>
>> May I suggest an editor/IDE that lets you navigate to functions directly,
>> then?
>
> I am *NOT* going to change my IDE just to suit *YOUR* preferences.

TW provided a popup list of your functions. It still helps to have them in 
alpha order though, for ease of navigation in the popup list.

[snip arguments]

I write functions to do specific things. E.g. I have a function (actually in 
JavaScript) called switchTab() which switches from one user view to another. 
It's just over 200 lines long and is mostly a giant case statement - and it's 
already loaded with function calls. I suppose I could break it up into five 
separate functions, more or less one for each case value, but then I'd have 
lots of unimportant local variables to pass around as argument values, and, 
what's worse, lots of unimportant functions cluttering the place up.

--
Cheers  --  Tim

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

Re: [PHP] url string being split

2012-04-27 Thread Tim Streater
On 27 Apr 2012 at 16:56, Chris Stinemetz  wrote: 

> On Thu, Apr 26, 2012 at 12:58 PM, Stuart Dallas  wrote:
>> On 26 Apr 2012, at 18:37, Jim Giner wrote:
>>
>>> I"m no expert, but why would you expose a query to the world thru the use of
>>> a GET?  Why not just collect the params and build the string in your code?
>>> That is how people hack into your database - via a re-formed query.  You're
>>> giving someone an open invitation.
>>
>> A "query string" has nothing to do with databases.

> I still haven't been able to find a solution. Is there anyone out
> there that knows how to keep the query string intact?

As was posted previously, you need to encode the query string. If you have:

   http://westeng/forum/store.php?id=Wiser Communication, LLC -& - Sprague Ave

that is going to be split in two unless you encode the "Wiser Communication, 
LLC -& - Sprague Ave" portion. I would do that with JavaScript on the html page.

This is not a PHP question.

--
Cheers  --  Tim

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

Re: [PHP] php in windows

2012-04-11 Thread Tim Streater
On 11 Apr 2012 at 03:13, Kirk Bailey  wrote: 

> It means it does nothing. I have a small server in the computer that
> works fine. I also installed python in this box- and it worked
> perfectly without having to do anything to the server. Php on the
> other hand merely occupies disk space.

So you don't want to tell us what "does nothing" means etc as per my previous 
post. Fine.

> Aside:Holy cow, you know nothing about windows?!? Considering that
> Boll Bates and co. are almost as omnipresent as Satan, and have been
> accused of BEING Satan, that's quite an accomplishment.

I exaggerate for effect. Sometimes I volunteer a small office that, inevitably, 
uses it. And when my dopey BiL downloaded iTunes and then asked me what to do 
next, I sent him to the Start menu. But I actively resist knowing more than I 
absolutely need to.

--
Cheers  --  Tim

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

Re: [PHP] strftime silliness

2012-04-11 Thread Tim Streater
On 11 Apr 2012 at 01:47, Geoff Shang  wrote: 

> On Wed, 10 Apr 2012, Tim Streater wrote:
>
>> I want to format a date/time using a 12 hour representation of the time
>> part. I can do this with, say, "%d %b %Y %l:%M %p", where the first time
>> format specifier is the lower-case L. But, this gives me a leading space
>> in the case that the hour is less than 12. I don't want this space.
>> Anyone know of an simple way to avoid it? There appears to be no
>> specifier to do this. Of course, I can call strftime twice, once for the
>> date portion and once for the time portion, trimming the latter, but
>> that seems clumsy.
>
> You can use %-l to achieve this.  You could also use %-I as this will also
> drop leading zeros if present.
>
> I forget where I read about this.  I'm almost certain that it was *not* in
> any PHP documentation.

Ah - thanks. My post wasn't a complete waste of time after all then. I ended up 
using date(). But is %-l officially supported?

--
Cheers  --  Tim

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

[PHP] Re: strftime silliness

2012-04-10 Thread Tim Streater
On Apr 10th, 2012 at 10:40pm, Tim Streater  wrote: 

> I want to format a date/time using a 12 hour representation of the time part.
> I can do this with, say, "%d %b %Y %l:%M %p", where the first time format
> specifier is the lower-case L. But, this gives me a leading space in the case
> that the hour is less than 12. I don't want this space. Anyone know of an
> simple way to avoid it? There appears to be no specifier to do this. Of
> course, I can call strftime twice, once for the date portion and once for the
> time portion, trimming the latter, but that seems clumsy.

OK belay that, sorry: I'm using the wrong function (shouldn't code this late at 
night).

--
Cheers  --  Tim

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

[PHP] strftime silliness

2012-04-10 Thread Tim Streater
I want to format a date/time using a 12 hour representation of the time part. I 
can do this with, say, "%d %b %Y %l:%M %p", where the first time format 
specifier is the lower-case L. But, this gives me a leading space in the case 
that the hour is less than 12. I don't want this space. Anyone know of an 
simple way to avoid it? There appears to be no specifier to do this. Of course, 
I can call strftime twice, once for the date portion and once for the time 
portion, trimming the latter, but that seems clumsy.

--
Cheers  --  Tim

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

Re: [PHP] php in windows

2012-04-10 Thread Tim Streater
On 10 Apr 2012 at 03:05, Kirk Bailey  wrote: 

> The edition of php for windows I instaklled does not work. Which
> flavor of windows php DOES work properly in windows?

What does "does not work" mean? You need to say which OS, which PHP version, 
what happens, and what you expect to happen. Not that I can help, as I know 
nothing about Windows, but with that info perhaps another can.

--
Cheers  --  Tim

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

Re: [PHP] Websocket using php

2012-04-01 Thread Tim Streater
On 31 Mar 2012 at 16:14, Leandro Dardini  wrote: 

> Hello,
> I have the need to use websockets for the server part of an application I
> am developing and I found with a big surprise no websocket class or
> procedure is available on the net. Have I missed looking in some place?
>
> Being really interested in using this protocol with PHP, I start from the
> closest working thing: http://code.google.com/p/phpwebsocket/ and start
> adapting it to the lastest RFC describing the protocol
> http://tools.ietf.org/html/rfc6455, but it is really heavy to code and I
> feel like "reinventing the wheel".
>
> Is there anyone out there who has already written a websocket server in PHP
> and like to share the code?

https://github.com/jam1401/PHP-Websockets-Server

--
Cheers  --  Tim

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

Re: [PHP] Parse errors

2012-03-18 Thread Tim Streater
On 18 Mar 2012 at 17:46, Simon J Welsh  wrote: 

> This is expected. The error doesn't occur to the second file is included, so
> everything in the first included file is parsed and run before execution is
> halted.

Simon,

Thanks for that. Looks like I should be able to catch most places where an 
error might occur.

--
Cheers  --  Tim

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

[PHP] Parse errors

2012-03-18 Thread Tim Streater
After recently omitting a semicolon from the end of a statement, and having the 
result be a JavaScript error in an odd place, I'm trying to pin down just what 
PHP does with such errors. I made a small test script to run at CLI, which does 
some echoes and then, after that, I miss out a semicolon. On the command line, 
all I get is the parse error message with line number.

The script where I'd left the semicolon out of my production code is reached 
via AJAX, and sends some results back. It consists of a number of functions, 
then the main code appears, starting with two requires. The first such included 
file has some functions, puts out a header and does an echo, and calls 
set_error_handler. It's in the second included file that the semicolon is 
missed off (inside yet another function).

I would have expected that the results sent back would just consist of the 
Parse error: message, but for some reason the echo done in the first included 
file shows up as well (this is important as it frames the parse error message 
for me).

Is this the expected behaviour? The doc for set_error_handler says you can't 
use it to recover from E_PARSE and the like, and the function I supply to it 
doesn't appear to be called. I was just surprised that the initial echo 
statement's output made it back to the JavaScript side.

(I obviously don't expect to have parse errors show up in production, but 
having them nicely visible and logged during testing is useful)

--
Cheers  --  Tim

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

Re: [PHP] Got HTML5 History API + caching LICKED, I think,

2012-03-18 Thread Tim Streater
On 18 Mar 2012 at 17:06, Tim Streater  wrote: 

> I don't like:
>
> a) menus that just spring into life because you happen to mouse near them. You
> should have to sick to activate a menu.

Damned autocorrect. s/sick/click/

--
Cheers  --  Tim

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

Re: [PHP] Got HTML5 History API + caching LICKED, I think,

2012-03-18 Thread Tim Streater
On 18 Mar 2012 at 16:39, Tamara Temple  wrote: 

> On Fri, 16 Mar 2012 19:57:38 +0100, rene7705  sent:
>> I could waste a lot of text on what I've accomplished during the last
>> months, but the easiest thing is if you have a (another) look at (the
>> source of) http://mediabeez.ws
>
> I seem a bit late to this party, but just wanted to say that the
> artwork is quite impressive, although I doubt I'd have really much use
> for the code parts.

I don't like:

a) menus that just spring into life because you happen to mouse near them. You 
should have to sick to activate a menu.

b) bright flashy distracting items on a website. Like the OP's menus.

--
Cheers  --  Tim

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

Re: [PHP] questions about $_SERVER

2012-03-13 Thread Tim Streater
On 13 Mar 2012 at 15:59, Tedd Sperling  wrote: 

> I'm not sure what would have saved bacon in the above case. I don't see how
> your example would work. I think it contained a typo.
>
> In what I think you were trying to demonstrate, I would just pass $x by
> reference (&$x) -- or -- return $x by value. I would not have used a global,
>
> In any event, I seldom use globals anyway. This was more an academic
> discussion.

As was my example - and yes, it had a typo. Worse, trying it in a shell it 
doesn't exhibit the failure mode I thought I'd had. Never mind.

--
Cheers  --  Tim

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

Re: [PHP] questions about $_SERVER

2012-03-12 Thread Tim Streater
On 12 Mar 2012 at 20:07, Tedd Sperling  wrote: 

> Tim:
>
> I read somewhere that using:
>
> global $x;
>
> is not recommended. Whereas, it is recommended to use:
>
> $x = $GLOBALS['x'];
> echo $x;

Tedd,

That may well be, although as I write I can't recollect having seen that 
anywhere; so I don't use that form. However I have been caught by something 
like the following:




but I haven't looked into $GLOBALS enough to know whether using them instead 
would have saved my bacon.

--
Cheers  --  Tim

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

Re: [PHP] questions about $_SERVER

2012-03-11 Thread Tim Streater
On 11 Mar 2012 at 18:16, Tedd Sperling  wrote: 

> On Mar 11, 2012, at 10:25 AM, Daniel Brown wrote:
>
>> On Sat, Mar 10, 2012 at 10:37, Tedd Sperling  wrote:
>>> As such, there are no "globals" in PHP other than SuperGlobals. As I said,
>>> if I'm wrong, please show me otherwise.
>>
>>A superglobal is predefined at run-time by the parser,
>> environment, SAPI, etc. (_SERVER, _POST, _GET, _REQUEST, _ENV,
>> _SESSION, _COOKIE), whereas a global can be defined at any time, and
>> is available to the current instance.  All superglobals are globals,
>> but not all globals are superglobals.


> Now I'm confused.
>
> My understanding is that all variables defined within the main script are
> accessible within the main script because they are all within scope by
> definition.
>
> Additionally, main script variables are not accessible out of scope (such as
> in a function) unless one uses $GLOBALS to retrieve those values.

In the following, $x is a global but not a super-global (AFAIK).




--
Cheers  --  Tim

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

Re: Re: [PHP] Variable number of arguments problem

2012-02-12 Thread Tim Streater
On 12 Feb 2012 at 19:01, Stuart Dallas  wrote: 

> Optional arguments must be given a default value...
>
> function my_func(&$arg1, $arg2, $arg3, $arg4 = null, $arg5 = null, &$arg6 =
> null)
>
> Note that passing a default value by reference was not supported prior to
> PHP5.
>
> All the relevant details are here: http://php.net/functions.arguments

Thanks, I do see an example now, although it's not stated explicitly.

--
Cheers  --  Tim

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

[PHP] Variable number of arguments problem

2012-02-12 Thread Tim Streater
I have a function defined thus:

function my_func (&$arg1, $arg2, $arg3, $arg4, $arg5, &$arg6)
 {

 // code here

 }

I call this with variously the first three arguments only, or all six, taking 
care that if I call it with fewer arguments then I don't try to acces $arg4, 
$arg5, or $arg6 (which is passed by reference, as is $arg1).

On my first attempt to execute this, I'm getting:

  Missing argument 4 for my_func(), called in /path/to/source/file1.php at line 
556 and defined
  in /path/to/source/file2.php at line 3

Is this because $arg6 is passed by reference? There is some reference to this 
in the docs and the user notes but it's a little unclear. Or is there another 
reason?

Thanks,

--
Cheers  --  Tim

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

Re: Re: Re: [PHP] What's Your Favorite Design Pattern?

2012-02-08 Thread Tim Streater
On 07 Feb 2012 at 22:31, Paul M Foster  wrote: 

> Design Patterns are Way Nifty Kewl patterns of code which are supposed
> to facilitate certain types of operations. (Was that sarcasm you
> detected? Yes it was.)
>
> For example, the Singleton pattern. Let's say you had a configuration
> class that held the configuration values for your application, and you
> wanted to make sure there was only one object of that class
> instantiated, no matter how many times it was called in your code. You'd
> arrange the code and call the class in a certain way to ensure that only
> one object of that class resulted. To make your configuration class a
> "singleton", you'd probably make the class have a *private* constructor
> (so no outside routine could call it), and then provide a method called
> get_instance() which tested for the existence of an object of that
> class. If such an instance was found, someone calling
> configuration::get_instance() would simply get the existing object
> returned to them. Otherwise, configuration::get_instance() would
> instantiate the class and then return the new object to the caller.
>
> As you can see, that's a peculiar way of setting up your code for a
> specific purpose. Other design patterns do other things and dictate
> setting up things in other ways.
>
> The definitive work on this (and where it first gained the most
> publicity) is a book called "Design Patterns" by four authors (Gamma,
> Helm, Johnson and Vlissides). It essentially contains a chapter about
> each (known at the time) design pattern and some pseudocode about how it
> might be constructed. I imagine the authors looked at a lot of code and
> discovered that programmers were coming up with code that, in each case
> was remarkably similar for solving certain types of programming
> problems. So they codified what that found and wrote a book about it.
>
> I have the book on my shelf, and it's decent technology, but you could
> spend your whole career and never use any of it, and get along just
> fine.

Mmmm. Well, at this point I feel underwhelmed - but its entirely possible that 
I'm missing something profound [1]. After looking at some of the reviews of the 
book you mention on Amazon, I might be inclined to get a simpler intro.

[1] In June 1982 (or was it '83?) I visited PARC with a small group from SLAC. 
We saw the Star or whatever it was, with bit-mapped display and mouse pointer. 
Whoosh !! (Well, to be fair, we'd gone along to look into XNS).

--
Cheers  --  Tim

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

Re: Re: [PHP] What's Your Favorite Design Pattern?

2012-02-07 Thread Tim Streater
On 07 Feb 2012 at 19:34, Daniel Brown  wrote: 

> On Tue, Feb 7, 2012 at 13:56, Mike Mackintosh
>  wrote:
>> I was curious to see what everyones favorite design patterns were, if you use
>> any, and why/when have you used it?
>>
>> Choices include slots and signals (observer), singleton, mvc, hmvc, factory,
>> commander etc..
>
>Mine is apparently CPSV (Commentless Procedural Spaghetti Vomit),
> as that's what I encounter no less than 80% of the time in the wild.

Since I have no idea what anyone is talking about, I can only conclude that 
you're playing Mornington Crescent (q.v.), on a non-standard board.

--
Cheers  --  Tim

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

[PHP] Re: Long Live GOTO

2012-02-06 Thread Tim Streater
On 06 Feb 2012 at 20:51, Simon J Welsh  wrote: 

> On 7/02/2012, at 9:44 AM, Marco Behnke wrote:
>
>> Am 06.02.12 17:23, schrieb Alain Williams:
>>> However: a few GOTOs can make things clearer. Think of a function that
>>> can fail in several different places (eg data validation, ...). But it
>>> is reading a file which needs to be closed before the function
>>> returns. I have seen code where some $IsError variable is tested in
>>> many places to see if things should be done. That is just as bad as
>>> lots of GOTO -- often when having to write something like that I will
>>> have a GOTO (in 
>>
>> Good code uses Exceptions and try catch for that kind of scenarios.
>
> Exceptions have a lot of overhead and should only be used in exceptional
> circumstances. I don't see how data validation failing is an exceptional
> circumstance.
>
> I find that using Exceptions and try/catch for something this trivial to be
> more confusing and harder to read (thus worse code) than a goto. It is also
> much easier to make a mistake, especially if you're expecting the catching to
> happen outside of the validation function.

While it is true that try/catch adds another level just like an extra 
if-then-else, there are times when it's unavoidable. During initialisation of 
my app, I have to check which of the files in a directory may be SQLite 
databases that belong to the app. So I have to check:

a) whether this file is an SQLite database
b) whether it has the two tables I expect to find there

Last time I checked the SQLite API in question, it looked as though try/catch 
was my only option.

--
Cheers  --  Tim

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

Re: Re: [PHP] Long Live GOTO

2012-02-06 Thread Tim Streater
On 06 Feb 2012 at 09:48, Adam Richardson  wrote: 

> On Mon, Feb 6, 2012 at 4:25 AM, Adam Richardson wrote:
>
>> On Mon, Feb 6, 2012 at 4:07 AM, Tim Streater  wrote:

>> I disagree that the nested function is a straw-man. I (just as the other
>> authors I'd linked to describing the "arrow" pattern of code) have seen
>> plenty of examples of similar code.

I guess what I meant was, that I'd never have written it that way in the first 
place, so as an example it felt contrived. Amateurs or people with no training 
(in particular physicists at CERN 40 years ago) should be kept well clear of 
the goto. I'd probably write your function like this:

function val_nested ($name = null, $value = null, $is_mutable = false)
 {

 static $values   = array();
 static $mutables = array();

 if  ($name===null)  return $values;

 if  ($value===null)  return isset($values[$name]) ? $values[$name] : null;

 if  (isset($values[$name]))
  {

      if (!$val_is_mutable = in_array($name, $mutables))// Set existing 
value
   {
   $msg = 'The value "' . $name . '" is immutable and has already 
been set to ' . $values[$name] . '.';
   throw new Exception ($msg);
   }

  return $values[$name] = $value;

  }

 if ($is_mutable)  $mutables[] = $name; // Set new value
 $values[$name] = $value;

 return $value;

 }


I always add blank lines for clarity. Remove those and the above is 30% shorter 
than yours - as far as I could tell, none of the else clauses was required.

My approach is:

1) deal with the trivial and error cases first

2) deal with the real work next

--
Cheers  --  Tim

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

Re: Re: [PHP] Long Live GOTO

2012-02-06 Thread Tim Streater
On 06 Feb 2012 at 15:05, Robert Cummings  wrote: 

> I've had a strong opinion on goto for a very long time. I was one of the
> proponents who argued on internals for its inclusion several years ago.
> I stand by its utility and refer the reader to the fact that many open
> source projects, especially ones that use some kind of parser, have goto
> hidden within their implementation. You can find it in the C code for
> the PHP, MySQL, and Apache to name a few easily recognizable projects.

All of which is no doubt true but that doesn't mean I have to like it, although 
obviously I'll have to put up with it. Anyway, discussions of this sort tend to 
be, or become, futile.

--
Cheers  --  Tim

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

Re: [PHP] Long Live GOTO

2012-02-06 Thread Tim Streater
On 06 Feb 2012 at 07:47, Adam Richardson  wrote: 

> While not purely focused on PHP, I toss this out to the group because I
> believe there are some novel, interesting points regarding the potential
> benefits of using the goto construct as implemented in PHP:
>
> http://adamjonrichardson.com/2012/02/06/long-live-the-goto-statement/

Your val_nested() function looks like a straw-man to me. I've not used a goto 
since I stopped writing in FORTRAN in 1978, and not missed it [1]. Neither do I 
ever have deeply nested if-then-else - these are a good source of bugs. I 
suppose the rest of your article might have been dealing with simplifying 
val_nested() but TBH I wasn't interested enough to find out.

[1] Not quite true - a Pascal compiler I once had to use in 1983 lacked a 
return statement, so I had to fake it by putting a 999: label at the end of the 
function and goto-ing to that.

--
Cheers  --  Tim

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

[PHP] Looking for the string functions

2012-02-01 Thread Tim Streater
I'm keen to look at the C source of such as substr_replace() and stripos(). 
I've downloaded the 5.3.9 PHP source, but am having difficulty locating the 
string functions. Could someone point me at the right directory or .c file?

Thanks,

--
Cheers  --  Tim

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

[PHP] Measuring CPU time

2012-01-15 Thread Tim Streater
I haven't found a function to allow me to see elapsed CPU time to date in a 
function. Am I right in thinking none such exists?

--
Cheers  --  Tim

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

Re: RE: RE: [PHP] passing variables to php script

2012-01-13 Thread Tim Streater
On 13 Jan 2012 at 15:05, David Savage  wrote: 

> I open the html file up from a windows explorer window (Q:\asterisk\), and so
> IE opens it up, but the problem lies in the fact that I cannot find apache
> service running in the background...haven't figured out why yet.  The "test
> configuration" start menu option (under "configure apache server") just
> displays a console window for a brief moment, then immediately disappears. 
> The icon I see near my time says "Running none of 1 Apache services"So I
> have to get that straightened out first...I believe that's been my problem all
> along.

Well, that's going to be part of it, but it's never going to work if you open 
it via Explorer. If you do that, apache won't be involved whether it's running 
or not. This will only work if you have IE (or other browser) open and put 
http://localhost/your-webpage.html into the browser's address bar. Further, 
both the webpage and PHP file need to be in your document-root. Look in your 
apache config file for that).

--
Cheers  --  Tim

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

Re: RE: [PHP] passing variables to php script

2012-01-12 Thread Tim Streater
On 12 Jan 2012 at 18:51, David Savage  wrote: 

> Installed apache onto a win2K server, and have the html file & php file in the
> same folder (Q:\ASTERISK\) on the Q: drive (which is just another drive in
> this same server).  I opened the html file using IE 6.0.   What I'm thinking
> is there may be an issue with some setting on the web server.  The php
> statements I posted were the first few statements in the script, so apparently
> the script didn't see the variables, so I'll have to review the httpd.conf and
> php.ini files to find whatever settings is preventing the acctnum, year, and
> month from being passed to the php script.  

You say:

   I opened the html file using IE 6.0

I don't like the sound of that. Do you mean you double-clicked the file and it 
opened in IE or do you mean you put Q:\... into the IE address bar or what?

What you should be doing is putting http://localhost/your-file.html in the IE 
address bar.

What is your document-root? Is the Q:\thingy part of it?

--
Cheers  --  Tim

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

Re: Re: [PHP] New to mac and trying to define a php.ini file.

2012-01-04 Thread Tim Streater
On 04 Jan 2012 at 21:59, Robert Williams  wrote: 

> On 1/4/12 14:34, "Tim Streater"  wrote:
>
>> As I hinted in my previous mail, client and server side of my app are
>> always on the user's machine. When the user starts the app, I create an
>> apache config file on the fly and run an instance of apache just for the
>> user. So I'm not messing with the standard OS X Web Sharing. For the same
>> reason, I don't want to start modifying or creating a php.ini file.
>
> In that case, you might consider setting it via the Apache config file
> that you're creating, which you can do with something like:
>
>php_value date.timezone 'America/Phoenix'

OK.

> That'll have the same effect (and benefits) as setting it via php.ini.
>
>>> Hmm, just looked more carefully at the docs. I see I'm going to have to
>>> add a prefs setting so the user can tell my app what timezone they are
>>> in. I find it odd that the OS can't provide this information.
>
> Well, it typically can, or at least can make a guess at it. The problem is
> that it's not something you can rely on across different OSes, as some
> handle it differently, or less reliably, or not at all. Basically, the
> result is non-deterministic. It's for this reason that, as of 5.4, PHP
> won't even ask the OS but will always return UTC (and complain a bit) if
> something else hasn't been set. This way, you at least have a chance of
> consistent results.
>
> If you're only supporting OS X, you can have your script that generates
> the Apache config file retrieve the system time zone, and then use that
> value in the php_value setting. If the script is in PHP, you can do this:
>
>$timeZone = `/usr/sbin/systemsetup -gettimezone`;
>
> Which just calls the systemsetup command line utility (basically, a CLI
> front-end to the settings controlled via System Preferences). Here's what
> that call returns when run on the command line on my system:
>
>H012316WHPV:~ rewilliams$ systemsetup -gettimezone
>Time Zone: America/Phoenix

That is a very helpful hint - thanks. Yes, it's OS X only at the moment as I 
don't have access to or a great interest in the other platforms.


Not sure if this has greatly help the OP though :-)

--
Cheers  --  Tim

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

Re: Re: [PHP] New to mac and trying to define a php.ini file.

2012-01-04 Thread Tim Streater
On 04 Jan 2012 at 21:01, Robert Williams  wrote: 

> On 1/4/12 13:33, "Tim Streater"  wrote:
>
> Also, if I remember right, Apple sets up Apache so that each user has
> his/her own config file inside the conf folder. You should make any config
> changes, such as turning on PHP, in there, rather than in the primary
> config file. The latter is subject to being overwritten on OS updates and
> upgrades, while the former is not. Segregating your changes also makes it
> easier to tell exactly what you've changed from the defaults.

This is true.

>> I'm however carefully ensuring that the client and server aspects of my
>> app (which will both run on the user's machine) don't use anything except
>> what comes with the standard OS X distribution, so to fix the date time
>> issue I do:
>>
>>  date_default_timezone_set (@date_default_timezone_get ());
>
> I recommend against this. First of all, in PHP 5.4, this is just going to
> return UTC if you haven't explicitly set the time zone, and that's
> probably not what you want. Plus, the use of @ here leaves a nasty taste
> in the mouth (as it does in most cases).
>
> Instead, I suggest creating a php.ini file and changing this setting there
> by setting it to a specific time zone. For example, in mine, I have this
> line:
>
>date.timezone = 'America/Phoenix'

As I hinted in my previous mail, client and server side of my app are always on 
the user's machine. When the user starts the app, I create an apache config 
file on the fly and run an instance of apache just for the user. So I'm not 
messing with the standard OS X Web Sharing. For the same reason, I don't want 
to start modifying or creating a php.ini file.

> This ensures that PHP is always using the same zone no matter what script
> is running, avoids PHP errors if you forget to make the change in a
> script, avoids you having to modify all your scripts in the first place,
> and lets you easily change the time zone used by your applications to
> whatever you want independently of the server's own time zone (or in 5.4,
> to something other than UTC).

Hmm, just looked more carefully at the docs. I see I'm going to have to add a 
prefs setting so the user can tell my app what timezone they are in. I find it 
odd that the OS can't provide this information.



--
Cheers  --  Tim

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

Re: [PHP] New to mac and trying to define a php.ini file.

2012-01-04 Thread Tim Streater
On 04 Jan 2012 at 14:09, Richard Quadling  wrote: 

> Where do I put my php.ini file for a MacBook Air? I've only had it 2
> days and having trouble with the date.timezone setting.

Hmmm, looks like I haven't got one on my Mini. Which doesn't appear to matter 
as a number of PHP scripts will have been run here in order for you to see this 
mail.

What I do seem to have is /etc/php.ini.default which I suppose you could rename 
to php.ini if you really wanted to modify it. I'm however carefully ensuring 
that the client and server aspects of my app (which will both run on the user's 
machine) don't use anything except what comes with the standard OS X 
distribution, so to fix the date time issue I do:

  date_default_timezone_set (@date_default_timezone_get ());

systematically in my scripts.

--
Cheers  --  Tim

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

Re: Re: [PHP] Class instance pointers

2011-11-29 Thread Tim Streater
On 29 Nov 2011 at 17:01, cimodev  wrote: 

> Am 29.11.2011 16:56, schrieb Tim Streater:
>> Is there any benefit to setting a pointer to a class instance to null before
>> returning from a function? As in:
>>
>> function myfunc ()
>>  {
>>  $p = new myclass ();
>>  // do stuff
>>  $p = null;
>>  }

> No!
> In this case the GC will do that for you :)

Thanks, I expected that to be the case, but it's not been crucial up to now. 
Rather than having a script that runs for a while and quits, I'm hoping to run 
a small server written in PHP and wanted to be 100% sure that I didn't need to.

--
Cheers  --  Tim

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

[PHP] Class instance pointers

2011-11-29 Thread Tim Streater
Is there any benefit to setting a pointer to a class instance to null before 
returning from a function? As in:

function myfunc ()
 {
 $p = new myclass ();
 // do stuff
 $p = null;
 }

Thanks.

--
Cheers  --  Tim

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

Re: [PHP] include

2011-11-21 Thread Tim Streater
On 21 Nov 2011 at 11:10, Tommy Pham  wrote: 

> On Mon, Nov 21, 2011 at 2:56 AM, Tim Streater  wrote:

>> I'm looking for confirmation that:
>>
>>  include $fn;
>>
>> is an allowed form of the include statement.
>>
>
> RTFM [1] example #6 ;)

> [1] http://php.net/function.include

Thanks - I missed that one.

--
Cheers  --  Tim

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

Re: Re: [PHP] include

2011-11-21 Thread Tim Streater
On 20 Nov 2011 at 23:46, Tamara Temple  wrote: 

> Tim Streater  wrote:
>
>> At the moment I'm using an instance of apache to run PHP scripts, as
>> and when required via AJAX. Having got some understanding of web
>> sockets, I'm minded to look at having a small server to execute these
>> functions as required. The scripts, some 50 or so, are only about
>> 300kbytes of source code, which seems small enough that it could all
>> be loaded with include, as in:
>
>> > $fn = 'wiggy.php';
>> include $fn;
>> ?>
>>
>> This appears to work although I couldn't see it documented.
>
> I'm really not sure what you're looking for here -- that is pretty
> standard php practice to load php files with include -- what were you
> expecting here?

I'm looking for confirmation that:

  include $fn;

is an allowed form of the include statement.

> While it's certainly possible to rig up something using sockets, I don't
> think that's how AJAX works, and you'd need a JS library that did.

Hmmm, I think perhaps I've not made myself clear - sorry about that. At present 
I'm using AJAX and apache; I'd like to *stop* doing that (and not use another 
web server, either). In my case, client and server are the same machine - the 
user's machine. There is a browser window and JavaScript within it which makes 
the AJAX requests. I just happen to use apache to have a variety of PHP scripts 
run to provide results back to the browser window.

> Generally, you should only really need to dynamically replace parts of a
> long-running program if you don't want to restart it. However, php
> scripts are not long-running programs in general, unlike the apache
> server itself, for example, and certainly if the php scripts are running
> under apache, they will be time- and space-limited by whatever is set in
> the php.ini file. If these little scripts are merely responding to AJAX
> requests, they should be really short-lived.

At present these scripts generally are short-lived, but with some notable 
exceptions. Hence my exploration of whether I could use websockets instead.

--
Cheers  --  Tim

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

Re: Re: [PHP] include

2011-11-20 Thread Tim Streater
On 20 Nov 2011 at 10:36, Tommy Pham  wrote: 

> I think you're approaching this the wrong way.
> 1) have a clear understanding of PHP - syntax, capabilities, etc.

That's what I'm doing - gathering information about bits of PHP that I've not 
used (or not used very much) before to see how my new setup could be structured.

> 2) have a clear understand of what you're intending to do -
> application's function/purpose, features, manageability,
> expandability, portability, etc...

I have a clear idea about *that*. I want to figure out if it's possible to use 
web sockets with a small server written in PHP to replace my current structure 
of ajax + apache + processes (which I suppose it forks). I see these benefits:

1) possible benefit - presumably when an ajax request arrives, a new process is 
started and so PHP has to be loaded and initialised each time. But perhaps this 
is in some way optimised so the PHP process is left running and apache then 
just tells it to read/execute a new script.

2) Definite benefit - when a browser makes an ajax request to run a script, it 
gets no information back until the script completes. Then it gets all of it. I 
have a couple of unsatisfactory workarounds for that in my existing structure. 
Websockets appears to offer a way for the browser to receive timely information.

> 3) understand design patterns

I don't know what this means.

> What your asking is practically impossible in any programming language
> akin to 'how to un-import packages in Java' or 'how to un-using
> namespace in C#'.  If you don't want to use it, don't include it ;)

I do want to use it but would like to be able to replace it with a newer 
version. If there is no way to do this then that is a data point.

And here's another question. Can a child forked by pcntl_fork() use a socket 
that the parent obtained? Reading the socket stuff in the PHP doc, there are a 
number of user-supplied notes hinting this might be problematic.

--
Cheers  --  Tim

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

[PHP] include

2011-11-19 Thread Tim Streater
At the moment I'm using an instance of apache to run PHP scripts, as and when 
required via AJAX. Having got some understanding of web sockets, I'm minded to 
look at having a small server to execute these functions as required. The 
scripts, some 50 or so, are only about 300kbytes of source code, which seems 
small enough that it could all be loaded with include, as in:



This appears to work although I couldn't see it documented.

I'd also like to be able to replace a module without restarting the server. I 
couldn't see a way to drop an included file, do I therefore take it that there 
is none? Failing that, is there a good way to dynamically replace parts of a 
PHP program, possibly using runkit?

--
Cheers  --  Tim

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

Re: Re: [PHP] Sniping on the List

2011-11-18 Thread Tim Streater
On 18 Nov 2011 at 05:40, Robert Cummings  wrote: 

> without a proof it's just farts in the wind :) No more valid than a
> theory of creation or the big ass spaghetti thingy majingy dude. Folded

The "theory" of creation is not a theory. It's a hypothesis, as is "scientific 
creationism".

> Thus before the big bang
> is perfectly valid whether we could perceive it or not.

Not really. It's as meaningless as asking what's north of the North Pole.

--
Cheers  --  Tim

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

[PHP] socket_recv

2011-11-17 Thread Tim Streater
I'm playing around with web sockets and have found a couple of simple servers 
written in PHP. They both appear to perform the initial handshake with a client 
but then just give up because socket_recv reports that there is no data. I'm 
confused by this as, the handshake being complete, I wouldn't expect there to 
be any data if the client hasn't sent any. Is there a way to wait with timeout 
on data showing up at a socket?

--
Cheers  --  Tim

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

Re: Re: [PHP] Think I found a PHP bug

2011-11-17 Thread Tim Streater
On 16 Nov 2011 at 16:30, Geoff Shang  wrote: 

> On Wed, 15 Nov 2011, Tim Streater wrote:
>
>> I find I need to do this:
>>
>>  date_default_timezone_set (@date_default_timezone_get ());
>>
>> in all my scripts since 5.x.x to avoid rude messages.
>
> Apart from the fact that I've not seen the rude messages of which you
> speak, even though I expected to, this won't help in this case.
> date_default_timezone_get() is returning the wrong timezone.

Here's what I would otherwise get:

Warning: date(): It is not safe to rely on the system's timezone settings. You 
are *required* to use the date.timezone setting or the 
date_default_timezone_set() function. In case you used any of those methods and 
you are still getting this warning, you most likely misspelled the timezone 
identifier. We selected 'UTC' for 'GMT/0.0/no DST' instead in /Users/tim/

--
Cheers  --  Tim

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

Re: Re: [PHP] {} forms

2011-11-16 Thread Tim Streater
On 16 Nov 2011 at 14:27, Richard Quadling  wrote: 

> If you want to embed $array[CONSTANT], then the {} is used.
>
> I use {} out of habit for non arrays. Not sure if there is an impact.
>
> http://docs.php.net/manual/en/language.types.string.php#example-71
> shows the use.
>
> Oh. I've fixed the layout bug for
> http://docs.php.net/manual/en/language.types.string.php#example-70.

Ah *that's* where it was hiding. Thanks - got it now.

--
Cheers  --  Tim

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

[PHP] {} forms

2011-11-16 Thread Tim Streater
I'm looking at the source of a web sockets server and I see these various forms:

  "ws://{$host}{$path}"
  "HTTP/1.1 ${status}\r\n"

Are these simply equivalent to:

  "ws://" . $host . $path
  "HTTP/1.1 " . $status . "\r\n";

and if so, is there any particular benefit to using that form? Or if not, what 
do they mean?

(I've read up about variable variables).

Thanks,

--
Cheers  --  Tim

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

Re: RE: RE: [PHP] Safari and PDF

2011-11-16 Thread Tim Streater
On 16 Nov 2011 at 12:13, HallMarc Websites  wrote: 

> Seems strange that you are given a choice. My clients have been telling me
> that they are told to get the latest Acrobat Reader by Safari. Which they have
> done (again why allow a plugin that isn't supported get installed to begin
> with) only to be told the same exact thing the next time the click on a pdf.

Perhaps they just need to completely de-install the Acrobat plugin. When a PDF 
is in a Safari widow, there is a fade-in/fade-out
 type of array of things you can click on at the bottom of the window (not good 
UI, IMO, but there it is). You can choose to open in Preview, Save, or 
increase/decrease zoom. If you do nothing then the array fades out, but 
reappears if you mouse down there. As I say, I've not had, or needed, Acrobat 
Reader on a Mac for some 10 years. Trouble is, all these sites telling you to 
download this PDF and "needs Acrobat Reader" which is complete cock.

> Anyway, I realize this topic is now slightly off list.

True but I think you needed a rant :-)

--
Cheers  --  Tim

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

Re: RE: [PHP] Safari and PDF

2011-11-16 Thread Tim Streater
On 16 Nov 2011 at 00:43, HallMarc Websites  wrote: 

> And in conclusion; sorry, I get uppity after a long day LOL. It's as I already
> thought; the answer is NO. So here is what I will do for any of you looking
> for an answer and stumbling across my slight rant, I will detect if it is
> Safari 5.1.x and then just remove the view link and leave them with a download
> link only. Sucks if you ask me.

I have to say that I still really have no clue what you are talking about. Why 
would anyone with OS X want Acrobat Reader, when there is a perfectly good [1] 
application (note: application, not "feature") available that does the task 
just as well. And when the PDF shows up in Safari you can choose to view it 
there or open in Preview. I only do the latter if I intend to save the PDF, 
which is not always the case.

[1] Preview also allows me to adjust images when I can't be bothered to fire up 
Elements.

--
Cheers  --  Tim

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

Re: [PHP] Think I found a PHP bug

2011-11-15 Thread Tim Streater
On 15 Nov 2011 at 22:34, Geoff Shang  wrote: 

> The bug is that if a server's timezone is set to Europe/London and you
> don't set an explicit timezone in your script, if it's winter time in
> the UK, PHP thinks the timezone is UTC instead of Europe/London.

I find I need to do this:

  date_default_timezone_set (@date_default_timezone_get ());

in all my scripts since 5.x.x to avoid rude messages.

--
Cheers  --  Tim

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

Re: Re: [PHP] Safari and PDF

2011-11-15 Thread Tim Streater
On 15 Nov 2011 at 22:36, Ashley Sheridan  wrote: 

> I always thought that opening a PDF inside the browser was a rubbish
> idea anyway. I've uninstalled Adobe Reader from my work machine now and
> the world is a happier place!

Well I'd rather it displays in the browser initially, which it does but not 
always (sometimes goes straight to disk). But if it shows in the browser window 
then there are buttons to save or open in Preview. I've not needed Acrobat on a 
Mac for years.

--
Cheers  --  Tim

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

Re: [PHP] What is an information_id in directory

2011-10-29 Thread Tim Streater
On 29 Oct 2011 at 20:46, Ernie Kemp  wrote: 

> 2 - Make a new content area in Site Manager->Content Manager. It doesn't
> matter what you put in your content area, you could just put "This is my new
> content area" or "Hello World" if you so choose.
>
> 3 - Grab the information_id of the new content area you made. When you are
> editing a content area that already exists, the information_id can be gotten
> from the update page URL.
>
> I'm having trouble understanding this request:
>
> 1. In item #2 the client wishes to put content here, I can only guess he
> means a file with text in it. ?
>
> 2. Item #3 I know what an ID is but not in this context. I'm don't
> understand what the client wishes here.??
>
> Any help here would be appreciated.

I think you posted an HTML-formatted email with images to this list. That is a 
waste of time (images are stripped). You'll need to send another email 
formatted as text-only. As it stands your mail made no sense at all.

--
Cheers  --  Tim

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

Re: Re: [PHP] Execute permission question

2011-10-28 Thread Tim Streater
On 28 Oct 2011 at 16:01, Tedd Sperling  wrote: 

> On Oct 27, 2011, at 7:49 PM, Daniel Brown wrote:

> But does having execute permissions set on a script affect the scripts ability
> to run shell commands?

No, as Dan has said. But if you have a file called wiggy, containing the 
following:

   #!/usr/bin/php
   

then you can run it at the command line by typing its name at the prompt - but 
wiggy will need to have execute permission set.

--
Cheers  --  Tim

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

Re: Re: [PHP] Geo IP Location help needed...

2011-10-25 Thread Tim Streater
On 25 Oct 2011 at 02:36, DealTek  wrote: 

> On Oct 24, 2011, at 6:23 PM, Bastien wrote:
>
>> On 2011-10-24, at 9:07 PM, DealTek  wrote:

>> If the IP is showing, could there be some left over debug in some function?
>>
>> If the IP is not in your list it could be anything from a new range for a
>> region to IP spoofing or some anonymizer or even an old DB

> simple code on my part - so no debug stuff...
>
>  $ip = $_SERVER['REMOTE_ADDR'];
> $this = geoip_country_name_by_name($ip);
> echo 'The country you are in is : '.$this;
> ?>
>
> The tester with the error was a friend on his home dsl and also on his
> smartphone (so no IP spoofing from him)...
>
> but maybe the db is old from - Geo IP Location? hmmm .  how do I check?
>
> the link does not provide any contact info...
> http://us3.php.net/manual/en/book.geoip.php

You can do a test yourself by hand. Go to www.ripe.net (one of the registries 
that allocates IP addresses). Click where it says: Ripe database. In the Search 
field type your IP address. Under Sources click on All. Under Types click on 
inetnum. Under Flags click on B (shows full details). Then click on Search, and 
scroll down to look at the results. You need to look at the inetnum object that 
contains the IP address of interest, then see Country.

Be aware that what this tells you is where an IP block is registered. Nothing 
to stop the entity using it from using those addresses anywhere on the planet, 
if it has its own network.

--
Cheers  --  Tim

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

Re: Re: [PHP] Friday Distraction

2011-10-21 Thread Tim Streater
On 21 Oct 2011 at 21:30, Govinda  wrote: 

> I did not use the takethislollipop.com app, so I don't know either what is its
> point (I hesitate like others said they do, to let apps grab all my FB data),
> but here I was just commenting on FB and social apps in general.

FB already has a royalty-free non-exclusive licence to all your data anyway. 
Once you put it up there, they can use it any way they like.

--
Cheers  --  Tim

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

Re: [PHP] Friday Distraction

2011-10-21 Thread Tim Streater
On 21 Oct 2011 at 17:27, Daniel Brown  wrote: 

> I'll get this week's Friday distraction kicked off here with
> something shared with me by a Facebook friend.  If you're on Facebook,
> try this.

Well, I'm not. I took one look at their Ts&Cs and thought "Sod that!"

--
Cheers  --  Tim

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

Re: Re: [PHP] junk from my forms output

2011-10-19 Thread Tim Streater
On 19 Oct 2011 at 22:27, Simon J Welsh  wrote: 

> On 20/10/2011, at 10:24 AM, hanson zhou wrote:
>
>> I have the following in a file called "hello.php" in my htdocs directory
>> (Apache webroot).
>>
>> 
>> Your name: 
>> Your age: 
>> 
>> 
>>
>> as well as the following in a file "action.php", also in the same directory.
>>
>> Hi .
>> You are  years old.
>>
>> When I click on the submit button of the form in hello.php, it should say
>> something like:
>> "Hi Hanson.  You are 33 years old."  But instead of just saying that it also
>> appends a bunch of junk at the beginning like this:
>>
>> {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0
>> Arial;}} {\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\f0\fs20 Hi
>> hanson .\par You are 33 years old.\par } �
>>
>> Can someone help me with this?  Why does my forms reply from action.php
>> contain so much junk?  I have a Windows installation of PHP and Apache.

> You saved action.php as a RTF file rather than a plain text file. Resave it as
> a plain text file.

Sounds like you should also use a text editor rather that Word or similar for 
editing your program files. Use Notepad or whatever they have or Windows 
machines.

--
Cheers  --  Tim

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

Re: Re: [PHP] Local variable protection

2011-10-14 Thread Tim Streater
On 14 Oct 2011 at 16:46, Tedd Sperling  wrote: 

> On Oct 13, 2011, at 11:37 AM, Tim Streater wrote:
>> On 13 Oct 2011 at 16:25, Tedd Sperling  wrote: 
>>> So, if you want a main script variable (i.e., $myVar) to be accessed by a
>>> function, you can do it by stating:
>>>
>>> myFunction
>>>  {
>>>  global $myVar;
>>>  // and then using $myVar
>>>  }
>>>
>>> or
>>>
>>> myFunction
>>>  {
>>>  $myVar = $GLOBAL['myVar'] 
>>>  // and then using $myVar
>>>  }
>>
>> But presumably these are not *quite* equivalent, as modifying $myVar will
>> change the global in the first but not in the second.
>>
>> --
>> Cheers  --  Tim
>
> Tim:
>
> I see what you are saying, but the reason for that $myVar declared within the
> function is local to that function and will not change the value of $myVar in
> the main script -- as such, illustrating differences in scope.

Yes.

> But the reason for my post was to illustrate that IF one declares a variable
> in the main script THEN that variable will also be automagically included in
> the $GLOBAL array.
>
> In short, you cannot write a script without having a $GLOBAL array that
> contains every variable you create in the main script -- that is what I found
> surprising. YSMV (Your Surprise May Vary).

I suppose my reaction is more like hmmm, interesting. I use globals here and 
there, e.g. to keep argument lists from getting very long. But I never use the 
$GLOBAL array.

--
Cheers  --  Tim

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

Re: Re: [PHP] Local variable protection

2011-10-13 Thread Tim Streater
On 13 Oct 2011 at 16:25, Tedd Sperling  wrote: 

> So, if in your main script you have the statement:
>
> $myVar = 'test';
>
> Then the $GLOBAL['myVar'] has also been created and will hold the value of
> 'test' without any additional coding.
>
> While many of you will say "But of course, that's the way it works." I
> actually said "What?!?" You see, I seldom use globals in my scripts and this
> runs counter to my 'keep the globals to an absolute minimum' practice. So
> while I was thinking my scripts didn't have globals, it was a surprise to me
> to find out that in the background they were present anyway.
>
> So, if you want a main script variable (i.e., $myVar) to be accessed by a
> function, you can do it by stating:
>
> myFunction
>   {
>   global $myVar;
>   // and then using $myVar
>   }
>
> or
>
> myFunction
>   {
>   $myVar = $GLOBAL['myVar'] 
>   // and then using $myVar
>   }

But presumably these are not *quite* equivalent, as modifying $myVar will 
change the global in the first but not in the second.

--
Cheers  --  Tim

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

Re: Re: Re: Re: [PHP] Multiple SQLite statements

2011-10-11 Thread Tim Streater
On 11 Oct 2011 at 11:25, David Robley  wrote: 

> Tim Streater wrote:

>> On 11 Oct 2011 at 10:47, David Robley  wrote:

>>> Tim Streater wrote:

>>>> On 11 Oct 2011 at 03:03, Paul M Foster  wrote:

>>>>> On Mon, Oct 10, 2011 at 04:14:00PM +0100, Tim Streater wrote:

>>>>>> I would like to use the SQLite3 (not PDO) interface to SQLite, and I
>>>>>> would like to be able to supply a string containing several SQL
>>>>>> statements and have them all executed, thus saving the overhead of
>>>>>> several calls. It *appears* that this may be how it actually works,
>>>>>> but I wondered if anyone could confirm that.

>>>>> The docs appear to agree that this is allowed. See:

>>>>> http://us.php.net/manual/en/function.sqlite-exec.php

>>>> That's the SQLite interface, though, rather than the SQLite3 one. The
>>>> latter just says: "Executes an SQL query ...".

>>> Not to be a smartass or anything, but what about TIAS ?

>> What that?

> Er, Try It And See
>
> A couple of minutes experimentation might have saved you the time of email,
> wait for an answer ...

Well, there is an sqlite3 executable that one can run to do CLI things to a 
database. OS X comes with that and I was also able to download the source of 
that program, and the SQLite C amalgamation, and rebuild it myself. It is 
certainly possible, with that program, to execute a sequence of semi-colon 
separated statements. It *doesn't* work with PHP's PDO interface to sqlite, as 
I found in a test program I put together; I haven't properly tested that with 
the sqlite3 interface. I've tried asking on the sqlite general mailing list and 
(to me at least), the answers are at best unclear. There is a function, part of 
the C interface to sqlite, that talks about a sequence of statements, but I 
guess ultimately it depends on how the writer of the PHP sqlite3 interface 
implemented it.

--
Cheers  --  Tim

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

Re: Re: Re: [PHP] Multiple SQLite statements

2011-10-11 Thread Tim Streater
On 11 Oct 2011 at 10:47, David Robley  wrote: 

> Tim Streater wrote:
>
>> On 11 Oct 2011 at 03:03, Paul M Foster  wrote:
>>
>>> On Mon, Oct 10, 2011 at 04:14:00PM +0100, Tim Streater wrote:
>>>
>>>> I would like to use the SQLite3 (not PDO) interface to SQLite, and I
>>>> would like to be able to supply a string containing several SQL
>>>> statements and have them all executed, thus saving the overhead of
>>>> several calls. It *appears* that this may be how it actually works,
>>>> but I wondered if anyone could confirm that.

>>> The docs appear to agree that this is allowed. See:
>>>
>>> http://us.php.net/manual/en/function.sqlite-exec.php
>>
>> That's the SQLite interface, though, rather than the SQLite3 one. The
>> latter just says: "Executes an SQL query ...".

> Not to be a smartass or anything, but what about TIAS ?

What that?

--
Cheers  --  Tim

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

Re: Re: [PHP] Multiple SQLite statements

2011-10-11 Thread Tim Streater
On 11 Oct 2011 at 03:03, Paul M Foster  wrote: 

> On Mon, Oct 10, 2011 at 04:14:00PM +0100, Tim Streater wrote:
>
>> I would like to use the SQLite3 (not PDO) interface to SQLite, and I
>> would like to be able to supply a string containing several SQL
>> statements and have them all executed, thus saving the overhead of
>> several calls. It *appears* that this may be how it actually works,
>> but I wondered if anyone could confirm that.
>
> --
> Cheers  --  Tim
>>
>
> The docs appear to agree that this is allowed. See:
>
> http://us.php.net/manual/en/function.sqlite-exec.php

That's the SQLite interface, though, rather than the SQLite3 one. The latter 
just says: "Executes an SQL query ...".

--
Cheers  --  Tim

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

Re: Re: [PHP] Re: Oi , Portas/ Hello, Ports

2011-10-10 Thread Tim Streater
On 10 Oct 2011 at 19:30, Ashley Sheridan  wrote: 

> Jim Giner  wrote:
>
>>
>> ""QI.VOLMAR QI""  wrote in message
>> news:cab7l6ey9rkfwtmprpe0fk3doo5s1c5jyhpnbt5rjj0f_eb5...@mail.gmail.com...
>>> Alguem sabe se, e como eu posso trabalhar com as portas do computador
>> com
>>> php no windows?
>>>
>>> Do someone know if, and how, I could work with Computer logical ports
>> with
>>> PHP on Windows?
>>>
>>> ex: shell_exec('cat /dev/usbmon0 | hexdump'); <- Linux
>>>
>>
>> If you mean "use php to interrogate a port" I would think the answer is
>> No.
>> Computer port=client; PHP=server.

> You can if the port is a server port, i.e. you're creating a daemon.. But, if
> it is the client machine you wish to inspect, then as Jim mentioned, PHP is
> not for you and something like java may be better suited, although I'm not
> sure how much power an applet has in this area.

Nothing wrong with using PHP client-side, I run plenty of PHP scripts that way.

--
Cheers  --  Tim

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

[PHP] Multiple SQLite statements

2011-10-10 Thread Tim Streater
I would like to use the SQLite3 (not PDO) interface to SQLite, and I would like 
to be able to supply a string containing several SQL statements and have them 
all executed, thus saving the overhead of several calls. It *appears* that this 
may be how it actually works, but I wondered if anyone could confirm that.

--
Cheers  --  Tim

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

Re: [PHP] Variable question

2011-10-01 Thread Tim Streater
On 01 Oct 2011 at 18:59, Ron Piggott  wrote: 

> If $correct_answer has a value of 3 what is the correct syntax needed to use
> echo to display the value of $trivia_answer_3?
>
> I know this is incorrect, but along the lines of what I am wanting to do:
>
> echo $trivia_answer_$correct_answer;
>
> $trivia_answer_1 = “1,000”;
> $trivia_answer_2 = “1,250”;
> $trivia_answer_3 = “2,500”;
> $trivia_answer_4 = “5,000”;

Not completely obvious to me what you're trying to do but I assume its:

echo '\$trivia_answer_' . $correct_answer . " = \"" . $somevalue . "\";"; 

--
Cheers  --  Tim

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

Re: [PHP] Input variable from form help request

2011-09-29 Thread Tim Streater
On 29 Sep 2011 at 13:30, PHProg  wrote: 

> I'm trying to create a standard web form that will use a PHP script
> to copy a file from one server to another.

[snip]

>  if(!@copy('http://mydomain.com/files/".$_POST['trakname']."','/".$_POST['dirna
> me']."/".$_POST['trakname']."'))

This line:

  
if(!@copy('http://mydomain.com/files/".$_POST['trakname']."','/".$_POST['dirname']."/".$_POST['trakname']."'))

looks like a big mess of single and double quotes to me. Why don't you go 
through it very carefully? I'd be inclined to make a small test program 
separate from the web page stuff and do things like:

http://mydomain.com/files/".$_POST['trakname']."','/".$_POST['dirname']."/".$_POST['trakname']."';

echo $myvar;

?>

and fiddle until that works.

--
Cheers  --  Tim

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

Re: [PHP] Question about losing port number

2011-09-26 Thread Tim Streater
On 26 Sep 2011 at 23:45, vince chan  wrote: 

> I have a general question about  PHP:
> So basically I have a link, and I want the href to be absolute., so I
> do 'https://' . $_SERVER['HTTP_HOST'] . '/login' ; this gives me
> https://127.0.0.1/login on my local; however, what i really want is
> https://127.0.0.1:9090/login, it is missing ":9090". I also have tried to
> use  $_SERVER['SERVER_PORT'],  but $_SERVER['SERVER_PORT'] doesn't give me
> 9090, it gives me 80.

Where does the 9090 come from?

--
Cheers  --  Tim

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

[PHP] Search for string followed by whitespace

2011-09-18 Thread Tim Streater
At the moment, I'm doing this:

   $start = stripos ($body, "-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Fwd: [PHP] Bug?

2011-09-15 Thread Tim Streater
On 15 Sep 2011 at 22:43, tamouse mailing lists  wrote: 

> For the floats, http://us2.php.net/operators.comparison makes it
> pretty clear (and this has been a well-known thing about floats as far
> back as Uni for me, in 1979).

The fact that floating point hardware has limited precision has been known ever 
since the first such hardware in the mid-1950's, in fact.

--
Cheers  --  Tim

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

Re: Re: Re: [PHP] What would you like to see in most in a text editor?

2011-09-14 Thread Tim Streater
On 14 Sep 2011 at 17:52, Paul M Foster  wrote: 

> Eventually I switched to Vim (counter-intuitively) because 1) there's no
> *unix variant on which it's not available; 2) at some point, you're
> probably going to *have* to know how to operate Vi if you move around
> among foreign machines and networks

Yes, this is entirely valid IMO. I still have my ultrix vi summary card for 
such occasions.

--
Cheers  --  Tim

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

  1   2   >