[PHP] Spaces in filename or path

2011-04-30 Thread Tim Streater
Does it matter to PHP filesystem functions if a path/to/file/name contains 
spaces? IOW, is this handled OK by design or should I replaces such spaces by 
backslash-space or would doing that present problems?

Thanks  --  tim


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

Re: Re: [PHP] Spaces in filename or path

2011-04-30 Thread Tim Streater
On 30 Apr 2011 at 22:33, Richard Quadling rquadl...@gmail.com wrote: 

 On 30 April 2011 22:07, Tim Streater t...@clothears.org.uk wrote:
 Does it matter to PHP filesystem functions if a path/to/file/name contains
 spaces? IOW, is this handled OK by design or should I replaces such spaces by
 backslash-space or would doing that present problems?

 Thanks  --  tim

 On Windows, PHP will happily access files and directories with spaces...

Richard,

I'll be doing this under OS X. I will be passing such paths/names to shell 
scripts too, but AIUI I can use escapeshellarg () there. As long as PHP 
filesystem functions don't have a problem then I should be OK.

Cheers  --  tim


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

Re: [PHP] Re: postgresql database access failure

2011-05-02 Thread Tim Streater
On 02 May 2011 at 11:05, e-letter inp...@gmail.com wrote: 


 Here's the URL of the relevant manual page:
 http://www.php.net/manual/en/function.pg-fetch-result.php


 The manual page did not explain the purpose of the text 'die', so was
 ignored (;)).

What, you mean this?

 $db = pg_connect(dbname=users user=me) || die();

It's what I would call an ugly and unreadable way of handing errors. Personally 
I'd do this:

 $db = pg_connect(dbname=users user=me);
 if  ($db===false)
  {
  // Do any error handling (such as writing to my log file) here
  die ();
  }

And which manual page are you talking about? die() is a function so it's 
trivial to search for it in the functions list using the search facility on all 
PHP documentation pages.

 Anyway, the php code was amended as follows:

   ?php
   $db = pg_connect('dbname=databasename user=httpd');
   $query = pg_query($db,'SELECT * FROM databasetable');
   $value=pg_fetch_result($query,100,0);
   echo 'list of files' ,$value,'\n';
   ?

 The result is a web page which shows:

 list of files12345\n

 where '12345' corresponds correctly to an equivalent value in row 100
 of the database table. However, the query requests the entire table.

 The php code was then amended as follows, which produces output from
 the database:

   ?php
   $db = pg_connect('dbname=databasename user=httpd');
   $query = pg_query($db,'SELECT * FROM databasetable');
   $value=pg_fetch_all_columns($query,1);
   var_dump($value);
   ?

 My personal recommendation, however, is to drop old-style procedural
 drivers and switch to PDO - it's much more convenient to use, IMO. If
 you use PDO, you don't need to study the API of various different DB
 drivers, and your code can easily switch from one database to another.

 What does PDO mean, so the relevant parts of the manual can be
 reviewed? Thank you.

Go to the PHP Manual front page, scroll down to Database Extensions under 
Function Reference.

I think you need to learn to find stuff for yourself in the manual. Finding 
PDO, die(), and pg_query (which you initially missed altogether) should be easy 
enough.


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

Re: [PHP] Bold links

2011-05-07 Thread Tim Streater
On 07 May 2011 at 18:42, Michael Simiyu simiyu.mich...@gmail.com wrote: 

 hey,

straw.

 some php 101 here guys :)

 i want to bold the first name and last name in the code below...

It's not PHP 101, it's HTML 101.

tim


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

Re: Re: [PHP] mysql problems

2011-05-12 Thread Tim Streater
On 11 May 2011 at 19:25, Curtis Maurand cur...@maurand.com wrote: 

 $_cartTotal=$0.00;

Surely that should be:

$_cartTotal = 0.00;


tim


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

[PHP] Error recovery - fatal errors

2011-05-14 Thread Tim Streater
I would like, in my app, to recover from as many run-time errors as possible, 
so that I can tidy up. And unsolicited output generated by the standard error 
system is really unhelpful as it becomes part of the ajax reply to the browser.

So I've added my own error handler, but it seems that I can't catch fatal 
errors. The error in question comes from doing something like:

$res = $dbh-query ($sql);

with $sql being an SQL statement, and $dbh being a database handle. I recently 
had a case where $dbh was NULL, which triggers a fatal error from SQLite. In 
principle such a bug should show up quickly, but this one had lain untriggered 
for about a year. It seems to me somewhat arbitrary for this to be designated a 
fatal error. Is there a way I can catch these? Most SQLite error situations I'm 
solving with try/catch but no luck with this one so far.

Error handling in library packages seems somewhat arbitrary - e.g. opendir may 
give an E_WARNING, but closedir, readdir don't.

tim


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

Re: Re: [PHP] Error recovery - fatal errors

2011-05-16 Thread Tim Streater
On 14 May 2011 at 15:05, Peter Lind peter.e.l...@gmail.com wrote: 

 On 14 May 2011 12:33, Tim Streater t...@clothears.org.uk wrote:
 I would like, in my app, to recover from as many run-time errors as possible,
 so that I can tidy up. And unsolicited output generated by the standard error
 system is really unhelpful as it becomes part of the ajax reply to the
 browser.

 So I've added my own error handler, but it seems that I can't catch fatal
 errors. The error in question comes from doing something like:

 Fatal errors are fatal - if you could recover from them, they wouldn't be
 fatal.

Except that this error is arbitrarily designated as fatal when it need not be. 
A few days ago I discovered register_shutdown_function as mentioned by someone 
today, and use that to pass E_ERRORs on to my error handler (as declared by 
set_error_handler). That way I can log the error properly and notify the user 
in a consistent manner. I've tested this by introducing some errors (e.g. 
unitialised variables or setting $dbh to null) and these are all nicely picked 
up.

 $res = $dbh-query ($sql);

 with $sql being an SQL statement, and $dbh being a database handle. I
 recently had a case where $dbh was NULL, which triggers a fatal error from
 SQLite. In principle such a bug should show up quickly, but this one had lain
 untriggered for about a year. It seems to me somewhat arbitrary for this to
 be designated a fatal error. Is there a way I can catch these? Most SQLite
 error situations I'm solving with try/catch but no luck with this one so far.

 You've got something wrong: either $dbh is not null or the error is
 not from sqlite. I'm guessing the former. To avoid situations like
 that, do proper error checking (i.e. actually check that your database
 connection was opened succesfully).

