Re: [PHP] Help with redeclare error

2011-10-27 Thread Ashley Sheridan
On Thu, 2011-10-27 at 17:40 -0700, UltraMega Admin wrote:

> On 10/27/2011 5:33 PM, Daniel Brown wrote:
> > On Thu, Oct 27, 2011 at 20:06, Jason Pruim  
> > wrote:
> >> Most likely you have in included in 2 files... Look into it from that 
> >> angle... It only needs to be included in 1 file to work throughout all the 
> >> files.
> >  Prune is spot-on.  That error generally happens when you include a
> > file that has already been included, which contains function
> > definitions.  Look at the code in the files the error mentions, on the
> > lines it specifies, and - most likely - you'll see an include.
> > Changing them to include_once instead will resolve the issue, as PHP
> > will just skip the order if it's already been done within the
> > execution of the code.
> >
> 
> A function with that name already exists in PHP as of 5.3.0. You'll have 
> to rename it or something.
> 
> http://us2.php.net/manual/en/function.date-diff.php
> 



Or wrap it inside a function_exists() call assuming that both your
function and the internal one do the same thing.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] array_unique by id multi-dimensional array

2011-10-27 Thread tamouse mailing lists
On Thu, Oct 27, 2011 at 10:31 AM, Tontonq Tontonq  wrote:
> i have an array like
>
>  [0] => Array
> (
> [likes] => 113091
>  [name] => blabla
>  [access_token] => AAABZCTx
> [id] => 188206217874932
>
> )
>
>  [1] => Array
> (
> [likes] => 113091
> [name] => blabla
> [access_token] =>   AAABZCTz
> [id] => 188206217874932
>   )
>
> i want to filter the array by [id] sub value?
>

Not quite sure what you mean by "filter" in this case, but the
function that pops to mind is
http://www.php.net/manual/en/function.array-filter.php, which applies
a callback function to each member of the array where you can
determine if it should be included in the filtered list by returning
true.

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



Re: [PHP] Help with redeclare error

2011-10-27 Thread UltraMega Admin

On 10/27/2011 5:33 PM, Daniel Brown wrote:

On Thu, Oct 27, 2011 at 20:06, Jason Pruim  wrote:

Most likely you have in included in 2 files... Look into it from that angle... 
It only needs to be included in 1 file to work throughout all the files.

 Prune is spot-on.  That error generally happens when you include a
file that has already been included, which contains function
definitions.  Look at the code in the files the error mentions, on the
lines it specifies, and - most likely - you'll see an include.
Changing them to include_once instead will resolve the issue, as PHP
will just skip the order if it's already been done within the
execution of the code.



A function with that name already exists in PHP as of 5.3.0. You'll have 
to rename it or something.


http://us2.php.net/manual/en/function.date-diff.php

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



Re: [PHP] OpenId Provider

2011-10-27 Thread Negin Nickparsa
I don't know about LDAP but Zend openID provider can be a good choice
http://framework.zend.com/manual/en/zend.openid.html

On 10/28/11, Roy Kaldung  wrote:
> Hi,
>
> Can anybody recommend a good OpenId Provider?
> I need one with LDAP integration if available.
>
> tia,
> Roy
>
> --
> Roy Kaldung
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



Re: [PHP] Help with redeclare error

2011-10-27 Thread Daniel Brown
On Thu, Oct 27, 2011 at 20:06, Jason Pruim  wrote:
>
> Most likely you have in included in 2 files... Look into it from that 
> angle... It only needs to be included in 1 file to work throughout all the 
> files.

Prune is spot-on.  That error generally happens when you include a
file that has already been included, which contains function
definitions.  Look at the code in the files the error mentions, on the
lines it specifies, and - most likely - you'll see an include.
Changing them to include_once instead will resolve the issue, as PHP
will just skip the order if it's already been done within the
execution of the code.

-- 

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] Help with redeclare error

2011-10-27 Thread Jason Pruim

Jason Pruim
li...@pruimphotography.com



On Oct 27, 2011, at 7:55 PM, Jack wrote:

