[PHP] Re: newbie date time question

2011-06-22 Thread David Nicholls

On 23/06/11 10:04 AM, Shawn McKenzie wrote:

On 06/22/2011 06:54 PM, David Nicholls wrote:

I'm late to the party, but strtotime works great, though you need to
give it what it expects:

$ts = strtotime(str_replace('/', '-', $date));



Thanks, Shawn, that's a bit more elegant!  I'll give it a go. I didn't
know how to do the str_relace bit.  Thanks


The deal is that if you use the / then strtotime interprets it as m/d/y
and if you use - it interprets it as d-m-y.




Yes, I knew the '-' format would work, I just didn't know quite how to 
convert the '/' to '-'.  A very simple and clean solution.


The final form is:

function read_data($filename)
{
$f = fopen($filename, 'r');
while ($d = fgetcsv($f)) {
$ts = strtotime(str_replace('/','-',$d[0]));
$data[] = array($ts, $d[1]);
}
fclose($f);
return $data;
}

DN

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



Re: [PHP] help with an array if its possible!

2011-06-22 Thread Jim Lucas
On 6/22/2011 3:43 PM, Adam Preece wrote:
> Hi Gang!
> 
> i have 2 assoc arrays from 2 querys, 
> 
> first one is page categorys it consists of:
>   id
>   name
> 
> second is pages
>   name
>   cat_id
> 
> now, i am using smarty, so i pass arrays into the view. this i would like to 
> pass to the view and display within a html select element.
> 
>   
>   CAT NAME
>   PAGE NAME ASSOCIATED TO THE 
> CAT NAME
>   
>   
> 
> and i cannot think of how i can structure an array to pass in to achieve this 
> and/or is it even possible :-/.
> 
> i hope this makes sense.
> 
> i'm truly stuck!
> 
> kind regards
> 
> Adam Preece
>   

I see that you have a nested  tag.  Maybe you are looking for the
 tag.


  
Volvo
Saab
  
  
Mercedes
Audi
  


 1, 'name' => 'cars');
$categories[] = array('id' => 2, 'name' => 'trucks');
$categories[] = array('id' => 3, 'name' => 'motorcycles');

$pages[] = array('id' => 1, 'name' => 'Neon', 'cat_id' => 1);
$pages[] = array('id' => 2, 'name' => 'Saturn', 'cat_id' => 1);
$pages[] = array('id' => 3, 'name' => 'F150', 'cat_id' => 2);
$pages[] = array('id' => 4, 'name' => 'Ram 2500', 'cat_id' => 2);
$pages[] = array('id' => 5, 'name' => 'Suzuki', 'cat_id' => 2);
$pages[] = array('id' => 6, 'name' => 'Honda', 'cat_id' => 3);

echo "\n";

foreach ($categories AS $cat) {
  $c_cat_name = htmlspecialchars($cat['name']);
  echo "\t\n";

  foreach ($pages AS $page) {
if ( $page['cat_id'] == $cat['id'] ) {
  $c_page_id = htmlspecialchars((int)$page['id']);
  $c_page_name = htmlspecialchars($page['name']);
  echo "\t\t{$c_page_name}\n";
}
  }
  # Reset pages so you can loop through it again
  reset($pages);
  echo "\t\n";
}

echo "\n";
?>

All the above is untested, but should get you very close to what I think you are
trying to accomplish.

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



[PHP] Re: newbie date time question

2011-06-22 Thread Shawn McKenzie
On 06/22/2011 06:54 PM, David Nicholls wrote:
>> I'm late to the party, but strtotime works great, though you need to
>> give it what it expects:
>>
>> $ts = strtotime(str_replace('/', '-', $date));
>>
> 
> Thanks, Shawn, that's a bit more elegant!  I'll give it a go. I didn't
> know how to do the str_relace bit.  Thanks

The deal is that if you use the / then strtotime interprets it as m/d/y
and if you use - it interprets it as d-m-y.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] newbie date time question

2011-06-22 Thread David Nicholls

On 23/06/11 1:02 AM, Stuart Dallas wrote:


On Wednesday, 22 June 2011 at 15:59, David Nicholls wrote:


OK, looks like I have fixed problem, using:

  $format = 'd/m/Y g:i:s A';
  $dt = date_create_from_format($format, $d[0]);
  $dt2 = date('r', $dt->getTimestamp());
  $data[] = array(strtotime($dt2), $d[1]);

Not elegant but it gives me the date/time value.


$dt->getTimestamp() will give you the same value as strtotime($dt2), so you 
don't need the inelegance.

$format = 'd/m/Y g:i:s A';
$dt = date_create_from_format($format, $d[0]);
$data[] = array($dt->getTimestamp(), $d[1]);

-Stuart



Thanks, Stuart.  That's much prettier!

DN

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



[PHP] Re: newbie date time question

2011-06-22 Thread David Nicholls

On 23/06/11 1:35 AM, Shawn McKenzie wrote:

On 06/22/2011 09:05 AM, David Nicholls wrote:

I'm trying to convert a date and time string using strtotime()

The date and time strings are the first entry in each line in a csv file
in the form:

22/06/2011 9:47:20 PM, data1, data2,...

I've been trying to use the following approach, without success:

function read_data($filename)
{
 $f = fopen($filename, 'r');
 while ($d = fgetcsv($f)) {

 $format = 'd/m/Y h:i:s';
 $dt = DateTime::createFromFormat($format, $d[0]);

 $data[] = array(strtotime($dt), $d[1]); //convert date/time
 }
 fclose($f);
 return $data;
}

Obviously I'm not getting the $format line right, as the resulting $dt
values are empty.  (I have previously used this reading process
successfully with better behaved date and time strings).

Advice appreciated.

DN


I'm late to the party, but strtotime works great, though you need to
give it what it expects:

$ts = strtotime(str_replace('/', '-', $date));



Thanks, Shawn, that's a bit more elegant!  I'll give it a go. I didn't 
know how to do the str_relace bit.  Thanks


DN

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



Re: [PHP] help with an array if its possible!

2011-06-22 Thread Daniel P. Brown
On Wed, Jun 22, 2011 at 18:43, Adam Preece  wrote:
> Hi Gang!
>
> i have 2 assoc arrays from 2 querys,
>
> first one is page categorys it consists of:
>        id
>        name
>
> second is pages
>        name
>        cat_id
>
> now, i am using smarty, so i pass arrays into the view. this i would like to 
> pass to the view and display within a html select element.
>
>        
>                CAT NAME
>                        PAGE NAME ASSOCIATED TO 
> THE CAT NAME
>                
>        
>
> and i cannot think of how i can structure an array to pass in to achieve this 
> and/or is it even possible :-/.
>
> i hope this makes sense.
>
> i'm truly stuck!

If I'm understanding you correctly, this should get you started:

 'apples',
  'inventory_101' => 'oranges',
  'inventory_102' => 'pears',
  'inventory_103' => 'bananas',
);

echo ''.PHP_EOL;

foreach ($arr as $k => $v) {
  echo '  '.$v.''.PHP_EOL;
}

echo ''.PHP_EOL;
?>

You can copy and paste that code (though I just typed it in here,
it should work) and it should illustrate the point.

-- 

Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

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



[PHP] Re: this newsgroup and OE

2011-06-22 Thread Al

I've reported the issue Bugzilla two times, and others have also.

On 6/22/2011 11:27 AM, Shawn McKenzie wrote:

On 06/22/2011 09:45 AM, Jim Giner wrote:

Perhaps someone can tell me the secret to getting problem-free access to the
php newsgroups using OE.  I have two other newsgroup servers configured in
OE which do not give me any difficulties at all.  My setup for news.php.net
however gives me nothing but problems.  Inability to connect to messages,
long delays during normal polling for new items that hangs up my normal mail
traffic, etc.  Right now, OE indicates two new messages in the php.general
list, but I cannot download them at this time because OE says it cannot
connect (oops - just went to get the text of the message and now OE has been
able to connect).

Some of the details of my config:
server name: php.new.net
port #: 119
timeouts: 30 secs.