No, $dbh was unitialised. It was a coding error where I was using $dbhs instead 
of $dbh. Since what I was apparently trying to do last year was wrong anyway 
I've rejigged that section. And obviously I do check that the db is opened; 
just that in this instance I was using the wrong variable.

 Error handling in library packages seems somewhat arbitrary - e.g. opendir
 may give an E_WARNING, but closedir, readdir don't.

 You can avoid all problems with error output by turning off error
 displays in php.ini (set display_errors = off) - use error logging
 instead. That's the recommended setting for production servers.

This is not a browser/webserver situation in the classic manner. In this case, 
the browser, PHP code, and the instance of apache used are all running on the 
user's machine. The user just thinks they are running a local application.

Cheers  --  tim


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

Re: [PHP] Error recovery - fatal errors

2011-05-16 Thread Tim Streater
On 16 May 2011 at 21:34, Peter Lind peter.e.l...@gmail.com wrote: 

 You were trying to call a method on a non-object - how do you expect
 PHP to handle that if not with a fatal error?
 Anyway, good to hear you solved the issue - I misunderstood what you
 wanted to do (shut down in a proper fashion, not actually recover from
 the error) so I didn't think to mention this.

Thanks, yes, that all appears to be function OK now. Meanwhile I'm chasing a 
strangeness to do perhaps with UTF-8 - I send some simplified Chinese back from 
the PHP side as part of an ajax response to the browser for it to display, and 
in one case it does it right, in another the browser converts it to something 
else. I'm trying to duplicate this in a testbed with no success so far. Still, 
it keeps me off the streets :-)

Cheers  --  tim 


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

Re: Re: [PHP] A Review Request

2011-05-18 Thread Tim Streater
On 18 May 2011 at 20:31, Joshua Kehn josh.k...@gmail.com wrote: 

 On May 18, 2011, at 3:22 PM, tedd wrote:

 What do you people think?

 I can say I really don't like your bracing style.

I completely disagree - having the braces lined up is the only way to go. Means 
I don't have to search all over creation for the matching one :-)

More constructively: you might want to say Copy/Paste rather than Cut/Paste.

I've found examples of this type to be very helpful in the past, btw. Much of 
my learning is done by poking around for information to solve problems I may 
have with some combination of PHP, ajax, javaScript, CSS, and/or HTML, so good 
for you is what I say.

Tedd: you have written who's instead of whose on your √ website.

tim


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

Re: Re: [PHP] A Review Request

2011-05-18 Thread Tim Streater
On 18 May 2011 at 22:22, Peter Lind peter.e.l...@gmail.com wrote: 

 On 18 May 2011 23:12, tedd t...@sperling.com wrote:

 This is just one way to give-back.

 Suggesting people that they copypaste your code is a very bad way of
 giving back. Suggesting that they read and understand the code is a
 great way. I hope you see the difference.

Not obvious. If I have copy/pasted code and it hasn't worked, that's been 
no-one's fault but mine, and I've then gone back and looked at it more 
carefully. Any example given on the web, seems to me, is likely to be 
copy/pasted unless you take steps to make it not possible.

tim


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

Re: Re: [PHP] Warning: session_start()

2011-05-19 Thread Tim Streater
On 19 May 2011 at 10:20, Richard Quadling rquadl...@gmail.com wrote: 

 On 18 May 2011 19:15, Nazish naz...@jhu.edu wrote:

 Hi everyone,

 !---
            WHEN USER CLICKS 'ENTER' TO LOGIN
 !
 ?php

code, code, code.

 ?

 The session cookie must be sent prior to any output. Including, but
 not limited to, comments, whitespace, HTML code, etc.

 2 - Remove all white space. Personally, this is the route I would use.

For the sake of completeness, that is whitespace *outside* the ?php ? tags.

tim


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

Re: Re: [PHP] A Review Request

2011-05-20 Thread Tim Streater
On 20 May 2011 at 04:03, Alex Nikitin niks...@gmail.com wrote: 

 but here is a brief example:

 (!DEBUG) || error_log(Fetch Data: .memory_get_usage()/1048576);

 reads and writes a lot better and faster then:

 if(DEBUG) {
$memory = memory_get_usage()/1048576;
error_log(Fetch Data: .$memory);
 }

Not to me it doesn't. I find such usage incomprehensible.

tim


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

Re: Re: [PHP] A Review Request

2011-05-20 Thread Tim Streater
On 19 May 2011 at 23:47, Adam Richardson simples...@gmail.com wrote: 

 You did make several other great points (session hijacking, multiple login
 attempts), but to be fair to Tedd, there are many levels of security, and I
 doubt he's trying to educate PHP developers with your background. In the
 same way that someone's first foray into the world of database access using
 PHP likely avoids a 20 table database with complex transactions for atomic
 operations and in-memory queues for  eventually consistent data where
 performance is a must, I see this as a reasonable first exposure to the
 general principles of how one might use the features of PHP to password
 protect a group of pages in a site.

I think this is the salient point. Provided the example is correct in itself, 
is marked as being aimed at the novice, and at the same time lists some of the 
areas that deliberately haven't been addressed in the example provided, then 
that should suffice.

The difficulty IME is finding more advanced examples, which would help the 
transition from learning mode to preparing for a production environment.

tim


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

Re: Re: [PHP] how to use echo checkboxes in php when i don't have access to $_POST

2011-05-28 Thread Tim Streater
On 28 May 2011 at 14:11, Igor Konforti php@confiq.org wrote: 

 It means that array $_POST does not have a key called negin.
 Simple If statement before line 4 would fix this.

 On Sat, May 28, 2011 at 16:03, Negin Nickparsa nickpa...@gmail.com wrote:

 suppose that i have this SIMPLE code:
 ?php
 echoinput type='Checkbox' name='negin'  value='yes' checked /;
 echo $_POST['negin'];
 ?
 html
 head
 body
 form method=post
 /form
 /body
 /head
 /html
 error is this:
 Undefined index: negin in *D:\phpweb\negin2.php* on line *4*
 *
 *
 *how can I correct this?*

For one thing you need to have the PHP code inside the form/form. Second 
you don't need to echo the input, just write that straight into the HTML. And 
you need to use the isset() function so you don't try to echo $_POST['negin'] 
unless it it is set.

--
Cheers  --  Tim

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

Re: Re: [PHP] iPhone sadness

2011-05-30 Thread Tim Streater
On 30 May 2011 at 19:07, jean-baptiste verrey jeanbaptiste.ver...@gmail.com 
wrote: 

 I like how people just like to complain about everything^^
 But as the debate is raging I had a look over internet and
 http://www.caliburn.nl/topposting.html gave the best argument ever :
 we read from *top* to *bottom *so top posting makes you read useless
 information^^

Actually, if you're trying to make *that* argument, then in fact the reverse is 
true: *bottom* posting makes you read useless information - because all the 
stuff I see first I've seen before. It's worse on Usenet in fact because there 
are some * who never learnt to snip. So I have to scroll down two pages 
just to see their one-liner. Sometimes that's a problem here, too.