> Hello All,
> 
> 
> 
> I have some code that just broke with a PHP upgrade, the error says:
> 
> PHP Fatal error:  Cannot redeclare date_diff() the line of the error is the
> close bracket of the function which is below.
> 
> Any ideas what's going on, I'm stuck?

Most likely you have in included in 2 files... Look into it from that angle... 
It only needs to be included in 1 file to work throughout all the files.



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



[PHP] Help with redeclare error

2011-10-27 Thread Jack
Hello All,

 

I have some code that just broke with a PHP upgrade, the error says:

PHP Fatal error:  Cannot redeclare date_diff() the line of the error is the
close bracket of the function which is below.

Any ideas what's going on, I'm stuck?

 

 

 

function date_diff($start_time, $stop_time) {

 $seconds   = strtotime($stop_time)-strtotime($start_time);

$days  = intval($seconds/86400);

$seconds  -= $days*86400;

$hours = sprintf("%02d",intval($seconds/3600));

$seconds  -= $hours*3600;   

 $minutes   = sprintf("%02d",intval($seconds/60));

$seconds  -= sprintf("%02d",$minutes*60);   

 

# $time_diff = "Days=>" . $days . "  Hours=>" . $hours . "  Minutes=>" .
$minutes . "  Seconds=>" . $seconds;

$time_diff = $hours . ":" . $minutes;

 return($time_diff); 

}

 

 

Everywhere I call the function it looks like this:

date_diff($fldstart_time,$fldstop_time);

 

 

 

 

Thanks!

Jack

 



Re: [PHP] Execute permission question

2011-10-27 Thread Daniel Brown
On Thu, Oct 27, 2011 at 19:44, Tedd Sperling  wrote:
>
> One of the things I'm trying to understand is a php script can execute a 
> shell command, right? Is there a way via permissions to prevent that -- or -- 
> does that even have anything to do with it? That's where I'm fuzzy.

Sure.  What PHP actually does is interface with a forked shell
(usually 'sh' by default) process, and the shell then has permission
controls and requirements of its own, defined by the operating
system's configuration.  So PHP isn't actually executing the commands,
per se, but is instead instructing the shell to do so itself.  To see
how to limit PHP's shell access, look into safe_mode and the like.

-- 

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

2011-10-27 Thread Tedd Sperling
On Oct 27, 2011, at 6:27 PM, Daniel Brown wrote:
> On Thu, Oct 27, 2011 at 18:15, Tedd Sperling  wrote:
>> That question begged the question of "What does execute mean?"
> 
>It means "execute."  Not to be confused with what others are
> mentioning here, which is "read and interpret."  If you run something
> through PHP, Perl, Python, or another parser/interpreter, it doesn't
> need to be executable by the user, only readable.
> 
>A caveat to this, of course, is that some scripts (such as those
> run via CGI) will usually need to be executable.  You may recall, back
> in the 90's, that any Perl scripts you'd upload to your cgi-bin needed
> to be chmod'd to 0755.
> 
> -- 
> 

One of the things I'm trying to understand is a php script can execute a shell 
command, right? Is there a way via permissions to prevent that -- or -- does 
that even have anything to do with it? That's where I'm fuzzy.

Cheers,

tedd

_
t...@sperling.com
http://sperling.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Execute permission question

2011-10-27 Thread Tedd Sperling
On Oct 27, 2011, at 6:27 PM, Daniel Brown wrote:

> On Thu, Oct 27, 2011 at 18:15, Tedd Sperling  wrote:
>> 
>> Ash:
>> 
>> You answered a question I wasn't prepared to ask, which was "How can php 
>> scripts be executed when their execute permissions aren't set?"
>> 
>> That question begged the question of "What does execute mean?"
> 
>It means "execute."  Not to be confused with what others are
> mentioning here, which is "read and interpret."  If you run something
> through PHP, Perl, Python, or another parser/interpreter, it doesn't
> need to be executable by the user, only readable.
> 
>A caveat to this, of course, is that some scripts (such as those
> run via CGI) will usually need to be executable.  You may recall, back
> in the 90's, that any Perl scripts you'd upload to your cgi-bin needed
> to be chmod'd to 0755.
> 
> -- 
> 