nothing else in particular set up - same as my other "working" newsgroup
accounts.

Thanks in advance.




No secret.  This has been happening to me every day for years using
Thunderbird.  It's a news server issue that has never been corrected.



I've reported the issue Bugzilla two times, and others have also. No response.

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



[PHP] help with an array if its possible!

2011-06-22 Thread Adam Preece
Hi Gang!

i have 2 assoc arrays from 2 querys, 

first one is page categorys it consists of:
id
name

second is pages
name
cat_id

now, i am using smarty, so i pass arrays into the view. this i would like to 
pass to the view and display within a html select element.


CAT NAME
PAGE NAME ASSOCIATED TO THE 
CAT NAME



and i cannot think of how i can structure an array to pass in to achieve this 
and/or is it even possible :-/.

i hope this makes sense.

i'm truly stuck!

kind regards

Adam Preece

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



Re: [PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Scott Baker
On 06/22/2011 03:17 PM, Simon J Welsh wrote:
> You still need to pass the value by reference to assign_children(), so:
> $new = &$leaf[$pid];
> assign_children($pid,$list,&$new);

One last thing I fixed was that PHP was complaining that run-time pass
by reference was deprecated. I changed assign_children to be

function assign_children($id,$list,&$leaf)

Which solved that also!

-- 
Scott Baker - Canby Telcom
System Administrator - RHCE - 503.266.8253

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



Re: [PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Scott Baker
On 06/22/2011 03:17 PM, Simon J Welsh wrote:
> You still need to pass the value by reference to assign_children(), so:
> $new = &$leaf[$pid];
> assign_children($pid,$list,&$new);

Aha... that was it! Thanks!

-- 
Scott Baker - Canby Telcom
System Administrator - RHCE - 503.266.8253

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



Re: [PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Simon J Welsh
On 23/06/2011, at 10:14 AM, Scott Baker wrote:

> On 06/22/2011 03:06 PM, Simon J Welsh wrote:
>> On further inspection, that's not the problem at all. The problem's around 
>> assign_children($pid,$list,&$new);
>> 
>> The previous line you defined $new with $new = $leaf[$pid], *copying* that 
>> node into $new. Thus the assign_children() call updates $new, but not 
>> $lead[$pid].
>> 
>> You can fix this by either assigning $new by reference ($new =& $leaf[$pid]) 
>> or by passing a reference to $lead[$pid] to assign_children instead of $new.
> 
> I updated the code:
> 
> http://www.perturb.org/tmp/tree.txt
> 
> I still get the same output though. Only one level of depth :(

You still need to pass the value by reference to assign_children(), so:
$new = &$leaf[$pid];
assign_children($pid,$list,&$new);
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Scott Baker
On 06/22/2011 03:06 PM, Simon J Welsh wrote:
> On further inspection, that's not the problem at all. The problem's around 
> assign_children($pid,$list,&$new);
> 
> The previous line you defined $new with $new = $leaf[$pid], *copying* that 
> node into $new. Thus the assign_children() call updates $new, but not 
> $lead[$pid].
> 
> You can fix this by either assigning $new by reference ($new =& $leaf[$pid]) 
> or by passing a reference to $lead[$pid] to assign_children instead of $new.

I updated the code:

http://www.perturb.org/tmp/tree.txt

I still get the same output though. Only one level of depth :(

-- 
Scott Baker - Canby Telcom
System Administrator - RHCE - 503.266.8253

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



[PHP] Re: URL Rewriting

2011-06-22 Thread Geoff Lane
On Wednesday, June 22, 2011, Daniel Brown wrote:

>> RewriteEngine on RewriteRule ^theme([0-9]+).php$
>>  /index.php?theme=$1 [L]

> That's neither nginx nor PHP, so it's not really relevant to the
> OP's questions.

I guess that the answer should be that you can rewrite outside of PHP
and then make use of the rewrites within your PHP application.
However, you can't AFAICT rewrite within PHP itself.

FWIW, I'm using mod-rewrite in one of my applications. In my .htaccess
file, I have:

8<---
RewriteEngine On
RewriteRule ^/$ master.php?url=index.html [L]
RewriteRule ^(.+\.html)$ master.php?url=$1 [QSA,L]
8<---

So that all .html files get rewritten to master.php with the
originally requested file on the querystring. In master.php, I then
have something like:

  $content = str_replace(".html", "", $_GET['url']) . ".php";
  require ('header.php');
  if (file_exists($content)){
include ($content);
  }
  require ('footer.php');

This lets me have all the common content in required files with the
content that is unique to each page defined separately and without
needing to embed the top-level page structure in each page. It also
gives me 'search-engine-friendly' URIs.

HTH,

-- 
Geoff


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



Re: [PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Simon J Welsh
On 23/06/2011, at 9:57 AM, Simon J Welsh wrote:

> On 23/06/2011, at 9:53 AM, Scott Baker wrote:
> 
>> I have a bunch of records in a DB that look like
>> 
>> id | parent_id
>> --
>> 1  | 4
>> 2  | 4
>> 3  | 2
>> 4  | 0
>> 5  | 2
>> 6  | 1
>> 7  | 3
>> 8  | 7
>> 9  | 7
>> 
>> I want to build a big has that looks like:
>> 
>> 4 -> 1 -> 6
>> -> 2 -> 3 -> 7 -> 9
>>  -> 5  -> 8
>> 
>> I'm like 90% of the way there, but I can't get my recursive assignment
>> to work. Has anyone done this before that could offer some pointers?
>> Here is my sample code thus far:
>> 
>> http://www.perturb.org/tmp/tree.txt
>> 
>> I can get one level of depth, but nothing more than that :(
> 
> I haven't looked that much into your code, but:
> $children = find_children($id,$list);
> 
> $list is never defined.

On further inspection, that's not the problem at all. The problem's around 
assign_children($pid,$list,&$new);

The previous line you defined $new with $new = $leaf[$pid], *copying* that node 
into $new. Thus the assign_children() call updates $new, but not $lead[$pid].

You can fix this by either assigning $new by reference ($new =& $leaf[$pid]) or 
by passing a reference to $lead[$pid] to assign_children instead of $new.

---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] URL Rewriting

2011-06-22 Thread Silvio Siefke
On Wed, 22 Jun 2011 23:32:10 +0200 Fatih P. wrote:
> try
> 
> RewriteEngine on
> RewriteRule ^theme([0-9]+).php$  /index.php?theme=$1 [L]

That is rule for Apache i think. I have nginx, and there i have try much
rules but nothing want work. And on the list from nginx the maintainer write,
i should use the power language php. 


Regards
Silvio

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



Re: [PHP] URL Rewriting

2011-06-22 Thread Silvio Siefke
On Wed, 22 Jun 2011 17:50:49 -0400 Daniel P. Brown wrote:
> > Has someone a Link with Tutorials or other Information?
> 
> Not entirely sure what you're asking here, or how you (or the
> nginx folks) expect it to relate to PHP.  Do you mean that you want to
> use PHP to have theme2.php act as if it was called as theme.php?id=2 ?

I have me write a blog, but my blog has link like blogdetail.html?id=1 or =2
through 16 at moment. And for google and other Search  Engines not good the
links, better where i can rewrite to a fix link, and when someone use the
link, php write to correct url. 

Sorry my english not perfect on earth. 

 
> If so, it's not redirect or rewrite, and it's extremely hacky, but
> this is the only real way PHP could achieve the desired result:
> 
>  // dynamictheme.php
> 
> if (preg_match('/.*([0-9]+)\.php/Ui',$_SERVER['PHP_SELF'],$match)) {
>   $_GET['id'] = $match[1];
>   include dirname(__FILE__).'/theme.php';
> }
> 
> ?>
> 
> Then just symlink dynamictheme.php to your various themes like so:
> 
> ln -s dynamictheme.php theme2.php
> ln -s dynamictheme.php theme301.php
> ln -s dynamictheme.php theme18447.php
> 


Regards 
Silvio

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



Re: [PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Simon J Welsh
On 23/06/2011, at 9:53 AM, Scott Baker wrote:

> I have a bunch of records in a DB that look like
> 
> id | parent_id
> --
> 1  | 4
> 2  | 4
> 3  | 2
> 4  | 0
> 5  | 2
> 6  | 1
> 7  | 3
> 8  | 7
> 9  | 7
> 
> I want to build a big has that looks like:
> 
> 4 -> 1 -> 6
>  -> 2 -> 3 -> 7 -> 9
>   -> 5  -> 8
> 
> I'm like 90% of the way there, but I can't get my recursive assignment
> to work. Has anyone done this before that could offer some pointers?
> Here is my sample code thus far:
> 
> http://www.perturb.org/tmp/tree.txt
> 
> I can get one level of depth, but nothing more than that :(

I haven't looked that much into your code, but:
$children = find_children($id,$list);

$list is never defined.
---
Simon Welsh
Admin of http://simon.geek.nz/


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



[PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Scott Baker
I have a bunch of records in a DB that look like

id | parent_id
--
1  | 4
2  | 4
3  | 2
4  | 0
5  | 2
6  | 1
7  | 3
8  | 7
9  | 7

I want to build a big has that looks like:

4 -> 1 -> 6
  -> 2 -> 3 -> 7 -> 9
   -> 5  -> 8

I'm like 90% of the way there, but I can't get my recursive assignment
to work. Has anyone done this before that could offer some pointers?
Here is my sample code thus far:

http://www.perturb.org/tmp/tree.txt

I can get one level of depth, but nothing more than that :(

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



Re: [PHP] URL Rewriting

2011-06-22 Thread Daniel P. Brown
On Wed, Jun 22, 2011 at 17:22, Silvio Siefke  wrote:
> Hello,
>
> is there a chance with php to use rewriting?
>
> Like Example:
>
> mysite.com/theme.php?id=1 to theme.php theme2.php etc.
>
> I have ask on the nginx list, but there they say i should use the power
> language php.
>
> When i search in google for Examples or Tutorials i only found mod_rewriting.
>
>
> Has someone a Link with Tutorials or other Information?

Not entirely sure what you're asking here, or how you (or the
nginx folks) expect it to relate to PHP.  Do you mean that you want to
use PHP to have theme2.php act as if it was called as theme.php?id=2 ?

If so, it's not redirect or rewrite, and it's extremely hacky, but
this is the only real way PHP could achieve the desired result:



Then just symlink dynamictheme.php to your various themes like so:

ln -s dynamictheme.php theme2.php
ln -s dynamictheme.php theme301.php
ln -s dynamictheme.php theme18447.php

-- 

Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

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



Re: [PHP] URL Rewriting

2011-06-22 Thread Daniel Brown
On Wed, Jun 22, 2011 at 17:32, Fatih P.  wrote:
> try
>
> RewriteEngine on
> RewriteRule ^theme([0-9]+).php$  /index.php?theme=$1 [L]

That's neither nginx nor PHP, so it's not really relevant to the
OP's questions.

-- 

Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] URL Rewriting

2011-06-22 Thread Fatih P.
try

RewriteEngine on
RewriteRule ^theme([0-9]+).php$  /index.php?theme=$1 [L]






On Wed, Jun 22, 2011 at 11:22 PM, Silvio Siefke wrote:

> Hello,
>
> is there a chance with php to use rewriting?
>
> Like Example:
>
> mysite.com/theme.php?id=1 to theme.php theme2.php etc.
>
> I have ask on the nginx list, but there they say i should use the power
> language php.
>
> When i search in google for Examples or Tutorials i only found
> mod_rewriting.
>
>
> Has someone a Link with Tutorials or other Information?
>
> Thank you.
>
> Nice Day.
>
> Silvio
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] URL Rewriting

2011-06-22 Thread Silvio Siefke
Hello, 

is there a chance with php to use rewriting?

Like Example:

mysite.com/theme.php?id=1 to theme.php theme2.php etc. 

I have ask on the nginx list, but there they say i should use the power
language php. 

When i search in google for Examples or Tutorials i only found mod_rewriting. 


Has someone a Link with Tutorials or other Information?

Thank you.

Nice Day.

Silvio

-- 
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  wrote: 

> At 04:30 PM 6/22/2011, you wrote:
>> On 22 Jun 2011 at 20:56, Jim Lucas  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: Re: [PHP] jQuery to PHP

2011-06-22 Thread Tim Streater
On 22 Jun 2011 at 20:56, Jim Lucas  wrote: 

> On 22/6/2011 12:43 PM, Tim Streater wrote:
>> On 22 Jun 2011 at 19:44, Ethan Rosenberg  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: [PHP] jQuery to PHP

2011-06-22 Thread Jim Lucas
On 6/22/2011 12:43 PM, Tim Streater wrote:
> On 22 Jun 2011 at 19:44, Ethan Rosenberg  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
> 
> 

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

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



Re: [PHP] Updating to 5.3.6

2011-06-22 Thread Sean Greenslade
All I can suggest is either compile from source or find a different mac
binary. I don't often deal with macs, much less try to use them as servers,
so that's the best I can offer. Good luck.
On Jun 20, 2011 1:53 PM, "Bruno Coelho"  wrote:


Re: [PHP] jQuery to PHP

2011-06-22 Thread Tim Streater
On 22 Jun 2011 at 19:44, Ethan Rosenberg  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

[PHP] Re: this newsgroup and OE

2011-06-22 Thread Jim Giner

Well - it's a secret until one asks I guess.  Thanks Shawn for the info.
Since you say it's been happening for years, I guess there's no hope for
resolution.

Can  you or someone else recommend a newsgroup client that functions better
with this group?

BTw - this is my second attempt to respond to you - the first hung in my 
outbox for 5 minutes. 



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



[PHP] Re: newbie date time question

2011-06-22 Thread Shawn McKenzie
On 06/22/2011 09:05 AM, David Nicholls wrote:
> I'm trying to convert a date and time string using strtotime()
> 
> The date and time strings are the first entry in each line in a csv file
> in the form:
> 
> 22/06/2011 9:47:20 PM, data1, data2,...
> 
> I've been trying to use the following approach, without success:
> 
> function read_data($filename)
> {
> $f = fopen($filename, 'r');
> while ($d = fgetcsv($f)) {
> 
> $format = 'd/m/Y h:i:s';
> $dt = DateTime::createFromFormat($format, $d[0]);
> 
> $data[] = array(strtotime($dt), $d[1]); //convert date/time
> }
> fclose($f);
> return $data;
> }
> 
> Obviously I'm not getting the $format line right, as the resulting $dt
> values are empty.  (I have previously used this reading process
> successfully with better behaved date and time strings).
> 
> Advice appreciated.
> 
> DN

I'm late to the party, but strtotime works great, though you need to
give it what it expects:

$ts = strtotime(str_replace('/', '-', $date));

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] Re: this newsgroup and OE

2011-06-22 Thread Shawn McKenzie
On 06/22/2011 09:45 AM, Jim Giner wrote:
> Perhaps someone can tell me the secret to getting problem-free access to the 
> php newsgroups using OE.  I have two other newsgroup servers configured in 
> OE which do not give me any difficulties at all.  My setup for news.php.net 
> however gives me nothing but problems.  Inability to connect to messages, 
> long delays during normal polling for new items that hangs up my normal mail 
> traffic, etc.  Right now, OE indicates two new messages in the php.general 
> list, but I cannot download them at this time because OE says it cannot 
> connect (oops - just went to get the text of the message and now OE has been 
> able to connect).
> 
> Some of the details of my config:
> server name: php.new.net
> port #: 119
> timeouts: 30 secs.
> 
> nothing else in particular set up - same as my other "working" newsgroup 
> accounts.
> 
> Thanks in advance. 
> 
> 

No secret.  This has been happening to me every day for years using
Thunderbird.  It's a news server issue that has never been corrected.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] newbie date time question

2011-06-22 Thread Stuart Dallas

On Wednesday, 22 June 2011 at 15:59, David Nicholls wrote:

> OK, looks like I have fixed problem, using:
> 
>  $format = 'd/m/Y g:i:s A';
>  $dt = date_create_from_format($format, $d[0]);
>  $dt2 = date('r', $dt->getTimestamp());
>  $data[] = array(strtotime($dt2), $d[1]);
> 
> Not elegant but it gives me the date/time value.

$dt->getTimestamp() will give you the same value as strtotime($dt2), so you 
don't need the inelegance.

$format = 'd/m/Y g:i:s A';
$dt = date_create_from_format($format, $d[0]);
$data[] = array($dt->getTimestamp(), $d[1]);

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/


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



Re: [PHP] newbie date time question

2011-06-22 Thread David Nicholls

OK, looks like I have fixed problem, using:

$format = 'd/m/Y g:i:s A';
$dt = date_create_from_format($format, $d[0]);
$dt2 = date('r', $dt->getTimestamp());
$data[] = array(strtotime($dt2), $d[1]);

Not elegant but it gives me the date/time value.

Thanks, Adam and Richard

DN

On 23/06/11 12:51 AM, Adam Balogh wrote:

$dt is an object as the error says, so you cant echo it, becouse its not a
string (it can be with __toString magic method, or use print_r/var_dump to
output your object). Try the format (
http://www.php.net/manual/en/datetime.format.php) method on your $dt object.

On Wed, Jun 22, 2011 at 4:41 PM, David Nicholls  wrote:


On 23/06/11 12:23 AM, Adam Balogh wrote:


hi,

you have a PM(/AM) in your date ($d[0]), so put an "A" (Uppercase Ante
meridiem and Post meridiem) format char to your $format variable.

b3ha



Thanks, Adam.  Tried that and it's now throwing an error:

Catchable fatal error: Object of class DateTime could not be converted to
string in  on line 12

Line 12 follows the attempt at conversion

10  $format = 'd/m/Y h:i:s A';
11  $dt = DateTime::createFromFormat($**format, $d[0]);
12  echo $dt,"...";

DN





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



Re: [PHP] newbie date time question

2011-06-22 Thread Richard Quadling
On 22 June 2011 15:05, David Nicholls  wrote:
> I'm trying to convert a date and time string using strtotime()
>
> The date and time strings are the first entry in each line in a csv file in
> the form:
>
> 22/06/2011 9:47:20 PM, data1, data2,...
>
> I've been trying to use the following approach, without success:
>
> function read_data($filename)
> {
>    $f = fopen($filename, 'r');
>    while ($d = fgetcsv($f)) {
>
>        $format = 'd/m/Y h:i:s';
>        $dt = DateTime::createFromFormat($format, $d[0]);
>
>        $data[] = array(strtotime($dt), $d[1]); //convert date/time
>    }
>    fclose($f);
>    return $data;
> }
>
> Obviously I'm not getting the $format line right, as the resulting $dt
> values are empty.  (I have previously used this reading process successfully
> with better behaved date and time strings).
>
> Advice appreciated.
>
> DN

getTimestamp());
?>

outputs ...

Wed, 22 Jun 2011 21:47:20 +0100



-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

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



Re: [PHP] newbie date time question

2011-06-22 Thread Adam Balogh
$dt is an object as the error says, so you cant echo it, becouse its not a
string (it can be with __toString magic method, or use print_r/var_dump to
output your object). Try the format (
http://www.php.net/manual/en/datetime.format.php) method on your $dt object.

On Wed, Jun 22, 2011 at 4:41 PM, David Nicholls  wrote:

> On 23/06/11 12:23 AM, Adam Balogh wrote:
>
>> hi,
>>
>> you have a PM(/AM) in your date ($d[0]), so put an "A" (Uppercase Ante
>> meridiem and Post meridiem) format char to your $format variable.
>>
>> b3ha
>>
>
> Thanks, Adam.  Tried that and it's now throwing an error:
>
> Catchable fatal error: Object of class DateTime could not be converted to
> string in  on line 12
>
> Line 12 follows the attempt at conversion
>
> 10  $format = 'd/m/Y h:i:s A';
> 11  $dt = DateTime::createFromFormat($**format, $d[0]);
> 12  echo $dt,"...";
>
> DN


Re: [PHP] newbie date time question

2011-06-22 Thread David Nicholls

On 23/06/11 12:30 AM, Richard Quadling wrote:

On 22 June 2011 15:05, David Nicholls  wrote:

I'm trying to convert a date and time string using strtotime()

The date and time strings are the first entry in each line in a csv file in
the form:

22/06/2011 9:47:20 PM, data1, data2,...

I've been trying to use the following approach, without success:

function read_data($filename)
{
$f = fopen($filename, 'r');
while ($d = fgetcsv($f)) {

$format = 'd/m/Y h:i:s';
$dt = DateTime::createFromFormat($format, $d[0]);

$data[] = array(strtotime($dt), $d[1]); //convert date/time
}
fclose($f);
return $data;
}

Obviously I'm not getting the $format line right, as the resulting $dt
values are empty.  (I have previously used this reading process successfully
with better behaved date and time strings).

Advice appreciated.

DN


getTimestamp());
?>

outputs ...

Wed, 22 Jun 2011 21:47:20 +0100


Yes, partly works, but I'm now getting:

Wed, 22 Jun 2011 20:19:56 +1000
Warning: strtotime() expects parameter 1 to be string, object given in 
.php on line 12


in:

5  function read_data($filename)
6  {
7  $f = fopen($filename, 'r');
8  while ($d = fgetcsv($f)) {
9   $format = 'd/m/Y g:i:s A';
10  $dt = DateTime::createFromFormat($format, $d[0]);
11  echo date('r', $dt->getTimestamp());

12$data[] = array(strtotime($dt), $d[1]); //convert date/time

13}
14fclose($f);
15return $data;
15}

So $dt is apparently not a string?

DN

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



[PHP] this newsgroup and OE

2011-06-22 Thread Jim Giner
Perhaps someone can tell me the secret to getting problem-free access to the 
php newsgroups using OE.  I have two other newsgroup servers configured in 
OE which do not give me any difficulties at all.  My setup for news.php.net 
however gives me nothing but problems.  Inability to connect to messages, 
long delays during normal polling for new items that hangs up my normal mail 
traffic, etc.  Right now, OE indicates two new messages in the php.general 
list, but I cannot download them at this time because OE says it cannot 
connect (oops - just went to get the text of the message and now OE has been 
able to connect).

Some of the details of my config:
server name: php.new.net
port #: 119
timeouts: 30 secs.

nothing else in particular set up - same as my other "working" newsgroup 
accounts.

Thanks in advance. 



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



Re: [PHP] newbie date time question

2011-06-22 Thread David Nicholls

On 23/06/11 12:23 AM, Adam Balogh wrote:

hi,

you have a PM(/AM) in your date ($d[0]), so put an "A" (Uppercase Ante
meridiem and Post meridiem) format char to your $format variable.

b3ha


Thanks, Adam.  Tried that and it's now throwing an error:

Catchable fatal error: Object of class DateTime could not be converted 
to string in  on line 12


Line 12 follows the attempt at conversion

10  $format = 'd/m/Y h:i:s A';
11  $dt = DateTime::createFromFormat($format, $d[0]);
12  echo $dt,"...";

DN

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



[PHP] newbie date time question

2011-06-22 Thread David Nicholls

I'm trying to convert a date and time string using strtotime()

The date and time strings are the first entry in each line in a csv file 
in the form:


22/06/2011 9:47:20 PM, data1, data2,...

I've been trying to use the following approach, without success:

function read_data($filename)
{
$f = fopen($filename, 'r');
while ($d = fgetcsv($f)) {

$format = 'd/m/Y h:i:s';
$dt = DateTime::createFromFormat($format, $d[0]);

$data[] = array(strtotime($dt), $d[1]); //convert date/time
}
fclose($f);
return $data;
}

Obviously I'm not getting the $format line right, as the resulting $dt 
values are empty.  (I have previously used this reading process 
successfully with better behaved date and time strings).


Advice appreciated.

DN

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