--
Cheers  --  Tim

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

Re: [PHP] Announcing New PHP Extension: System Detonation Library (was: phpsadness)

2011-06-04 Thread Tim Streater
On 03 Jun 2011 at 16:56, Daniel Brown danbr...@php.net wrote: 

 First of all, a happy Friday to all here.  Hopefully some of you
 will be able to pass this on to your boss and get sent home early.

Second, as dreamed up in the previous thread, I've decided to take
 a few moments this morning to build and release a new PHP extension,
 which provides a single function: detonate().

No Manfred Mann though.

--
Cheers  --  Tim

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

Re: Re: [PHP] phpsadness - P.C. shmee seee.

2011-06-05 Thread Tim Streater
On 05 Jun 2011 at 06:08, Tamara Temple tamouse.li...@gmail.com wrote: 

 On Jun 3, 2011, at 3:52 PM, Daevid Vincent wrote:
 ...actually, I do have some good ones here:
 http://daevid.com/content/examples/procmail.php

 It appears your browser does not support some of the advanced
 features this site requires.
 Please use Internet Explorer or Firefox.

 ROFL. Good one.

Anyone whose site says that sort of crap needs a good smack.

--
Cheers  --  Tim

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

Re: Re: [PHP] Re: phpsadness - P.C. shmee seee.

2011-06-05 Thread Tim Streater
On 05 Jun 2011 at 16:23, Geoff Shang ge...@quitelikely.com wrote: 

 On Sun, 5 Jun 2011, Richard Riley wrote:

 I don't.  I just don't want them to lock out my browser just because they 
 don't
 support it.  Many pages which don't work optimally under Lynx can still be 
 read,
 which is all I'm wanting to do anyway.

 They need to or there can be unintentional side affects that will
 reflect badly on them and possibly you.

 Rubbish.  All they need to do is what everyone else does and say This
 site may not work well on your browser, we recommend using Internet
 Explorer or firefox (or whatever they support).  Then if I choose to use
 it, it's on my own head, which is fine by me.

 If you really want a half arsed user experience then set your browser
 string ;) Would that not work for you?

 It probably would.  But this tangent began with the principle of Use IE
 or Firefox and how we hated sites that said that.  It's the principle of
 the thing.

Yes. You might (just) be able to justify something really old [1], but Safari 
5.0.5? I find that to be a damn cheek. I expect sites to be standards-based.



[1] Don't ask me what that means. I've not kept up with what new stuff is 
around now that wasn't, ten years ago.

--
Cheers  --  Tim

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

Re: Re: [PHP] Re: phpsadness - P.C. shmee seee.

2011-06-05 Thread Tim Streater
On 05 Jun 2011 at 21:28, Geoff Shang ge...@quitelikely.com wrote: 

 On Sun, 5 Jun 2011, Richard Riley wrote:

 If they allowed incompatible browsers that caused havoc then before you
 know it the great unwashed would be demanding more and better support or
 complaining about lack of functionality. Doing what they do they make it
 very clear from day one.

 This would be a fair enough attitude if they only applied it to their
 member sections, but they don't.  They set themselves up as publishers of
 information, page hosts of sorts, then don't let anyone in who wants to
 *read* them.

This sums it up better than I could:

Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee

-- 
Cheers  --  Tim

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

Re: [PHP] What do you get for ...

2011-06-07 Thread Tim Streater
On 07 Jun 2011 at 11:35, Richard Quadling rquadl...@gmail.com wrote: 

 What do you get for ...

 php -r var_dump(realpath(null));

OS X:  string(10) /Users/tim


--
Cheers  --  Tim

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

Re: [PHP] jQuery to PHP

2011-06-22 Thread Tim Streater
On 22 Jun 2011 at 19:44, Ethan Rosenberg eth...@earthlink.net wrote: 

 I have a PHP program which will generate a chess board with a form in
 the program. I wish to fill the form by clicking one of the
 squares  in the chess board.  I am trying to use jQuery and Aja to do
 this.  The Ajax call works, but the value never gets into the form.

So where is jq_test.php? And why do you seem to be referring to it both in what 
looks like an ajax request (I've never ever looked at jquery, so I'm guessing 
here) and also as the action of a form?

--
Cheers  --  Tim

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

Re: Re: [PHP] jQuery to PHP

2011-06-22 Thread Tim Streater
On 22 Jun 2011 at 20:56, Jim Lucas li...@cmsws.com wrote: 

 On 22/6/2011 12:43 PM, Tim Streater wrote:
 On 22 Jun 2011 at 19:44, Ethan Rosenberg eth...@earthlink.net wrote:

 I have a PHP program which will generate a chess board with a form in
 the program. I wish to fill the form by clicking one of the
 squares  in the chess board.  I am trying to use jQuery and Aja to do
 this.  The Ajax call works, but the value never gets into the form.

 So where is jq_test.php? And why do you seem to be referring to it both in
 what looks like an ajax request (I've never ever looked at jquery, so I'm
 guessing here) and also as the action of a form?

 The example script that he showed is jq_test.php   He could have left
 action=
 and it would do the same thing.

So the OP is using the form's action to reload the page, and seemingly making 
an ajax call under some circumstance that will also retrieve the whole contents 
of the same page - and do what with it?

Anyway if you just want to get the coords of a square into a form by clicking, 
I'd have thought just use JavaScript. No need for ajax for that bit, IMO. Use 
the ajax stuff to send the move off to the chess program script, and use its 
reply to update the board showing the new position.

--
Cheers  --  Tim

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

Re: Re: Re: [PHP] jQuery to PHP

2011-06-22 Thread Tim Streater
On 22 Jun 2011 at 21:56, Ethan Rosenberg eth...@earthlink.net wrote: 

 At 04:30 PM 6/22/2011, you wrote:
 On 22 Jun 2011 at 20:56, Jim Lucas li...@cmsws.com wrote:

 So the OP is using the form's action to reload the page, and
 seemingly making an ajax call under some circumstance that will also
 retrieve the whole contents of the same page - and do what with it?

 Anyway if you just want to get the coords of a square into a form by
 clicking, I'd have thought just use JavaScript. No need for ajax for
 that bit, IMO. Use the ajax stuff to send the move off to the chess
 program script, and use its reply to update the board showing the new
 position.

 I am not trying to reload the page.  I am trying to send the
 coordinate of the chess square, which is identified by an id, to the
 form.  The ajax call does work, since when it runs, it shows an alert
 Yippee.  However, nothing appears in $_POST or $_GET.  I hope this
 clarifies the issue.

Ethan,

1) The page will reload when you click on Enter move, ISTM.