Thanks for the wayback machine ride -- my memory cells have long expunged that 
data for more useless information.

Good point re comparison of "execute" vs "read and interpret" -- that will end 
up in the minds of students to ponder.

Thanks,

tedd

_
t...@sperling.com
http://sperling.com





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



Re: [PHP] Exporting large data from mysql to html using php

2011-10-27 Thread Jason Pruim

Jason Pruim
li...@pruimphotography.com



On Oct 27, 2011, at 4:08 PM, Nathan Nobbe wrote:

> On Mon, Oct 24, 2011 at 6:50 PM, Jason Pruim  
> wrote:
> Now that I've managed to list 3 separate programming languages and somewhat 
> tie it back into php here's the question...
> 
> I have about 89 million records in mysql... the initial load of the page 
> takes 2 to 3 minutes, I am using pagination, so I have LIMIT's on the SQL 
> query's... But they just aren't going fast enough...
> 
> What I would like to do, is pull the data out of MySQL and store it in the 
> HTML files, and then update the HTML files once a day/week/month... I can 
> figure most of it out... BUT... How do I automatically link to the individual 
> pages?
> 
> I have the site working when you pull it from MySQL... Just the load time 
> sucks... Any suggestions on where I can pull some more info from? :)
> 
> Thanks in advance!
> 
> dial in the db schema (think keys) and queries; then investigate a reverse 
> proxy like varnish to cache the generated html.
> 
> you'll be able to handle a couple thousand requests per second against the 
> proxy in no time.
> 
> might be worth pre-generating some of the pages if they are still really slow 
> after db optimization.

Would it make sense that COUNT()'ing 89 million records would kill the 
performance? Once that was gone... It worked perfectly! 




Re: [PHP] Exporting large data from mysql to html using php

2011-10-27 Thread Jason Pruim

Jason Pruim
li...@pruimphotography.com



On Oct 27, 2011, at 2:44 PM, Tommy Pham wrote:

> On Wed, Oct 26, 2011 at 5:47 PM, Jason Pruim  
> wrote:
> 
> Jason Pruim
> li...@pruimphotography.com
> 
> The server that's running it is a home computer with a VPS installed... It's 
> not my dev environment :)
> 
> 
> Home computer used for a production environment?  Wow.. I'm speechless.

Ummm... No... Home computer for a dev environment... The final product will be 
moved to a better host. This is temporary... And actually isn't a bad idea... 
If you get it running good on a cheap home computer, why wouldn't it run 
*BETTER* on the high-end production server?

>  
> The information being searched is specifically phone numbers, and the bosses 
> want to provide the public away to browse them, hence the pagination... Once 
> I removed a COUNT from mysql it started working alot better... So I still 
> need to provide a better pagination system, but it's working.
> 
> 
> If just showing phone numbers only and no other information, what's the point 
> since there are already several other white and yellow pages on the net?  
> There's even a reverse number look-up too.  There's also a well known paid 
> service for getting a DB of contacts (name, address, phone numbers of persons 
> and businesses).  Just out of curiosity, what is it that your boss intend to 
> offer that would stand out for already existing services?  I doubt anyone 
> would be sane enough to sit there and just browse through phone numbers only. 
>  Even if it does show the owner's name of the registered number, I highly 
> doubt anyone sane would browse unless you provide some kind of filter/search.

I'm not expecting people to look at every single page... But I need away to 
allow curious people the ability to page through results if they want. 
>  
> Oh, and the 89 million is just for one state :) We are talking the 
> possibility of I believe 10 billion numbers to cover the US, not to mention 
> Canada which I believe uses the same numbering system as we do so that could 
> be another 10 billion...
> 
> >
> > As I've mentioned, something of this magnitude is better to leave it to the
> > DBA and work together with that DBA.  Either hire/contract one or become one
> > :)
> 
> I'm working on becoming one ontop of web designer and programmer :)
> 
> Good luck, that's a LOT of reading.  I'd estimate that's about 3k+ pages of 
> reading. :)

I've always been a fan of reading :) Just wish I had more time to do it! :)




Re: [PHP] Execute permission question

2011-10-27 Thread Daniel Brown
On Thu, Oct 27, 2011 at 18:15, Tedd Sperling  wrote:
>
> Ash:
>
> You answered a question I wasn't prepared to ask, which was "How can php 
> scripts be executed when their execute permissions aren't set?"
>
> That question begged the question of "What does execute mean?"

It means "execute."  Not to be confused with what others are
mentioning here, which is "read and interpret."  If you run something
through PHP, Perl, Python, or another parser/interpreter, it doesn't
need to be executable by the user, only readable.

A caveat to this, of course, is that some scripts (such as those
run via CGI) will usually need to be executable.  You may recall, back
in the 90's, that any Perl scripts you'd upload to your cgi-bin needed
to be chmod'd to 0755.

-- 

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

2011-10-27 Thread Tedd Sperling
On Oct 27, 2011, at 4:51 PM, Ashley Sheridan wrote:
> Yes, I just ran a quick test PHP script without any execute permissions set 
> at all, only rw-rw-r-- and it ran just fine, suggesting it is just an 
> argument as Larry said.
> 
> I don't think Apache needs execute permissions set on PHP files or pages 
> either, only read rights.
> 
> -- 
> Thanks,
> Ash

Ash:

You answered a question I wasn't prepared to ask, which was "How can php 
scripts be executed when their execute permissions aren't set?"

That question begged the question of "What does execute mean?"

I find the topic of permissions complicated when they can be overridden 
elsewhere.

Thanks,

tedd

_
t...@sperling.com
http://sperling.com






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



Re: [PHP] Question reading a file

2011-10-27 Thread Tedd Sperling
On Oct 27, 2011, at 5:14 PM, Daniel Brown wrote:
> On Thu, Oct 27, 2011 at 15:25, Tedd Sperling  wrote:
>> -snip my confusion -
> 
>No need to review the code.  The first hunch I had proved correct.
> PHP opens with a less-than (left carat, or 'less-than') symbol, as do
> HTML tags.  As a result, the browser interprets both as tags and tries
> to parse them.
> 
> -snip-
> 
> -- 
> 

Daniel:

But of course. I never considered that the "<" in both the HTML () and the PHP (http://sperling.com





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



Re: [PHP] Question reading a file

2011-10-27 Thread Daniel Brown
On Thu, Oct 27, 2011 at 15:25, Tedd Sperling  wrote:
> Hi gang:
>
> I have a few questions -- this is my first one.
>
> Please review this link:
>
> http://webbytedd.com//perms/
>
> This page simply reads the contents of a file of the user's choice and 
> displays the file's data.
>
> My first question is with regard to reading a file ( fread() ):
>
> If the user picks the PDF file, the [1] First 20 bytes are: %PDF...
> If the user picks a JPG file, the [1] First 20 bytes are:  ...JFFIF...
> If the user picks a GIF file, the [1] First 20 bytes are:  GIF89a...
>
> Of course, the above is just reading/echoing the header for each of those 
> files.
>
> Likewise, if the user picks a TXT or CSS file, then [1] First 20 bytes echoed 
> are the first 20 characters of the file.
>
> However, if the user picks a HTML or PHP file, there are no [1] First 20 
> bytes echoed.
>
> BUT, the ord() and chr() of the bytes ARE indeed collected and can be echoed 
> as shown in statements [2] and [3].
>
> So, my question is specifically "Why is the data gathered in the variable 
> $content not echoed for the HTML and PHP files, but is for all other files?"
>
> Please review the code shown.

No need to review the code.  The first hunch I had proved correct.
 PHP opens with a less-than (left carat, or 'less-than') symbol, as do
HTML tags.  As a result, the browser interprets both as tags and tries
to parse them.

Viewing the source of that page upon selection of the PHP or HTML
options displays the code as expected.

Resolution:  str_replace('<','<',str_replace('>','>',$data));

Technically, only the less-than symbols need to be replaced, but
you may as well - as Charley Jordan says - Keep It Clean.

-- 

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

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



[PHP] OpenId Provider

2011-10-27 Thread Roy Kaldung
Hi,

Can anybody recommend a good OpenId Provider?
I need one with LDAP integration if available.

tia,
Roy

-- 
Roy Kaldung



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



Re: [PHP] Question reading a file

2011-10-27 Thread Ashley Sheridan
On Thu, 2011-10-27 at 15:25 -0400, Tedd Sperling wrote:

> Hi gang:
> 
> I have a few questions -- this is my first one.
> 
> Please review this link:
> 
> http://webbytedd.com//perms/
> 
> This page simply reads the contents of a file of the user's choice and 
> displays the file's data.
> 
> My first question is with regard to reading a file ( fread() ):
> 
> If the user picks the PDF file, the [1] First 20 bytes are: %PDF... 
> If the user picks a JPG file, the [1] First 20 bytes are:  ...JFFIF... 
> If the user picks a GIF file, the [1] First 20 bytes are:  GIF89a... 
> 
> Of course, the above is just reading/echoing the header for each of those 
> files.
> 
> Likewise, if the user picks a TXT or CSS file, then [1] First 20 bytes echoed 
> are the first 20 characters of the file.
> 
> However, if the user picks a HTML or PHP file, there are no [1] First 20 
> bytes echoed.
> 
> BUT, the ord() and chr() of the bytes ARE indeed collected and can be echoed 
> as shown in statements [2] and [3].
> 
> So, my question is specifically "Why is the data gathered in the variable 
> $content not echoed for the HTML and PHP files, but is for all other files?" 
> 
> Please review the code shown.
> 
> Cheers,
> 
> tedd
> 
> _
> t...@sperling.com
> http://sperling.com
> 
> 
> 
> 
> 
> 


This might sound silly, but is it because it's being interpreted
somehow? I could understand the HTML going a little weird because of
this, not sure about the PHP, would depend what was trying to interpret
it...
-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Execute permission question

2011-10-27 Thread Ashley Sheridan
On Thu, 2011-10-27 at 14:41 -0600, Larry Martell wrote:

> On Thu, Oct 27, 2011 at 2:26 PM, Tedd Sperling  
> wrote:
> > Hi gang:
> >
> > Another question -- in the context of file permissions (rwx) is the execute 
> > permission limited to shell commands -- Or -- is there more?
> 
> Not sure I fully understand your question, but to execute anything
> directly - shell script, python script, perl script, binary program -
> you need the x bit set. I say directly because you could do: 'perl
> script' without script being executable (because in that case it's an
> argument to the perl executable).
> 
> 
> HTH,
> -larry
> 


Yes, I just ran a quick test PHP script without any execute permissions
set at all, only rw-rw-r-- and it ran just fine, suggesting it is just
an argument as Larry said.

I don't think Apache needs execute permissions set on PHP files or pages
either, only read rights.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Execute permission question

2011-10-27 Thread Larry Martell
On Thu, Oct 27, 2011 at 2:26 PM, Tedd Sperling  wrote:
> Hi gang:
>
> Another question -- in the context of file permissions (rwx) is the execute 
> permission limited to shell commands -- Or -- is there more?

Not sure I fully understand your question, but to execute anything
directly - shell script, python script, perl script, binary program -
you need the x bit set. I say directly because you could do: 'perl
script' without script being executable (because in that case it's an
argument to the perl executable).


HTH,
-larry

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



[PHP] Execute permission question

2011-10-27 Thread Tedd Sperling
Hi gang:

Another question -- in the context of file permissions (rwx) is the execute 
permission limited to shell commands -- Or -- is there more?

Cheers,

tedd

_
t...@sperling.com
http://sperling.com






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



[PHP] Question reading a file

2011-10-27 Thread Tedd Sperling
Hi gang:

I have a few questions -- this is my first one.

Please review this link:

http://webbytedd.com//perms/