2) Instead of doing alert(yippee), seems to me you should alert on the 
results of the ajax call. I don't know how you get at those with jquery, but I 
imagine that is where you'll find the results of doing var_dump($_POST);

3) Where *are* you expecting the output from var_dump($_POST); to appear, and 
why?

4) You say the ajax call works. Well, for some value of works, perhaps, but 
you are calling for your own page to be the script to be run, I can't really 
see the point of that.

5) For a simple but effective ajax example, see http://www.clothears.org.uk.

6) If you're attaching an onclick to each table cell, the onclick handler can 
write the cell's id into the form, seems to me. Why use ajax for that?

BTW, I'm replying via the list (even though so far this has minimal PHP 
content) because my mail host at clothears appears to be on earthlink's 
shitlist.

--
Cheers  --  Tim

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

Re: [PHP] jQuery to PHP

2011-06-23 Thread Tim Streater
On 23 Jun 2011 at 14:56, Ethan Rosenberg eth...@earthlink.net wrote: 

 At 05:21 PM 6/22/2011, you wrote:

 2) Instead of doing alert(yippee), seems to me you should alert on
 the results of the ajax call. I don't know how you get at those with
 jquery, but I imagine that is where you'll find the results of doing
 var_dump($_POST);

 The results should be in $_POST. I have done a print_r and var_dump
 and nothing is there.  My question was if the call ever worked.

But you don't know that nothing is there because you haven't looked for the 
output.

When an ajax call is made, it causes a script on the server to be run. You tell 
the ajax call what script you want to have run, in this case apparently 
jq_test.php. All output from that script will be returned to the function you 
specify in the ajax call. As I said, I don't know jquery, but I'm guessing that 
that is the success: function - and in that you do nothing with the returned 
results. I should also point out that *all* output from the script will be 
returned there. That means anything from an echo or var_dump statement, but 
also anything *outside* ?php and ?, which means all the html that is in your 
file jq_test.php too. It's all concatenated together as one humungous text 
string and returned to your ajax success: function. And because you're not 
looking at those results, you won't see them.

 3) Where *are* you expecting the output from var_dump($_POST); to
 appear, and why?

 As I understand, $.post [which is an Ajax call??] should put the results into 
 $_POST in the URL: in the call.

Well, it might put it into $_POST[move_from], possibly, but I don't know what 
the JavaScript behind this jquery call actually does.

 5) For a simple but effective ajax example, see
 http://www.clothears.org.uk.

 Looks good.

Thanks but have you understood it?

 6) If you're attaching an onclick to each table cell, the onclick
 handler can write the cell's id into the form, seems to me. Why use
 ajax for that?

 Please tell me how to do that [write cell's id into form].

Something like (e.g.):

Move From: input type=text name=move_from id=xyz/input

and then in your onclick handler:

document.getElementById(xyz).textContent = this.id;

I'd say also that you need to keep separate your HTML page (where you display 
your 8x8 grid and click on the cells) from any PHP scripts you want to run with 
ajax.


--
Cheers  --  Tim

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

Re: [PHP] Re: Php filter validate url

2011-06-27 Thread Tim Streater
On 27 Jun 2011 at 00:15, Richard Riley rile...@googlemail.com wrote: 

 In addition your content type in your post is incorrect.

 Your header contains

 Content-Type: multipart/alternative;
 boundary=00151747b53cf2927204a6a46ebb

 But its not multipart. This happens a lot in this group and I dont
 experience it elsewhere so I dont know if its a php programmer thing,
 an gmane artifact or something the mailing list does.

I couldn't see anything in RFC2046, section 5.1.4, to suggest that 
multipart/alternative *requires* that there be more than one part. And why does 
it matter, anyway?

--
Cheers  --  Tim

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

Re: Re: [PHP] Re: [PHP-DB] Re: radio form submission

2011-06-27 Thread Tim Streater
On 27 Jun 2011 at 13:18, Steve Staples sstap...@mnsi.net wrote: 

 On Sat, 2011-06-25 at 16:11 -0500, Tamara Temple wrote:

 Well played, sir, well played. I think we should go through all the
 xkcd comics that relate to programming somehow and insert them in the
 php.net documentation :)


 Tamara, kind of like this one?

 http://ca3.php.net/manual/en/control-structures.goto.php

I haven't used a 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

Re: [PHP] PHP 5.4.0alpha1 released

2011-06-28 Thread Tim Streater
On 28 Jun 2011 at 22:39, David Soria Parra d...@php.net wrote: 

 You can read more information about this release here:
 http://www.php.net/archive/2011.php#id2011-06-28-1

Not quite yet, perhaps?

--
Cheers  --  Tim

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

Re: Re: [PHP] Time zones are spinning my brain

2011-06-29 Thread Tim Streater
On 29 Jun 2011 at 17:25, Richard Quadling rquadl...@gmail.com wrote: 

 And UTC is not the same as GMT. Ish.

Yes it is.

 GMT is only valid for 6 months of the year. Then, due to DST, it becomes BST.

No, the UK is on GMT for 5 months a year and then on BST (GMT+1) for 7 months.


--
Cheers  --  Tim

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

Re: [PHP] PHP EOL

2011-07-04 Thread Tim Streater
On 04 Jul 2011 at 08:01, Stuart Dallas stu...@3ft9.com wrote: 

 On Mon, Jul 4, 2011 at 7:11 AM, Karl DeSaulniers k...@designdrumm.comwrote:

 Hello Stuart,
 After some closer look at the RFC Compliant manuals you suggested,
 I have determined that the creator of that code was in fact RFC821
 Compliant.
 Being that this was a code I found several years ago, RFC822 may not have
 been in effect.
 This being the reason (I believe) that the creator went with a check for
 System OS when determining the end of line characters to use.
 Not substantiated in any way, but that is what it looks like to me. I could
 stand corrected.


 RFC821: Simple Mail Transfer Protocol, dated August 1982 (
 http://www.faqs.org/rfcs/rfc821.html)

 RFC822: Standard for the Format of ARPA Internet Text Messages, dated August
 13, 1982 (http://www.faqs.org/rfcs/rfc822.html)

There are more recent RFCs than these. RFC822 was obsoleted by RFC2822, for 
example, which was itself obsoleted by RFC 5322. See here:

http://tools.ietf.org/html/rfc5322

I always use this site for looking at RFCs as every line in the contents of an 
RFC is an internal link which makes finding things in the RFC rather easier. 
The following list of RFCs is the set I consulted when writing my own email 
client:

a)  RFC 5034 POP3
b)  RFC 2821 SMTP
c)  RFC 5322 Internet Message Format
d)  RFC 2045, 2046, 2047, 2048, 2049, (MIME), and 2183


--
Cheers  --  Tim

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

Re: [PHP] Top Posting

2011-07-05 Thread Tim Streater
On 05 Jul 2011 at 15:29, ad...@buskirkgraphics.com wrote: 

 Since this is the 3rd time I have been chewed out for top posting.

 Anyone know how to make Outlook changes its reply position.

 I am using outlook 2007 and I do not find an option for this.

 I have to scroll down to the bottom of the email and it considers that to be
 an adjustment to the original email, plus I have to manually write my
 signature block.

What is meant by an adjustment to the original mail? You could try switching 
to another email client.

--
Cheers  --  Tim

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

Re: Re: [PHP] Re: Re: Top Posting

2011-07-06 Thread Tim Streater
On 06 Jul 2011 at 20:03, Jim Giner jim.gi...@albanyhandball.com wrote: 

 You are currently listed in my /etc/postfix/helo_checks file as

 64.118.87.45 REJECT Your mail server is a source of SPAM.  Fix it!

 My mail server is my isp's.  It is a shared server and not under my control.
 They are aware that is listed but cannot get to the bottom of why it is
 flagged.
 Frankly, I don't know why you are getting mail from me - I'm not sending you
 any.

 As for your solution to spam.  What is Postfix?

Rather than rely on heuristics, I wrote a Bayesian filter for my e-mail app. 
Let the spammer, by sending you the mail, indicate what is spam and what is not.

--
Cheers  --  Tim

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

Re: Re: [PHP] Re: Re: Top Posting

2011-07-06 Thread Tim Streater
On 06 Jul 2011 at 20:03, Jim Giner jim.gi...@albanyhandball.com wrote: 

 Frankly, I don't know why you are getting mail from me - I'm not sending you
 any.

You're sending mail to all of us. Here's what I got from you:

To:  php-general@lists.php.net
From:Jim Giner jim.gi...@albanyhandball.com
Subject: Re: [PHP] Re: Re: Top Posting
Date:Wed, 6 Jul 2011 15:03:44 -0400

 You are currently listed in my /etc/postfix/helo_checks file as

 64.118.87.45 REJECT Your mail server is a source of SPAM.  Fix it!

My mail server is my isp's.  It is a shared server and not under my control.
They are aware that is listed but cannot get to the bottom of why it is
flagged.
Frankly, I don't know why you are getting mail from me - I'm not sending you
any.

As for your solution to spam.  What is Postfix?

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


--
Cheers  --  Tim

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

[PHP] What is a label?

2011-07-13 Thread Tim Streater
Looking over the definition of a function today I see:

Function names follow the same rules as other labels in PHP.

but I can't find the definition of a label anywhere. I can't see it listed in 
the contents - have I overlooked it? If not, how can I request the the doccy be 
updated?

Tim Streater
Bedford House
Kake St
Waltham  CT4 5RZ
01227 700322

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

Re: Re: [PHP] What is a label?

2011-07-13 Thread Tim Streater
On 13 Jul 2011 at 22:39, Micky Hulse rgmi...@gmail.com wrote: 

 They must mean labels as in general naming convention rules for
 programming... Like not naming a variable/function label with a number at
 the front.

 Here's a page about variables:

 http://www.php.net/manual/en/language.variables.basics.php

 Variable names follow the same rules as other labels in PHP. A valid
 variable name starts with a letter or underscore, followed by any
 number of letters, numbers, or underscores. As a regular expression,
 it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'

Except that variables are case-sensitive whereas function names are not. And if 
there's going to be a formal or programmatic definition, then I think I'd 
prefer BNF to a regexp.

--
Cheers  --  Tim

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

Re: Re: [PHP] Your language sucks because...

2011-07-14 Thread Tim Streater
On 14 Jul 2011 at 01:59, Lester Caine les...@lsces.co.uk wrote: 

 Daevid Vincent wrote:
 (at the risk of starting another $h!t storm like the last time)

 http://wiki.theory.org/YourLanguageSucks#PHP_sucks_because:

 Perhaps when they get around to checking the facts ... most of the content
 will
 be deleted? A number of the -ve's I'd personally flag as +ve's and complain if
 anybody changed them ...
 Generally I'd say the whole page simply sucks :)

Particularly as it's written by a fathead who thinks that lose is spelt 
loose.

--
Cheers  --  Tim

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

Re: [PHP] How to sum monetary variables

2011-07-18 Thread Tim Streater
On 18 Jul 2011 at 23:00, Martín Marqués martin.marq...@gmail.com wrote: 

 I'm building a table (which is a report that has to be printed) with a
 bunch of items (up to 300 in some cases) that have unitary price
 (stored in a numeric(9,2) field), how many there are, and the total
 price for each item. At the end of the table there is a total of all
 the items.

 The app is running on PHP and PostgreSQL is the backend.

 The question is, how do I get the total of everything?

 Running it on PHP gives one value, doing a sum() on the backend gives
 another, and I'm starting to notice that even using python as a
 calculator gives me errors (big ones). Right now I'm doing the maths
 by hand to find out who has the biggest error, or if any is 100%
 accurate.

Much safer to price everything internally in pence or cents or whatever, and 
convert to £xxx.xx for external display. Then just use integer arithmetic for 
the calculations.

--
Cheers  --  Tim

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

[PHP] Use of preg_replace

2011-07-24 Thread Tim Streater
I need to be able to convert a line of the form:

From

to have either one more or one less  at the front. A web site tells me that 
the regexps to use are:

1,$s/^*From //

and

1,$s/^(*From )/\1/

respectively (there is a single space after From). So, if my text string is 
in $line, I ought to be able to do something like:

$line = preg_replace ($pattern, $replacement, $line);

But, since all regexps are to me, like TECO commands, no better than 
line-noise, how do I make up $pattern and $replacement from the proffered 
regexps?

Thanks.

--
Cheers  --  Tim

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

Re: RE: [PHP] Use of preg_replace

2011-07-24 Thread Tim Streater
On 24 Jul 2011 at 19:35, Dajka Tamás vi...@vipernet.hu wrote: 

 I lost trail, what do you want to do?

 You want to convert

 From

 to this:

 From

The number of  in front of From  is not known. I want to be able to add or 
remove one.

--
Cheers  --  Tim

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

Re: RE: RE: [PHP] Use of preg_replace

2011-07-24 Thread Tim Streater
On 24 Jul 2011 at 19:57, Dajka Tamás vi...@vipernet.hu wrote: 

 You want to do it in a greater text, I think.

 1,$s/^(*From )/\1/

 $line = preg_replace ($pattern, $replacement, $line);

 Adding one '':

 preg_replace('/(^[]+From )/','$1', $line)

 Removing one '':

 preg_replace('/(^([]+From )/','$1', $line)

Thanks, I'll try that.

--
Cheers  --  Tim

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

Re: RE: RE: [PHP] Use of preg_replace