This page simply reads the contents of a file of the user's choice and displays 
the file's data.

My first question is with regard to reading a file ( fread() ):

If the user picks the PDF file, the [1] First 20 bytes are: %PDF... 
If the user picks a JPG file, the [1] First 20 bytes are:  ...JFFIF... 
If the user picks a GIF file, the [1] First 20 bytes are:  GIF89a... 

Of course, the above is just reading/echoing the header for each of those files.

Likewise, if the user picks a TXT or CSS file, then [1] First 20 bytes echoed 
are the first 20 characters of the file.

However, if the user picks a HTML or PHP file, there are no [1] First 20 bytes 
echoed.

BUT, the ord() and chr() of the bytes ARE indeed collected and can be echoed as 
shown in statements [2] and [3].

So, my question is specifically "Why is the data gathered in the variable 
$content not echoed for the HTML and PHP files, but is for all other files?" 

Please review the code shown.

Cheers,

tedd

_
t...@sperling.com
http://sperling.com






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



Re: [PHP] Exporting large data from mysql to html using php

2011-10-27 Thread Jim Giner
>
> Good luck, that's a LOT of reading.  I'd estimate that's about 3k+ pages 
> of
> reading. :)
>
>
>> >
>> >
>> > Regards,
>> > Tommy
>>
>>
>

nice to see someone else is finally getting the point that I'm been making. 



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



Re: [PHP] Exporting large data from mysql to html using php

2011-10-27 Thread Nathan Nobbe
On Mon, Oct 24, 2011 at 6:50 PM, Jason Pruim wrote:

> Now that I've managed to list 3 separate programming languages and somewhat
> tie it back into php here's the question...
>
> I have about 89 million records in mysql... the initial load of the page
> takes 2 to 3 minutes, I am using pagination, so I have LIMIT's on the SQL
> query's... But they just aren't going fast enough...
>
> What I would like to do, is pull the data out of MySQL and store it in the
> HTML files, and then update the HTML files once a day/week/month... I can
> figure most of it out... BUT... How do I automatically link to the
> individual pages?
>
> I have the site working when you pull it from MySQL... Just the load time
> sucks... Any suggestions on where I can pull some more info from? :)
>
> Thanks in advance!
>

dial in the db schema (think keys) and queries; then investigate a reverse
proxy like varnish to cache the generated html.

you'll be able to handle a couple thousand requests per second against the
proxy in no time.

might be worth pre-generating some of the pages if they are still really
slow after db optimization.

-nathan


Re: [PHP] What is wrong with this preg_match?

2011-10-27 Thread Robert Williams
On 10/27/11 11:43, "Paul Halliday"  wrote:


>if ($argc == 1 || $argc > 2 || !preg_match("(\d{4}-\d{2}-\d{2})",
>
>Usage: ./process_patches.php 
>
>patches@innm2 ~/Code/Oculi $ ./process_patches.php 2011-01-011

The problem is that your expression basically defines a 'contains'-type
search, so it's matching the first 10 characters as required but then
simply ignoring that last, 11th character because there's no requirement
regarding it in the expression.

Try this instead:

^(\d{4}-\d{2}-\d{2})$

The ^ anchors the matching string to the beginning of the string, while
the $ anchors it to the end, which effectively forces the expression to
match the entire string, disallowing extra characters before or after it.


Regards,
Bob
--
Robert E. Williams, Jr.
Associate Vice President of Software Development
Newtek Businesss Services, Inc. -- The Small Business Authority
https://www.newtekreferrals.com/rewjr
http://www.thesba.com/







Notice: This communication, including attachments, may contain information that 
is confidential. It constitutes non-public information intended to be conveyed 
only to the designated recipient(s). If the reader or recipient of this 
communication is not the intended recipient, an employee or agent of the 
intended recipient who is responsible for delivering it to the intended 
recipient, or if you believe that you have received this communication in 
error, please notify the sender immediately by return e-mail and promptly 
delete this e-mail, including attachments without reading or saving them in any 
manner. The unauthorized use, dissemination, distribution, or reproduction of 
this e-mail, including attachments, is prohibited and may be unlawful. If you 
have received this email in error, please notify us immediately by e-mail or 
telephone and delete the e-mail and the attachments (if any).

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



RE: [PHP] What is wrong with this preg_match?

2011-10-27 Thread Steve Staples
-Original Message-
From: Paul Halliday [mailto:paul.halli...@gmail.com] 
Sent: Thursday, October 27, 2011 2:43 PM
To: PHP-General
Subject: [PHP] What is wrong with this preg_match?

I have the following:

if (isset($argc)) {
if ($argc == 1 || $argc > 2 || !preg_match("(\d{4}-\d{2}-\d{2})",
$argv[1])) {
echo "\nUsage: $argv[0] \n\n";
exit;
} else {
$base_date = $argv[1];
}
} else {
$base_date = date('Y-m-d');
}

When I run it:

 $ ./process_patches.php 201-01-01

Usage: ./process_patches.php 

patches@innm2 ~/Code/Oculi $ ./process_patches.php 2011-011-01

Usage: ./process_patches.php 

patches@innm2 ~/Code/Oculi $ ./process_patches.php 2011-01-011

Works..

What am I doing wrong?

Thanks!

--
Paul Halliday
http://www.squertproject.org/


Paul,

To me, it looks like you're just getting the next 2 digits, so 2011-01-011 is 
getting 2011-01-01 and truncating the last 1.

If you had used (I think)  "^(\d{4}-\d{2}-\d{2})$"  I think that would give you 
what you want... (but my reg-ex is horrible)

Steve

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



Re: [PHP] Exporting large data from mysql to html using php

2011-10-27 Thread Tommy Pham
On Wed, Oct 26, 2011 at 5:47 PM, Jason Pruim wrote:

>
> Jason Pruim
> li...@pruimphotography.com
>
> The server that's running it is a home computer with a VPS installed...
> It's not my dev environment :)
>
>
Home computer used for a production environment?  Wow.. I'm speechless.


> The information being searched is specifically phone numbers, and the
> bosses want to provide the public away to browse them, hence the
> pagination... Once I removed a COUNT from mysql it started working alot
> better... So I still need to provide a better pagination system, but it's
> working.
>
>
If just showing phone numbers only and no other information, what's the
point since there are already several other white and yellow pages on the
net?  There's even a reverse number look-up too.  There's also a well known
paid service for getting a DB of contacts (name, address, phone numbers of
persons and businesses).  Just out of curiosity, what is it that your boss
intend to offer that would stand out for already existing services?  I doubt
anyone would be sane enough to sit there and just browse through phone
numbers only.  Even if it does show the owner's name of the registered
number, I highly doubt anyone sane would browse unless you provide some kind
of filter/search.


> Oh, and the 89 million is just for one state :) We are talking the
> possibility of I believe 10 billion numbers to cover the US, not to mention
> Canada which I believe uses the same numbering system as we do so that could
> be another 10 billion...
>
> >
> > As I've mentioned, something of this magnitude is better to leave it to
> the
> > DBA and work together with that DBA.  Either hire/contract one or become
> one
> > :)
>
> I'm working on becoming one ontop of web designer and programmer :)
>

Good luck, that's a LOT of reading.  I'd estimate that's about 3k+ pages of
reading. :)


> >
> >
> > Regards,
> > Tommy
>
>


[PHP] What is wrong with this preg_match?

2011-10-27 Thread Paul Halliday
I have the following:

if (isset($argc)) {
if ($argc == 1 || $argc > 2 || !preg_match("(\d{4}-\d{2}-\d{2})",
$argv[1])) {
echo "\nUsage: $argv[0] \n\n";
exit;
} else {
$base_date = $argv[1];
}
} else {
$base_date = date('Y-m-d');
}

When I run it:

 $ ./process_patches.php 201-01-01

Usage: ./process_patches.php 

patches@innm2 ~/Code/Oculi $ ./process_patches.php 2011-011-01

Usage: ./process_patches.php 