2011-07-24 Thread Tim Streater
On 24 Jul 2011 at 19:57, Dajka Tamás vi...@vipernet.hu wrote: 

 You want to do it in a greater text, I think.

See below.

 1,$s/^(*From )/\1/

 $line = preg_replace ($pattern, $replacement, $line);

 Adding one '':

 preg_replace('/(^[]+From )/','$1', $line)

 Removing one '':

 preg_replace('/(^([]+From )/','$1', $line)
 ^
 |
Missing ) ---+

In fact I forgot to mention that the string always starts at the start of the 
line. So, I experimented a bit and the following works:


$onemore = preg_replace ('/^(*From )/', '$1', $line);
$oneless = preg_replace ('/^(*From )/', '$1', $line);

Thanks for the help.

--
Cheers  --  Tim

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

[PHP] pathinfo function

2011-07-26 Thread Tim Streater
Is it to be expected that, if a file has no extension, and I do this:

   $info = pathinfo ($myfile);

that I will get an error if I try to reference $info[extension] ??

--
Cheers  --  Tim

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

Re: Re: [PHP] pathinfo function

2011-07-27 Thread Tim Streater
On 26 Jul 2011 at 23:55, Micky Hulse rgmi...@gmail.com wrote: 

 On Tue, Jul 26, 2011 at 3:47 PM, Tim Streater t...@clothears.org.uk wrote:
 that I will get an error if I try to reference $info[extension] ??

 From what I can tell via reading the docs:

 The following associative array elements are returned: dirname,
 basename, extension (if any), and filename.
 http://php.net/pathinfo

 Makes me think that if the extension does not exist, then the
 extension key will not exist.

Seems to me that's the case. However the doc is ambiguous, especially as I 
*asked* for that key to be returned. IMO it should exist and be empty. Not 
existing is only OK if I didn't ask for it.


--
Cheers  --  Tim

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

Re: RE: Re: [PHP] pathinfo function

2011-07-27 Thread Tim Streater
On 27 Jul 2011 at 11:09, Mike Ford m.f...@leedsmet.ac.uk wrote: 

 -Original Message-
 From: Tim Streater [mailto:t...@clothears.org.uk]

 Seems to me that's the case. However the doc is ambiguous,
 especially as I *asked* for that key to be returned. IMO it should
 exist and be empty. Not existing is only OK if I didn't ask for it.

 This is how you tell the difference between a basename with a null
 extension (/path/filename.) and no extension (/path/filename).
 In the former case you get $info[extension]=, in the latter
 there is no [extension] element in the returned array.

OK, this makes sense.

 This does seem like the most logical way to make this distinction,
 but the manual could use a bit of work to document this and other
 edge cases more explicitly.

I may have a go at this if I can find a round tuit.

--
Cheers  --  Tim

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

Re: Re: [PHP] Re: testing

2011-08-04 Thread Tim Streater
On 04 Aug 2011 at 15:48, Jim Giner jim.gi...@albanyhandball.com wrote: 

 Sounds like time for me to move on.
 Thanks for the info Dan.

Say Jim,

Why don't you pick it up as mail like the rest of us?

--
Cheers  --  Tim

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

Re: Re: [PHP] pass text variables to next page

2011-08-09 Thread Tim Streater
On 09 Aug 2011 at 13:30, Chris Stinemetz chrisstinem...@gmail.com wrote: 

 Not sure if I am doing it right. It looks like the last single quote
 is being escaped.

 When I dump the query I get:

 SELECT store_id, store_subject FROM stores WHERE store_subject =
 'Bella Roe 4980 Roe Blvd\'


 I am thinking maybe I have too many single quotes some where, but I
 can't find it.

 echo 'h4a href=store.php?id=' . $storerow['store_subject'] . ''
 .. $storerow['store_subject'] . '/a/h4 at ' . date('m-d-Y',
 strtotime($storerow['store_date']));


 The query:

 $sql = SELECT store_id, store_subject
   FROM stores
   WHERE store_subject = ' . mysql_real_escape_string($_GET['id'].');

Why don't you:

1) Make this a single line instead of splitting it over three. No need to do 
that.

2) Having created $sql, echo it out. That way you could see whether it's 
correct or not.

Doing (1) and (2) will make it a damn sight easier to see what you are 
*actually* creating.

--
Cheers  --  Tim

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

Re: [PHP] Using function prototypes in code

2011-08-10 Thread Tim Streater
On 10 Aug 2011 at 02:10, Frank Thynne frank.thy...@gmail.com wrote: 

 In the interest of clarity and maintainability I would like to be able
 to write code that makes it clear what kind of arguments a function
 expects and what it returns.

So add the appropriate comments to your functions.

 This is what I tried:

 function integer int_func(string $s) {
  // does something like, say, converting five to 5
 }

 There are two problems:
 1 The appearance of a type name before the function name is treated as
 a syntax error
 2 Even if I forget about declaring the return type and code it instead
 as

 function int_func(string $s) {
 ...
 }

 I get a run-time error when I call the function with a string. (eg
 $var = int_func(five);) The error message saysCatchable fatal
 error: Argument 1 passed to int_func() must be an instance of string,
 string given.

Why are you doing this when the documentation clearly states that this is not 
how it works. Did you not read up about it first?

 It seems that basic data types cannot be specified in ths way although
 (intstances of) classes can. I have successfully used the technique to
 catch run-time errors of wrong object types when testing, but am
 surprised that I can't use it to trap unexpected basic types - or at
 least to document what is expected.

This is PHP, not FORTRAN IV.

Personally I see it as a great step forward that for the most part, I don't 
have to bother.

--
Cheers  --  Tim

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

Re: Re: [PHP] text insertion

2011-08-10 Thread Tim Streater
On 10 Aug 2011 at 22:39, Daniel P. Brown daniel.br...@parasane.net wrote: 

 On Wed, Aug 10, 2011 at 17:37, Chris Stinemetz chrisstinem...@gmail.com
 wrote:
 No luck. Thanks.

Per list rules, please don't top-post.

If the situation you're describing is accurate and correct, then
 pre is indeed what you want.

But can you put a pre/pre inside a table cell? (I don't know that you 
can't, but it seems an odd thing to do).

--
Cheers  --  Tim

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

Re: Re: [PHP] text insertion

2011-08-10 Thread Tim Streater
On 10 Aug 2011 at 22:07, Chris Stinemetz chrisstinem...@gmail.com wrote: 


    Use HTML 'pre' tags:

        pre?php echo $your_content; ?/pre


 I just tried that and that puts all the text on a single line.

You could write the string into another textarea, which you could make readonly 
for this purpose.

--
Cheers  --  Tim

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

Re: [PHP] Problem with inserting numbers...

2011-08-11 Thread Tim Streater
On 11 Aug 2011 at 02:22, Jason Pruim pru...@gmail.com wrote: 

 while ($num != 1) {
while($row = mysql_fetch_assoc($result)) {
$padnum = number_pad($num, 4);
echo $row['areacode'] . - . $row['prefix'] . - . $padnum . BR;
$num++;
}


 }

This is certain to fail. You've got the $num++ in the *inner* loop, and are 
checking its value in the *outer* loop. Think about it: suppose you enter the 
inner loop with $num being 9998. Suppose also that you then go round the inner 
loop 5 times. What is the value of $num when you then exit the inner loop in 
order to do the test against 1 in the outer loop?

You need to rework that logic.

--
Cheers  --  Tim

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

Re: Re: [PHP] Login with Remember me Feature

2011-08-14 Thread Tim Streater
On 14 Aug 2011 at 14:23, Alekto Antarctica alekto.antarct...@gmail.com wrote: 

 *function loggedin()*
 *{*
 * if (isset($_SESSIONS['username']) || isset($_COOKIE['username']))*
 * {*
 * $loggedin = true;*
 * return $loggedin;*
 * }*
 *}*

Why not justreturn true;

And what happens if your if doesn't evaluate to true? What do you return then?


 *?php*
 *
 *
 *if (loggedin==true)*
 *{*

Should this be:

  if ($loggedin==true) ...

--
Cheers  --  Tim

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

Re: [PHP] How to catch an irregular end of an application?

2011-08-26 Thread Tim Streater
On 26 Aug 2011 at 01:33, Andreas maps...@gmx.net wrote: 

 what is the best practice to catch an irregular end of an application?
 The browser might crash or the user closes accidently the browser window
 decides to jump away to his favourite bloq without loging out of my
 application.
 Is there some way to let an javascript event trigger some ajax to store
 an exit time into my DB or make it mandatory to at least visit the
 logout.php before someone can surf away?

Use the onbeforeunload event.

--
Cheers  --  Tim

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

Re: Re: [PHP] Re: Code should be selv-maintaining!

2011-08-29 Thread Tim Streater
On 29 Aug 2011 at 21:32, George Langley george.lang...@shaw.ca wrote: 

 The One True Brace Style:

 http://en.wikipedia.org/wiki/Indent_style

 Didn't know there was a name for the way I learned to indent! Make sense to me
 - looks so much cleaner and less scrolling/printing.
   And, I already add a comment to confirm the end brace:

 } // end if($myVar)

 to clarify any long nests.

The fact that you feel the need to do that is a giveaway.

--
Cheers  --  Tim

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

Re: Re: [PHP] Code should be selv-maintaining!

2011-09-01 Thread Tim Streater
On 01 Sep 2011 at 11:42, Richard Quadling rquadl...@gmail.com wrote: 

 On 30 August 2011 23:25, Richard Quadling rquadl...@gmail.com wrote:
 On 30 August 2011 20:09, Robert Cummings rob...@interjinn.com wrote:
 You're just saying that so Tedd will be your friend!! Come now, let's be
 honest with everyone... Whitesmith's is -GLEE! ;)

 Beauty is in the eye of the beholder.

 So I think we've all established that Whitesmith's is the way to go,

I've been using the Whitesmith's style since I started coding in BCPL in the 
mid-70s. Having the braces line up is a big help.


--
Cheers  --  Tim

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

Re: [PHP] Opening Multiple Files

2011-09-07 Thread Tim Streater
On 07 Sep 2011 at 15:21, Ron Piggott ron.pigg...@actsministries.org wrote: 

 Hi Everyone

 I am trying to load an HTML book into mySQL.  The book was distributed with
 each chapter being it’s own HTML file.

 The only way I know how to open a file is by specifying the file name.  Such
 as:

 $myFile = B01C001.htm;
 $lines = file($myFile);
 foreach ($lines as $line_num = $theData) {

 Is there a way PHP will open each file in the directory ending in “.htm”,
 one file at a time, without me specifying the file name?

You can use opendir() and readdir() to get the filenames one by one.

--
Cheers  --  Tim

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

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 12:40, Richard Quadling rquadl...@gmail.com wrote: 

 On 14 September 2011 01:23, tamouse mailing lists
 tamouse.li...@gmail.com wrote:
 On Tue, Sep 13, 2011 at 3:35 PM, Robert Cummings rob...@interjinn.com
 wrote:
 I'm a big fan of editors that work in the terminal.

 You'll get my emacs when you pry it out of my cold dead hands.

 Pah! You and your full screen editor.

 EDLIN is the way to go.

Is that more or less terse than TECO?

Back in 1989 when I was at SLAC, they were just getting into unix, and debates 
were raging about which editor to standardise on and teach people (emacs, vi, 
jove, etc). Because this wasn't settled, I started using notepad (and later, 
dxnotepad) and got on with coding. Six months later, the debates were still 
raging. I then had an epiphany: I'd been using notepad for six moths  got work 
done. It took me 5 minutes to find out how to use it. I didn't need teaching 
about it or to have a manual. So IMO, emacs, vi, and all their ilk belong in 
the dustbin of history.

--
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 pa...@quillandmouse.com 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

Re: Fwd: [PHP] Bug?

2011-09-15 Thread Tim Streater
On 15 Sep 2011 at 22:43, tamouse mailing lists tamouse.li...@gmail.com 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

[PHP] Search for string followed by whitespace

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

   $start = stripos ($body, a , $loc);

You'll note the space after the 'a'. But I really need to search in $body for 
'a' followed by any whitespace char, at least one, starting at the $loc'th 
character, and returning the location of the string in $start.

I had a look at the PCRE and POSIX regexp functions to no avail. Is there a 
slick way of doing this with one function call or should I just search for 'a' 
and brute-force check that the next char is ' ' or '\t' or '\n'?

Thanks,

--
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 rainma...@gmail.com 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

Re: [PHP] Input variable from form help request

2011-09-29 Thread Tim Streater
On 29 Sep 2011 at 13:30, PHProg php...@speedemessenger.com 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]

 ?php
 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:

?php
$_POST['trakname'] = abc;
// similar for the other two

$myvar = 
'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] Variable question

2011-10-01 Thread Tim Streater
On 01 Oct 2011 at 18:59, Ron Piggott ron@actsministries.org 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