patches@innm2 ~/Code/Oculi $ ./process_patches.php 2011-01-011

Works..

What am I doing wrong?

Thanks!

-- 
Paul Halliday
http://www.squertproject.org/

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



[PHP] Re: array_unique by id multi-dimensional array

2011-10-27 Thread Jim Giner
>
> i want to filter the array by [id] sub value?
>

The PHP manual is a source of infinite knowledge.  A simple entry of "array" 
in the "search for" field brings up just what you need.  Have at it! 



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



[PHP] array_unique by id multi-dimensional array

2011-10-27 Thread Tontonq Tontonq
i have an array like

  [0] => Array
(
[likes] => 113091
  [name] => blabla
  [access_token] => AAABZCTx
[id] => 188206217874932

)

  [1] => Array
(
[likes] => 113091
[name] => blabla
[access_token] =>   AAABZCTz
[id] => 188206217874932
   )

i want to filter the array by [id] sub value?


Re: [PHP] Friday Distraction

2011-10-27 Thread Richard Quadling
On 21 October 2011 17:27, Daniel Brown  wrote:
>    I'll get this week's Friday distraction kicked off here with
> something shared with me by a Facebook friend.  If you're on Facebook,
> try this.  It's pretty sweet (and safe for work and kids).
>
>        http://www.takethislollipop.com/

Sweet? SWEET!? What sort of sicko are you???

I've got a deranged nutter hunting me down.

He looks a LOT like you





Cool though.
-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc : Fantasy Shopper
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
fan.sh/6/370

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



Re: [PHP] Convert Hours to Decimal

2011-10-27 Thread Richard Quadling
On 17 October 2011 22:57, Don Wieland  wrote:
> select timediff(cast(out_1 as time), cast(in_1 as time)) tHours FROM
> lm_tc_trans WHERE tc_trans_id = '42'

Can you try ...

SELECT
CAST
(
TIMEDIFF
(
CAST(Out_1 AS Time),
CAST(In_1 AS Time)
)
AS Decimal(5,2)
) tHours
FROM
lm_tc_trans
WHERE
tc_trans_id = '42'

Basically, CAST the result back to a decimal(5,2)
-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc : Fantasy Shopper
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
fan.sh/6/370

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



Re: [PHP] Exporting large data from mysql to html using php

2011-10-27 Thread David Robley
Jim Giner wrote:

> "David Robley"  wrote in message
> news:49.50.34068.1b567...@pb1.pair.com...
>>
>> Consider running EXPLAIN on all your queries to see if there is something
>> Mysql thinks could be done to improve performance.
>>
> 
> Why do so many responders seem to think the problem here is in the
> preparation of the query?
> 
> It is the Approach that it is the problem.  It needs to re-addressed, not
> simply tinkered with.  I don't care if someone figures out how to spew out
> 89M+ records in 5 seconds flat.  What are you doing pulling up that many
> detail records at one time for? Who is going to look at them?  You?  If
> so, see my previous post on how long that is going to take you just to
> examine (!) the first million alone.
> 
> This problem needs a re-working of the data processing and user interfaces
> to allow for the selection of an appropriate amount of individual records
> in any result set, otherwise simply preparing a summary of some sort.

Jason originally said that he was using LIMIT to grab a subset of the data,
so I don't see why you would think he is trying to pull the full data set
in one hit. My response suggesting EXPLAIN was made in the knowledge that
he is using LIMIT.


Cheers
-- 
David Robley

"I was the first to climb Mount Everest," said Tom hilariously.
Today is Setting Orange, the 8th day of The Aftermath in the YOLD 3177. 


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



Re: [PHP] Exporting large data from mysql to html using php

2011-10-27 Thread Lester Caine

Jim Giner wrote:

Your boss wants to give access to phone numbers to the public in general?
Then what?

Glad mine's unlisted.


Is it?
Does it start 518248 ?
I often forget to get a phone number when a parcel has to go by carrier, and 
paypal does not include that info, but only rarely does one not come up on 
google ... even if in your case I had to check the cashed copy of the the result ;)


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

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