[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: Re: [PHP] Re: Oi , Portas/ Hello, Ports

2011-10-10 Thread Tim Streater
On 10 Oct 2011 at 19:30, Ashley Sheridan a...@ashleysheridan.co.uk wrote: 

 Jim Giner jim.gi...@albanyhandball.com wrote:


 QI.VOLMAR QI qi.vol...@gmail.com 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

Re: Re: [PHP] Multiple SQLite statements

2011-10-11 Thread Tim Streater
On 11 Oct 2011 at 03:03, Paul M Foster pa...@quillandmouse.com 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: Re: [PHP] Multiple SQLite statements

2011-10-11 Thread Tim Streater
On 11 Oct 2011 at 10:47, David Robley robl...@aapt.net.au wrote: 

 Tim Streater wrote:

 On 11 Oct 2011 at 03:03, Paul M Foster pa...@quillandmouse.com 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: Re: Re: [PHP] Multiple SQLite statements

2011-10-11 Thread Tim Streater
On 11 Oct 2011 at 11:25, David Robley robl...@aapt.net.au wrote: 

 Tim Streater wrote:

 On 11 Oct 2011 at 10:47, David Robley robl...@aapt.net.au wrote:

 Tim Streater wrote:

 On 11 Oct 2011 at 03:03, Paul M Foster pa...@quillandmouse.com 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: [PHP] Local variable protection

2011-10-13 Thread Tim Streater
On 13 Oct 2011 at 16:25, Tedd Sperling tedd.sperl...@gmail.com 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: [PHP] Local variable protection

2011-10-14 Thread Tim Streater
On 14 Oct 2011 at 16:46, Tedd Sperling tedd.sperl...@gmail.com wrote: 

 On Oct 13, 2011, at 11:37 AM, Tim Streater wrote:
 On 13 Oct 2011 at 16:25, Tedd Sperling tedd.sperl...@gmail.com 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] junk from my forms output

2011-10-19 Thread Tim Streater
On 19 Oct 2011 at 22:27, Simon J Welsh si...@welsh.co.nz 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).

 form action=action.php method=post
 pYour name: input type=text name=name //p
 pYour age: input type=text name=age //p
 pinput type=submit //p
 /form

 as well as the following in a file action.php, also in the same directory.

 Hi ?php echo htmlspecialchars($_POST['name']); ?.
 You are ?php echo (int)$_POST['age']; ? 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: [PHP] Friday Distraction

2011-10-21 Thread Tim Streater
On 21 Oct 2011 at 17:27, Daniel Brown danbr...@php.net 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 TsCs 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] Friday Distraction

2011-10-21 Thread Tim Streater
On 21 Oct 2011 at 21:30, Govinda govinda.webdnat...@gmail.com 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: Re: [PHP] Geo IP Location help needed...

2011-10-25 Thread Tim Streater
On 25 Oct 2011 at 02:36, DealTek deal...@gmail.com wrote: 

 On Oct 24, 2011, at 6:23 PM, Bastien wrote:

 On 2011-10-24, at 9:07 PM, DealTek deal...@gmail.com 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...

 ?php
 $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] Execute permission question

2011-10-28 Thread Tim Streater
On 28 Oct 2011 at 16:01, Tedd Sperling tedd.sperl...@gmail.com 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
   ?php

   echo Hello World!\n;

   ?

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: [PHP] What is an information_id in directory

2011-10-29 Thread Tim Streater
On 29 Oct 2011 at 20:46, Ernie Kemp ernie.k...@sympatico.ca 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] Safari and PDF

2011-11-15 Thread Tim Streater
On 15 Nov 2011 at 22:36, Ashley Sheridan a...@ashleysheridan.co.uk 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] Think I found a PHP bug

2011-11-15 Thread Tim Streater
On 15 Nov 2011 at 22:34, Geoff Shang ge...@quitelikely.com 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-16 Thread Tim Streater
On 16 Nov 2011 at 00:43, HallMarc Websites m...@hallmarcwebsites.com 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: RE: RE: [PHP] Safari and PDF

2011-11-16 Thread Tim Streater
On 16 Nov 2011 at 12:13, HallMarc Websites m...@hallmarcwebsites.com 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

[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: [PHP] {} forms

2011-11-16 Thread Tim Streater
On 16 Nov 2011 at 14:27, Richard Quadling rquadl...@gmail.com 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

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

2011-11-17 Thread Tim Streater
On 16 Nov 2011 at 16:30, Geoff Shang ge...@quitelikely.com 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

[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] Sniping on the List

2011-11-18 Thread Tim Streater
On 18 Nov 2011 at 05:40, Robert Cummings rob...@interjinn.com 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] 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:

?php
$fn = 'wiggy.php';
include $fn;
?

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] include

2011-11-20 Thread Tim Streater
On 20 Nov 2011 at 10:36, Tommy Pham tommy...@gmail.com 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

Re: Re: [PHP] include

2011-11-21 Thread Tim Streater
On 20 Nov 2011 at 23:46, Tamara Temple tamouse.li...@tamaratemple.com wrote: 

 Tim Streater t...@clothears.org.uk 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:

 ?php
 $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: [PHP] include

2011-11-21 Thread Tim Streater
On 21 Nov 2011 at 11:10, Tommy Pham tommy...@gmail.com wrote: 

 On Mon, Nov 21, 2011 at 2:56 AM, Tim Streater t...@clothears.org.uk 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

[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: Re: [PHP] Class instance pointers

2011-11-29 Thread Tim Streater
On 29 Nov 2011 at 17:01, cimodev cimo...@googlemail.com 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

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 rquadl...@gmail.com 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] 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 rewilli...@thesba.com wrote: 

 On 1/4/12 13:33, Tim Streater t...@clothears.org.uk 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: 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 rewilli...@thesba.com wrote: 

 On 1/4/12 14:34, Tim Streater t...@clothears.org.uk 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] passing variables to php script

2012-01-12 Thread Tim Streater
On 12 Jan 2012 at 18:51, David Savage dsav...@cytelcom.com 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: RE: [PHP] passing variables to php script

2012-01-13 Thread Tim Streater
On 13 Jan 2012 at 15:05, David Savage dsav...@cytelcom.com 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 servicesSo 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

[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

[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

Re: [PHP] Long Live GOTO

2012-02-06 Thread Tim Streater
On 06 Feb 2012 at 07:47, Adam Richardson simples...@gmail.com 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

Re: Re: [PHP] Long Live GOTO

2012-02-06 Thread Tim Streater
On 06 Feb 2012 at 15:05, Robert Cummings rob...@interjinn.com 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: Re: [PHP] Long Live GOTO

2012-02-06 Thread Tim Streater
On 06 Feb 2012 at 09:48, Adam Richardson simples...@gmail.com wrote: 

 On Mon, Feb 6, 2012 at 4:25 AM, Adam Richardson simples...@gmail.comwrote:

 On Mon, Feb 6, 2012 at 4:07 AM, Tim Streater t...@clothears.org.uk 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

[PHP] Re: Long Live GOTO

2012-02-06 Thread Tim Streater
On 06 Feb 2012 at 20:51, Simon J Welsh si...@welsh.co.nz 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

  1   2   >