php-general Digest 31 Jul 2009 09:31:41 -0000 Issue 6259

2009-07-31 Thread php-general-digest-help

php-general Digest 31 Jul 2009 09:31:41 - Issue 6259

Topics (messages 296076 through 296096):

Re: regex - filtering out chinese utf8 characters
296076 by: Jim Lucas

Re: Asterisk anyone?
296077 by: Skip Evans
296085 by: Nathan Nobbe
296093 by: Per Jessen

Formatting plain text file
296078 by: Skip Evans
296079 by: Jim Lucas
296080 by: Skip Evans
296081 by: Robert Cummings
296088 by: b
296089 by: kranthi

This isn't infinitely recursive is it?
296082 by: Matt Neimeyer
296083 by: Jonathan Tapicer
296084 by: Ben Dunlap
296086 by: Ben Dunlap

Better Formatting Options?
296087 by: sono-io.fannullone.us
296096 by: Richard Heyes

Re: fileinfo returning wrong mime type for Excel files
296090 by: b

PHP 5.2.9 + NCurses
296091 by: Martin Scotta

Extract an element from XML
296092 by: Angelo Zanetti

Re: Ridiculous ..won't print or echo ...(RESOLVED)
296094 by: Ondr(ej S(ibr(ina
296095 by: Ondr(ej S(ibr(ina

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
Merlin Morgenstern wrote:
 Hi there,
 
 I am trying to filter out content that is not ascii. Can I do this with
 regex? For example:
 
 $regex = '[AZ][09]';
 if (preg_match($regex, $text)) {
 return TRUE;
 }
 else {
 return FALSE;
 }
 
 The reason I need to do this is that I am doing a mysql query with the
 text and I need to make sure it is not UTF8. Otherwise I do get
 following error:
 
 Error: Illegal mix of collations (latin1_swedish_ci,IMPLICIT)
 and (utf8_general_ci,COERCIBLE) for operation '='
 
 I am new to regex and would be happy for a jump start to get this fixed.
 
 Best regards, Merlin
 

You might want to read up on iconv.  I think it will do what you are
wanting to do.

http://us2.php.net/manual/en/book.iconv.php

specifically...

http://us2.php.net/manual/en/function.iconv.php

---End Message---
---BeginMessage---
I'm looking at this page now that shows working with the 
database through socket type stuff, but now the ball is in the 
client's court what they want to do. Not sure, so I'm just 
reading up.


http://www.voip-info.org/tiki-index.php?page=Web+based+Asterisk+Database+maintenance

But thanks all for the pointers. It has been helpful. I've 
looked up Trixbox, thanks.


Skip

--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut
---End Message---
---BeginMessage---
On Wed, Jul 29, 2009 at 1:18 PM, Skip Evans s...@bigskypenguin.com wrote:

 Hey,

 I've been asked to write a simple couple of public pages that would let an
 Asterisk customer modify their account configuration, but the client has no
 idea how Asterisk stores its data, apparently not in MySQL.

 Anyone know of any resources for accessing Asterisk from PHP?

 If anyone has done this can you tell me if I'm on the right track here?

 http://www.voip-info.org/wiki/view/Asterisk+AGI+php#PHPTipsandExamples


this should get you off to a good start,

http://www.voip-info.org/wiki/view/Asterisk+CDR+csv+mysql+import

-nathan
---End Message---
---BeginMessage---
Nathan Nobbe wrote:

 On Wed, Jul 29, 2009 at 1:18 PM, Skip Evans s...@bigskypenguin.com
 wrote:
 
 Hey,

 I've been asked to write a simple couple of public pages that would
 let an Asterisk customer modify their account configuration, but the
 client has no idea how Asterisk stores its data, apparently not in
 MySQL.

 Anyone know of any resources for accessing Asterisk from PHP?

 If anyone has done this can you tell me if I'm on the right track
 here?


http://www.voip-info.org/wiki/view/Asterisk+AGI+php#PHPTipsandExamples
 
 
 this should get you off to a good start,
 
 http://www.voip-info.org/wiki/view/Asterisk+CDR+csv+mysql+import

Yes, the CDR is often recorded in a database, but it's write-only as far
as Asterisk is concerned.  It can be used for billing and such
afterwards, but then we're no longer in Asterisk territory.

/Per

-- 
Per Jessen, Zürich (17.8°C)

---End Message---
---BeginMessage---

Hey all,

Am I brain fading or what? I'm so used to formatting text in 
tables for HTML display I can't think of how to do it for a 
plain text file.


I just need to create a columned table of names and addresses 
type stuff... sprintf?

--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

[PHP] Extract an element from XML

2009-07-31 Thread Angelo Zanetti
Hi all, 

I have the following segment of XML:

BookingReference ReferenceSource=api165432 /BookingReference

Now I want to get the value of the BookingReference where the
ReferenceSource = api. In other words I want to get the value 165432.

I have the following code: 

$ItemConfirmationReference2 = $xpath-query('BookingReference
ReferenceSource' , $Element);

$ItemConfirmationReference =
trim($ItemConfirmationReference2-item(0)-textContent);

The $Element variable passes the node that contains the BookingReference
node.

The tricky part for me is the =api part.

Thanks in advance.

A


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



Re: [PHP] Asterisk anyone?

2009-07-31 Thread Per Jessen
Nathan Nobbe wrote:

 On Wed, Jul 29, 2009 at 1:18 PM, Skip Evans s...@bigskypenguin.com
 wrote:
 
 Hey,

 I've been asked to write a simple couple of public pages that would
 let an Asterisk customer modify their account configuration, but the
 client has no idea how Asterisk stores its data, apparently not in
 MySQL.

 Anyone know of any resources for accessing Asterisk from PHP?

 If anyone has done this can you tell me if I'm on the right track
 here?


http://www.voip-info.org/wiki/view/Asterisk+AGI+php#PHPTipsandExamples
 
 
 this should get you off to a good start,
 
 http://www.voip-info.org/wiki/view/Asterisk+CDR+csv+mysql+import

Yes, the CDR is often recorded in a database, but it's write-only as far
as Asterisk is concerned.  It can be used for billing and such
afterwards, but then we're no longer in Asterisk territory.

/Per

-- 
Per Jessen, Zürich (17.8°C)


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



Re: [PHP] Ridiculous ..won't print or echo ...(RESOLVED)

2009-07-31 Thread ej S(ibr(ina on...@mojestopa.cz
Just testing message

Miller, Terion napsal(a):
 Yep I forgot about escaping the $
 
 
 
 On 7/29/09 10:51 AM, Ford, Mike m.f...@leedsmet.ac.uk wrote:
 
 -Original Message-
 From: Miller, Terion [mailto:tmil...@springfi.gannett.com]
 Sent: 29 July 2009 16:36

 Ok in my output to Quark I need to have $P printed to the page like
 this:

 @$p2118 S. Campbell Ave

 So in my php which is going to be grabbing this info and formatting
 it for
 the Quarkisn't echoing that $p all I get is the @

 I have tried several things:

 $p = $p

 $p = print($p)
 
 $p is trying to interpolate the value of the variable $p -- if you had full 
 error reporting turned on, you would see a nonexistent variable error. Once 
 more, there are several things you can do, of which the two most obvious are:
 
 * Use single quotes: echo '$p';
 
 * Use a backslash: echo \$p;
 
 
 Cheers!
 
 Mike
  --
 Mike Ford,
 Electronic Information Developer, Libraries and Learning Innovation,
 Leeds Metropolitan University, C507, Civic Quarter Campus,
 Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
 Email: m.f...@leedsmet.ac.uk
 Tel: +44 113 812 4730
 
 
 
 
 
 To view the terms under which this email is distributed, please go to 
 http://disclaimer.leedsmet.ac.uk/email.htm
 
 --
 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] Ridiculous ..won't print or echo ...(RESOLVED)

2009-07-31 Thread ej S(ibr(ina on...@mojestopa.cz
I'm sorry for this post. It's only testing. Thanks for understand.

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



Re: [PHP] Better Formatting Options?

2009-07-31 Thread Richard Heyes
Hi,

        I have many products per page and this code pulls the list price and
 formats it.  It works fine, but I'd like to know if I can shorten it.

Personally, I would advise against trying to cram as much as possible
into the least amount of space as possible, and instead going for
verbosity/readability. It will help when you come back to re-read it
in X months.

-- 
Richard Heyes
HTML5 graphing: RGraph - www.rgraph.net (updated 25th July)
Lots of PHP and Javascript code - http://www.phpguru.org

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



Re: [PHP] fileinfo returning wrong mime type for Excel files

2009-07-31 Thread Ashley Sheridan
On Thu, 2009-07-30 at 21:26 -0400, b wrote:
 On 07/30/2009 10:15 AM, Ashley Sheridan wrote:
  On Thu, 2009-07-30 at 07:12 -0700, Christoph Boget wrote:
  
  You could email it to me, which I presume is better if you replied
  back just to me and not the list?
 
  Just copying the list back on in this one now. I don't know of any
  places that you could upload a file to off the top of my head. Anyone
  have any links?
 
 
 Just google upload file; there are a bunch of sites that do this to 
 choose from.
 
 (I've never used any so I can't recommend one over the others)
 
 
If it helps any with testing, on my laptop (brand new Fedora 11 install)
a standard .xls file created with OOo3 is showing up as just 'test.xls:
application/vnd.ms-office; charset=binary' and not a specific Excel
sheet.



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


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



Re: [PHP] Extract an element from XML

2009-07-31 Thread Aschwin Wesselius

Angelo Zanetti wrote:
Hi all, 


I have the following segment of XML:

BookingReference ReferenceSource=api165432 /BookingReference

Now I want to get the value of the BookingReference where the
ReferenceSource = api. In other words I want to get the value 165432.

I have the following code: 


$ItemConfirmationReference2 = $xpath-query('BookingReference
ReferenceSource' , $Element);

$ItemConfirmationReference =
trim($ItemConfirmationReference2-item(0)-textContent);

The $Element variable passes the node that contains the BookingReference
node.

The tricky part for me is the =api part.

Thanks in advance.

A


  

Hi Angelo,

Probably it is something along the lines like:

$xpath-query('BookingReference/[...@referencesource=api]/');

Fairly simple and XPath is way powerful!

Kind regards,

Aschwin Wesselius

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



Re: [PHP] Extract an element from XML

2009-07-31 Thread Aschwin Wesselius

Aschwin Wesselius wrote:

Angelo Zanetti wrote:

Hi all,
I have the following segment of XML:

BookingReference ReferenceSource=api165432 /BookingReference

Now I want to get the value of the BookingReference where the
ReferenceSource = api. In other words I want to get the value 165432.

I have the following code:
$ItemConfirmationReference2 = $xpath-query('BookingReference
ReferenceSource' , $Element);

$ItemConfirmationReference =
trim($ItemConfirmationReference2-item(0)-textContent);

The $Element variable passes the node that contains the BookingReference
node.

The tricky part for me is the =api part.

Thanks in advance.

A


  

Hi Angelo,

Probably it is something along the lines like:

$xpath-query('BookingReference/[...@referencesource=api]/');

Fairly simple and XPath is way powerful!

Kind regards,

Aschwin Wesselius


Ah, sorry about that:

$xpath-query('bookingreferen...@referencesource=api]/');

There was a '/' after BookingReference.

Kind regards,

Aschwin Wesselius

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



[PHP] PHPBB Speed Issues

2009-07-31 Thread Ashley Sheridan
Hi Guys,

I know this is maybe a bit specific for the general list, but thought
I'd throw it out there anyway as I reckon a lot of you have had
experience with PHPBB at some point or another. We've got an existing
installation of the forum here, that's been active for a couple of years
and is fairly busy. The site itself is on a dedicated server, but we're
having some issues with the speed. Some pages are taking ≅7-8 seconds to
display.

I've optimised the images in the template, enabled the GZ compression,
and it's only improved the speed by a mere fraction. I have noticed that
the page itself doesn't display until after this delay, so I was
guessing that I could maybe force the buffer to flush at key intervals
to give the impression the pages are loading faster. Does anybody have
any insights into this?

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


Re: [PHP] PHPBB Speed Issues

2009-07-31 Thread Paul Scott
Ashley Sheridan wrote:
 I've optimised the images in the template, enabled the GZ compression,
 and it's only improved the speed by a mere fraction. I have noticed that
 the page itself doesn't display until after this delay, so I was
 guessing that I could maybe force the buffer to flush at key intervals
 to give the impression the pages are loading faster. Does anybody have
 any insights into this?

To bring things more on topic, why not rather have a discussion about
general scalability?

1. Cache as much as you can (everything)
2. Minimise HTTP requests
3. Use an opcode cache like APC
4. Use a RAM based cache system like memcacheD and give your db a breather
5. FINALLY, throw more hardware at it.

-- 
-- Paul

http://www.paulscott.za.net/
http://twitter.com/paulscott56
http://avoir.uwc.ac.za

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



Re: [PHP] PHPBB Speed Issues

2009-07-31 Thread David Otton
2009/7/31 Paul Scott psc...@uwc.ac.za:

-1. Measure everything. No point implementing a change that slows
things down. Implement low-hanging-fruit first (eg a CDN)
0. Optimise your existing setup before adding more layers
 1. Cache as much as you can (everything)
 2. Minimise HTTP requests
 3. Use an opcode cache like APC
 4. Use a RAM based cache system like memcacheD and give your db a breather
4a. Cache complete objects, not DB result sets
5. Don't tie up Apache processes with requests for static files
(lighttpd/CDN/both)
 6. FINALLY, throw more hardware at it.

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



Re: [PHP] Freeing Memory

2009-07-31 Thread Nisse Engström
On Thu, 30 Jul 2009 10:42:26 -0400, Dan Shirah wrote:

 I don't know what version of SQL you are using, but I have found that using:
 
 mysql_free_result($result);
 mssql_free_result($result);
 ifx_free_result($result);
 
 Helped my queries run much faster and use less resources. I had something
 similar to your script where I would read lines from a huge file and then
 insert the contents into my database.  Before adding the above the process
 would take 20-30 minutes.  After freeing the results after each insert my
 script completed in about 5-8 minutes.

How does that work considering that mysql_query() only
returns true or false on INSERT? I'd expect the script
to fail on $result not being a valid resource.


/Nisse

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



RE: [PHP] preg_match too greedy

2009-07-31 Thread Ford, Mike
 -Original Message-
 From: b [mailto:p...@logi.ca]
 Sent: 30 July 2009 03:17
 
 
 
  echo (preg_match($pattern, $test) != false)
 
  The  != false  here is redundant.
 
 Understood. But what you think is redundancy is, to me, clarity in
 programming. I happen to think that boolean tests shouldn't ride on
 whether or not an array returned from a function is empty or not (or
 a
 freaking boolean). If what I'm looking for is a false then that's
 what
 I'll test for.

Well, then, by that logic you should be testing separately for ===FALSE and 
===0, since the former means an error occurred, whilst the latter means the 
pattern was ok but didn't match.  If the pattern finds a match, the return 
value is 1 (not TRUE).


Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730


  


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] Freeing Memory

2009-07-31 Thread Dan Shirah

 How does that work considering that mysql_query() only
 returns true or false on INSERT? I'd expect the script
 to fail on $result not being a valid resource.


I don't know about mysql as I work with MSSQL Server and Informix, but for
me it works like this:

   $insert = ifx_prepare(INSERT INTO my_table
  VALUES ('0'), $connect_id);
   ifx_do($insert) or die (Query failed);
   ifx_free_result($insert);

By using PREPARE and DO to execute the queries it allows ifx_free_result to
release those resources.


[PHP] 2 ifs embedded?

2009-07-31 Thread Miller, Terion
I need this to say : If row notes is not empty and is alpha echo notes

How do I get the is alpha part in here;

If (!empty($row['notes'])) {


  echo( $trimNotes );

  }

I tried.

If (IsAlpha($row['notes'])) {


  echo( $trimNotes );

  }

But it broke the whole script.

--Terion


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



Re: [PHP] PHPBB Speed Issues

2009-07-31 Thread Ashley Sheridan
On Fri, 2009-07-31 at 11:27 +0100, David Otton wrote:
 2009/7/31 Paul Scott psc...@uwc.ac.za:
 
 -1. Measure everything. No point implementing a change that slows
 things down. Implement low-hanging-fruit first (eg a CDN)
 0. Optimise your existing setup before adding more layers
  1. Cache as much as you can (everything)
  2. Minimise HTTP requests
  3. Use an opcode cache like APC
  4. Use a RAM based cache system like memcacheD and give your db a breather
 4a. Cache complete objects, not DB result sets
 5. Don't tie up Apache processes with requests for static files
 (lighttpd/CDN/both)
  6. FINALLY, throw more hardware at it.
 

For those interested, I found the errant cause of the speed issue. Was a
query using a left join on 4 of the largest tables. Changed one query to
an inner join, and it's now smoking again!


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


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



Re: [PHP] 2 ifs embedded?

2009-07-31 Thread Ashley Sheridan
On Fri, 2009-07-31 at 06:53 -0700, Miller, Terion wrote:
 I need this to say : If row notes is not empty and is alpha echo notes
 
 How do I get the is alpha part in here;
 
 If (!empty($row['notes'])) {
 
 
   echo( $trimNotes );
 
   }
 
 I tried.
 
 If (IsAlpha($row['notes'])) {
 
 
   echo( $trimNotes );
 
   }
 
 But it broke the whole script.
 
 --Terion
 
 
I'm not really sure what you are trying to do here? Is it that you want
to have nested queries, or only do something if both conditions have
been met?

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


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



Re: [PHP] 2 ifs embedded?

2009-07-31 Thread m0s
Miller, Terion wrote:
 I need this to say : If row notes is not empty and is alpha echo notes

 How do I get the is alpha part in here;

 If (!empty($row['notes'])) {


   echo( $trimNotes );

   }

 I tried.

 If (IsAlpha($row['notes'])) {


   echo( $trimNotes );

   }

 But it broke the whole script.

 --Terion


   
You can write it in one IF statement

If (!empty($row['notes'])  IsAlpha($row['notes'])) {
   
}


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



[PHP] String to Date Conversion Problem

2009-07-31 Thread Alice Wei

Hi, Guys:

  I am trying to turn a prepared line into a date format, and the string looks 
something like this: 23 JUL 09  -  THURSDAY, and I am trying to change the 
string to a mm/dd/ format that looks like 07/23/2009. 

  I tried to use strtotime() but it gave me nothing. 
  Here is the code: 

list($date,$month,$year,$dash,$day) = split( ,$line,5);
echo date2 . strtotime($date . \s . $month . \s . $year). 
/date2;

  Could anyone on the list please give me a hint on what I might have done 
wrong here? 

Thanks for your help.

Alice










_
All-in-one security and maintenance for your PC.  Get a free 90-day trial!
http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail

Re: [PHP] Freeing Memory

2009-07-31 Thread Nisse Engström
On Fri, 31 Jul 2009 07:54:13 -0400, Dan Shirah wrote:


 How does that work considering that mysql_query() only
 returns true or false on INSERT? I'd expect the script
 to fail on $result not being a valid resource.

 
 I don't know about mysql as I work with MSSQL Server and Informix, but for
 me it works like this:
 
$insert = ifx_prepare(INSERT INTO my_table
   VALUES ('0'), $connect_id);
ifx_do($insert) or die (Query failed);
ifx_free_result($insert);
 
 By using PREPARE and DO to execute the queries it allows ifx_free_result to
 release those resources.

That explains it. (You'd have to use the MySQLi extension
to use prepared statements with MySQL, unless I'm confused).
Personally, I try to make it a point to free resources as
soon as possible.


/Nisse

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



Re: [PHP] 2 ifs embedded?

2009-07-31 Thread Miller, Terion



On 7/31/09 8:58 AM, m0s d...@lenss.nl wrote:

(!empty($row['notes'])  IsAlpha($row['notes']))

I tried that and this one:

If (!empty($row['notes'])  ctype_alpha($row['notes']))

It didn't display the notes at all...

And this one...doesn't display if the field has a 0 in it but I still need it 
to?

If (!empty($row['critical'])  ctype_alnum($row['critical']))

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



Re: [PHP] String to Date Conversion Problem

2009-07-31 Thread Stuart Connolly

Hi Alice,

Based on the string format that you mentioned (DD MMM YY - DAY) you  
should be able to transform to any other date using the following:


$parts = explode(' ', '23 JUL 09 - THURSDAY');

echo date('m/d/Y', strtotime({$parts[1]} {$parts[0]} {$parts[2]}));

Cheers

Stuart

On 31 Jul 2009, at 15:19, Alice Wei wrote:



Hi, Guys:

 I am trying to turn a prepared line into a date format, and the  
string looks something like this: 23 JUL 09  -  THURSDAY, and I am  
trying to change the string to a mm/dd/ format that looks like  
07/23/2009.


 I tried to use strtotime() but it gave me nothing.
 Here is the code:

   list($date,$month,$year,$dash,$day) = split( ,$line,5);
   echo date2 . strtotime($date . \s . $month . \s .  
$year). /date2;


 Could anyone on the list please give me a hint on what I might have  
done wrong here?


Thanks for your help.

Alice










_
All-in-one security and maintenance for your PC.  Get a free 90-day  
trial!

http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail




smime.p7s
Description: S/MIME cryptographic signature


Re: [PHP] 2 ifs embedded?

2009-07-31 Thread Bastien Koert
On Fri, Jul 31, 2009 at 10:28 AM, Miller,
Teriontmil...@springfi.gannett.com wrote:



 On 7/31/09 8:58 AM, m0s d...@lenss.nl wrote:

 (!empty($row['notes'])  IsAlpha($row['notes']))

 I tried that and this one:

 If (!empty($row['notes'])  ctype_alpha($row['notes']))

 It didn't display the notes at all...

 And this one...doesn't display if the field has a 0 in it but I still need it 
 to?

 If (!empty($row['critical'])  ctype_alnum($row['critical']))

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



Hey Teri,
Could the return from the db have a space or something in the value? Perhaps

If (!empty($row['critical'])  ctype_alnum((int)$row['critical']))

might work


-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] 2 ifs embedded?

2009-07-31 Thread Miller, Terion



On 7/31/09 9:53 AM, Bastien Koert phps...@gmail.com wrote:

On Fri, Jul 31, 2009 at 10:28 AM, Miller,
Teriontmil...@springfi.gannett.com wrote:



 On 7/31/09 8:58 AM, m0s d...@lenss.nl wrote:

 (!empty($row['notes'])  IsAlpha($row['notes']))

 I tried that and this one:

 If (!empty($row['notes'])  ctype_alpha($row['notes']))

 It didn't display the notes at all...

 And this one...doesn't display if the field has a 0 in it but I still need it 
 to?

 If (!empty($row['critical'])  ctype_alnum($row['critical']))

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



Hey Teri,
Could the return from the db have a space or something in the value? Perhaps

If (!empty($row['critical'])  ctype_alnum((int)$row['critical']))

might work


--

Bastien

Cat, the other other white meat


It's got me stumped, tried it and it still will not echo if the field has a 0 
in it:

If (!empty($row['critical'])  ctype_alnum((int)$row['critical'])){
echo( Critical violations found: . $row['critical'] .. );

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



[PHP] unsubscription not working

2009-07-31 Thread Luke
Trying to unsubscribe from the list, send the email and get this response:
'Acknowledgment: The address



   tinmach...@googlemail.com



was not on the php-general mailing list when I received your request and is
not a subscriber of this list.'


Where I'm sure that is the address I'm subscribed with.

-- 
Luke Slater
:O)

this text is protected by international copyright. it is illegal for
anybody apart from the recipient to keep a copy of this text.
dieser text wird von internationalem urheberrecht geschuetzt. allen
ausser dem/der empfaenger/-in ist untersagt, eine kopie dieses textes
zu behalten.


Re: [PHP] 2 ifs embedded?

2009-07-31 Thread Bastien Koert
On Fri, Jul 31, 2009 at 10:59 AM, Miller,
Teriontmil...@springfi.gannett.com wrote:



 On 7/31/09 9:53 AM, Bastien Koert phps...@gmail.com wrote:

 On Fri, Jul 31, 2009 at 10:28 AM, Miller,
 Teriontmil...@springfi.gannett.com wrote:



 On 7/31/09 8:58 AM, m0s d...@lenss.nl wrote:

 (!empty($row['notes'])  IsAlpha($row['notes']))

 I tried that and this one:

 If (!empty($row['notes'])  ctype_alpha($row['notes']))

 It didn't display the notes at all...

 And this one...doesn't display if the field has a 0 in it but I still need 
 it to?

 If (!empty($row['critical'])  ctype_alnum($row['critical']))

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



 Hey Teri,
 Could the return from the db have a space or something in the value? Perhaps

 If (!empty($row['critical'])  ctype_alnum((int)$row['critical']))

 might work


 --

 Bastien

 Cat, the other other white meat


 It's got me stumped, tried it and it still will not echo if the field has a 0 
 in it:

 If (!empty($row['critical'])  ctype_alnum((int)$row['critical'])){        
 echo( Critical violations found: . $row['critical'] .. );


If you echo it out what is the value?

echo [.$row['critical'].];

what do you get?

-- 

Bastien

Cat, the other other white meat

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



RE: [PHP] 2 ifs embedded?

2009-07-31 Thread Chrome
 On 7/31/09 9:53 AM, Bastien Koert phps...@gmail.com wrote:
 
 On Fri, Jul 31, 2009 at 10:28 AM, Miller,
 Teriontmil...@springfi.gannett.com wrote:
 
 
 
  On 7/31/09 8:58 AM, m0s d...@lenss.nl wrote:
 
  (!empty($row['notes'])  IsAlpha($row['notes']))
 
  I tried that and this one:
 
  If (!empty($row['notes'])  ctype_alpha($row['notes']))
 
  It didn't display the notes at all...
 
  And this one...doesn't display if the field has a 0 in it but I still
 need it to?
 
  If (!empty($row['critical'])  ctype_alnum($row['critical']))
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 Hey Teri,
 Could the return from the db have a space or something in the value?
 Perhaps
 
 If (!empty($row['critical'])  ctype_alnum((int)$row['critical']))
 
 might work
 
 
 --
 
 Bastien
 
 Cat, the other other white meat
 
 
 It's got me stumped, tried it and it still will not echo if the field
 has a 0 in it:
 
 If (!empty($row['critical'])  ctype_alnum((int)$row['critical'])){
 echo( Critical violations found: . $row['critical'] .. );
 

empty() regards 0 as an empty value... From the manual:

[quote]
The following things are considered to be empty:

*  (an empty string)
* 0 (0 as an integer)
* 0 (0 as a string)
* NULL
* FALSE
* array() (an empty array)
* var $var; (a variable declared, but without a value in a class)
[/quote]

HTH

Dan


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



RE: [PHP] String to Date Conversion Problem

2009-07-31 Thread Alice Wei

Looks like what I did by using mm/dd/ was extra, which was probably why it 
didn't work. 
Thanks, looks like this is up and running now. 

Alice



 CC: php-general@lists.php.net
 From: stu...@stuconnolly.com
 To: aj...@alumni.iu.edu
 Subject: Re: [PHP] String to Date Conversion Problem
 Date: Fri, 31 Jul 2009 15:45:44 +0100
 
 Hi Alice,
 
 Based on the string format that you mentioned (DD MMM YY - DAY) you  
 should be able to transform to any other date using the following:
 
 $parts = explode(' ', '23 JUL 09 - THURSDAY');
 
 echo date('m/d/Y', strtotime({$parts[1]} {$parts[0]} {$parts[2]}));
 
 Cheers
 
 Stuart
 
 On 31 Jul 2009, at 15:19, Alice Wei wrote:
 
 
  Hi, Guys:
 
   I am trying to turn a prepared line into a date format, and the  
  string looks something like this: 23 JUL 09  -  THURSDAY, and I am  
  trying to change the string to a mm/dd/ format that looks like  
  07/23/2009.
 
   I tried to use strtotime() but it gave me nothing.
   Here is the code:
 
 list($date,$month,$year,$dash,$day) = split( ,$line,5);
 echo date2 . strtotime($date . \s . $month . \s .  
  $year). /date2;
 
   Could anyone on the list please give me a hint on what I might have  
  done wrong here?
 
  Thanks for your help.
 
  Alice
 
 
 
 
 
 
 
 
 
 
  _
  All-in-one security and maintenance for your PC.  Get a free 90-day  
  trial!
  http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail
 

_
Express yourself with gadgets on Windows Live Spaces
http://discoverspaces.live.com?source=hmtag1loc=us

Re: [PHP] 2 ifs embedded?

2009-07-31 Thread Miller, Terion



On 7/31/09 10:14 AM, Bastien Koert phps...@gmail.com wrote:

On Fri, Jul 31, 2009 at 10:59 AM, Miller,
Teriontmil...@springfi.gannett.com wrote:



 On 7/31/09 9:53 AM, Bastien Koert phps...@gmail.com wrote:

 On Fri, Jul 31, 2009 at 10:28 AM, Miller,
 Teriontmil...@springfi.gannett.com wrote:



 On 7/31/09 8:58 AM, m0s d...@lenss.nl wrote:

 (!empty($row['notes'])  IsAlpha($row['notes']))

 I tried that and this one:

 If (!empty($row['notes'])  ctype_alpha($row['notes']))

 It didn't display the notes at all...

 And this one...doesn't display if the field has a 0 in it but I still need 
 it to?

 If (!empty($row['critical'])  ctype_alnum($row['critical']))

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



 Hey Teri,
 Could the return from the db have a space or something in the value? Perhaps

 If (!empty($row['critical'])  ctype_alnum((int)$row['critical']))

 might work


 --

 Bastien

 Cat, the other other white meat


 It's got me stumped, tried it and it still will not echo if the field has a 0 
 in it:

 If (!empty($row['critical'])  ctype_alnum((int)$row['critical'])){
 echo( Critical violations found: . $row['critical'] .. );


If you echo it out what is the value?

echo [.$row['critical'].];

what do you get?

--

Bastien

Cat, the other other white meat

If I echo it I get the int that is in the field from the db fine...so it's 
something with my statement?

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



[PHP] Re: This isn't infinitely recursive is it?

2009-07-31 Thread Matt Neimeyer
I like it... Thanks!

On Thu, Jul 30, 2009 at 8:04 PM, Ben Dunlapbdun...@agentintellect.com wrote:
 I don't THINK I need to worry about circular mappings... but I'm not
 sure how to check for it if I did...
 Would the following work? It avoids recursion entirely and also checks for
 circular mappings. You can plug in your own code where the comments are to do
 whatever is appropriate when a circular mapping is detected.

 function GetMappedField($Field)
 {
    $OriginalField = $Field;

    while (isset($FieldMap[$Field])) {
        $Field = $FieldMap[$Field];

        if ($Field === $OriginalField) {
            /*
             * circular mapping has been detected;
             * report an error or explode or whatever
             */
             break;
        }
    }

    return $Field;
 }


 Ben


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



Re: [PHP] 2 ifs embedded?

2009-07-31 Thread Jim Lucas
Miller, Terion wrote:
 
 
 On 7/31/09 10:14 AM, Bastien Koert phps...@gmail.com wrote:
 
 On Fri, Jul 31, 2009 at 10:59 AM, Miller,
 Teriontmil...@springfi.gannett.com wrote:


 On 7/31/09 9:53 AM, Bastien Koert phps...@gmail.com wrote:

 On Fri, Jul 31, 2009 at 10:28 AM, Miller,
 Teriontmil...@springfi.gannett.com wrote:


 On 7/31/09 8:58 AM, m0s d...@lenss.nl wrote:

 (!empty($row['notes'])  IsAlpha($row['notes']))

 I tried that and this one:

 If (!empty($row['notes'])  ctype_alpha($row['notes']))

 It didn't display the notes at all...

 And this one...doesn't display if the field has a 0 in it but I still need 
 it to?

 If (!empty($row['critical'])  ctype_alnum($row['critical']))

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


 Hey Teri,
 Could the return from the db have a space or something in the value? Perhaps

 If (!empty($row['critical'])  ctype_alnum((int)$row['critical']))

 might work


 --

 Bastien

 Cat, the other other white meat


 It's got me stumped, tried it and it still will not echo if the field has a 
 0 in it:

 If (!empty($row['critical'])  ctype_alnum((int)$row['critical'])){
 echo( Critical violations found: . $row['critical'] .. );

 
 If you echo it out what is the value?
 
 echo [.$row['critical'].];
 
 what do you get?
 
 --
 
 Bastien
 
 Cat, the other other white meat
 
 If I echo it I get the int that is in the field from the db fine...so it's 
 something with my statement?
 

That all depends on WHAT it is you are getting.

Can you tell us WHAT you are getting?  Not simply that I get the int
that is in the field from the db.  We don't have any idea what that
value is.  Only you know that...


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



Re: [PHP] 2 ifs embedded?

2009-07-31 Thread Miller, Terion



On 7/31/09 10:54 AM, Jim Lucas li...@cmsws.com wrote:

Miller, Terion wrote:


 On 7/31/09 10:14 AM, Bastien Koert phps...@gmail.com wrote:

 On Fri, Jul 31, 2009 at 10:59 AM, Miller,
 Teriontmil...@springfi.gannett.com wrote:


 On 7/31/09 9:53 AM, Bastien Koert phps...@gmail.com wrote:

 On Fri, Jul 31, 2009 at 10:28 AM, Miller,
 Teriontmil...@springfi.gannett.com wrote:


 On 7/31/09 8:58 AM, m0s d...@lenss.nl wrote:

 (!empty($row['notes'])  IsAlpha($row['notes']))

 I tried that and this one:

 If (!empty($row['notes'])  ctype_alpha($row['notes']))

 It didn't display the notes at all...

 And this one...doesn't display if the field has a 0 in it but I still need 
 it to?

 If (!empty($row['critical'])  ctype_alnum($row['critical']))

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


 Hey Teri,
 Could the return from the db have a space or something in the value? Perhaps

 If (!empty($row['critical'])  ctype_alnum((int)$row['critical']))

 might work


 --

 Bastien

 Cat, the other other white meat


 It's got me stumped, tried it and it still will not echo if the field has a 
 0 in it:

 If (!empty($row['critical'])  ctype_alnum((int)$row['critical'])){
 echo( Critical violations found: . $row['critical'] .. );


 If you echo it out what is the value?

 echo [.$row['critical'].];

 what do you get?

 --

 Bastien

 Cat, the other other white meat

 If I echo it I get the int that is in the field from the db fine...so it's 
 something with my statement?


That all depends on WHAT it is you are getting.

Can you tell us WHAT you are getting?  Not simply that I get the int
that is in the field from the db.  We don't have any idea what that
value is.  Only you know that...


Numbers are in that field ... So I'm getting 0, 1, 2 etc however many 
violations there are

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



Re: [PHP] 2 ifs embedded?

2009-07-31 Thread Miller, Terion



On 7/31/09 11:03 AM, Miller, Terion tmil...@springfi.gannett.com wrote:




On 7/31/09 10:54 AM, Jim Lucas li...@cmsws.com wrote:

Miller, Terion wrote:


 On 7/31/09 10:14 AM, Bastien Koert phps...@gmail.com wrote:

 On Fri, Jul 31, 2009 at 10:59 AM, Miller,
 Teriontmil...@springfi.gannett.com wrote:


 On 7/31/09 9:53 AM, Bastien Koert phps...@gmail.com wrote:

 On Fri, Jul 31, 2009 at 10:28 AM, Miller,
 Teriontmil...@springfi.gannett.com wrote:


 On 7/31/09 8:58 AM, m0s d...@lenss.nl wrote:

 (!empty($row['notes'])  IsAlpha($row['notes']))

 I tried that and this one:

 If (!empty($row['notes'])  ctype_alpha($row['notes']))

 It didn't display the notes at all...

 And this one...doesn't display if the field has a 0 in it but I still need 
 it to?

 If (!empty($row['critical'])  ctype_alnum($row['critical']))

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


 Hey Teri,
 Could the return from the db have a space or something in the value? Perhaps

 If (!empty($row['critical'])  ctype_alnum((int)$row['critical']))

 might work


 --

 Bastien

 Cat, the other other white meat


 It's got me stumped, tried it and it still will not echo if the field has a 
 0 in it:

 If (!empty($row['critical'])  ctype_alnum((int)$row['critical'])){
 echo( Critical violations found: . $row['critical'] .. );


 If you echo it out what is the value?

 echo [.$row['critical'].];

 what do you get?

 --

 Bastien

 Cat, the other other white meat

 If I echo it I get the int that is in the field from the db fine...so it's 
 something with my statement?


That all depends on WHAT it is you are getting.

Can you tell us WHAT you are getting?  Not simply that I get the int
that is in the field from the db.  We don't have any idea what that
value is.  Only you know that...


Numbers are in that field ... So I'm getting 0, 1, 2 etc however many 
violations there are, so why doesn't this work?

If (ctype_alnum((int)$row['critical'])){echo( Critical violations 
found: . $row['critical'] .. );

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



Re: [PHP] 2 ifs embedded? (RESOLVED)

2009-07-31 Thread Miller, Terion



On 7/31/09 10:54 AM, Jim Lucas li...@cmsws.com wrote:

Miller, Terion wrote:


 On 7/31/09 10:14 AM, Bastien Koert phps...@gmail.com wrote:

 On Fri, Jul 31, 2009 at 10:59 AM, Miller,
 Teriontmil...@springfi.gannett.com wrote:


 On 7/31/09 9:53 AM, Bastien Koert phps...@gmail.com wrote:

 On Fri, Jul 31, 2009 at 10:28 AM, Miller,
 Teriontmil...@springfi.gannett.com wrote:


 On 7/31/09 8:58 AM, m0s d...@lenss.nl wrote:

 (!empty($row['notes'])  IsAlpha($row['notes']))

 I tried that and this one:

 If (!empty($row['notes'])  ctype_alpha($row['notes']))

 It didn't display the notes at all...

 And this one...doesn't display if the field has a 0 in it but I still need 
 it to?

 If (!empty($row['critical'])  ctype_alnum($row['critical']))

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


 Hey Teri,
 Could the return from the db have a space or something in the value? Perhaps

 If (!empty($row['critical'])  ctype_alnum((int)$row['critical']))

 might work


 --

 Bastien

 Cat, the other other white meat


 It's got me stumped, tried it and it still will not echo if the field has a 
 0 in it:

 If (!empty($row['critical'])  ctype_alnum((int)$row['critical'])){
 echo( Critical violations found: . $row['critical'] .. );


 If you echo it out what is the value?

 echo [.$row['critical'].];

 what do you get?

 --

 Bastien

 Cat, the other other white meat

 If I echo it I get the int that is in the field from the db fine...so it's 
 something with my statement?


That all depends on WHAT it is you are getting.

Can you tell us WHAT you are getting?  Not simply that I get the int
that is in the field from the db.  We don't have any idea what that
value is.  Only you know that...


Got it..yay...

If (ctype_digit($row['critical'])){echo( Critical violations found: . 
$row['critical'] .. );

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



Re: [PHP] 2 ifs embedded?

2009-07-31 Thread Jim Lucas
Miller, Terion wrote:
 
 
 On 7/31/09 11:03 AM, Miller, Terion tmil...@springfi.gannett.com wrote:
 
 
 
 
 On 7/31/09 10:54 AM, Jim Lucas li...@cmsws.com wrote:
 
 Miller, Terion wrote:

 On 7/31/09 10:14 AM, Bastien Koert phps...@gmail.com wrote:

 On Fri, Jul 31, 2009 at 10:59 AM, Miller,
 Teriontmil...@springfi.gannett.com wrote:

 On 7/31/09 9:53 AM, Bastien Koert phps...@gmail.com wrote:

 On Fri, Jul 31, 2009 at 10:28 AM, Miller,
 Teriontmil...@springfi.gannett.com wrote:

 On 7/31/09 8:58 AM, m0s d...@lenss.nl wrote:

 (!empty($row['notes'])  IsAlpha($row['notes']))

 I tried that and this one:

 If (!empty($row['notes'])  ctype_alpha($row['notes']))

 It didn't display the notes at all...

 And this one...doesn't display if the field has a 0 in it but I still need 
 it to?

 If (!empty($row['critical'])  ctype_alnum($row['critical']))

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


 Hey Teri,
 Could the return from the db have a space or something in the value? Perhaps

 If (!empty($row['critical'])  ctype_alnum((int)$row['critical']))

 might work


 --

 Bastien

 Cat, the other other white meat


 It's got me stumped, tried it and it still will not echo if the field has a 
 0 in it:

 If (!empty($row['critical'])  ctype_alnum((int)$row['critical'])){
 echo( Critical violations found: . $row['critical'] .. );

 If you echo it out what is the value?

 echo [.$row['critical'].];

 what do you get?

 --

 Bastien

 Cat, the other other white meat

 If I echo it I get the int that is in the field from the db fine...so it's 
 something with my statement?

 
 That all depends on WHAT it is you are getting.
 
 Can you tell us WHAT you are getting?  Not simply that I get the int
 that is in the field from the db.  We don't have any idea what that
 value is.  Only you know that...
 
 
 Numbers are in that field ... So I'm getting 0, 1, 2 etc however many 
 violations there are, so why doesn't this work?
 
 If (ctype_alnum((int)$row['critical'])){echo( Critical violations 
 found: . $row['critical'] .. );
 

So, the only thing you will see is a number?  Correct?  What is the
range that the number will fall between?

And, does zero mean anything different then 1, 2, 3...

If, all you want to do is make sure that $row['critical'] is a number
and the value is within a range of numbers, so this.

if (
isset($row['critical']) 
is_numeric($row['critical']) 
in_array($row['critical'], range(0, 200))
} {
...
}


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



[PHP] ForEach Range Problems

2009-07-31 Thread Miller, Terion




I have this script that works, just a couple tweeks needed...

1. I don't want it to default to A being selected
2. I need the number range part to only display one # sign not 10 of them,
somehow I have to have it pull any record that does not start with alpha


   ?php
  $letter =
isset($_GET['letter']) ? $_GET['letter'] :A;
   
echo 'div
align=centerb';
   
foreach(range('A','Z') as $c){
  ($letter == $c)
?
printf('%snbsp',$c)
: printf('a
href=browse.php?letter=%s%s/anbsp;',$c,$c);
}
   
echo 'br';
//Other
   
   
foreach(range('0','9') as $n){
  ($letter == $n)
?
printf('%snbsp',$n)
: printf('a
href=?letter=%s#/anbsp;',$n,$n);
  }
   
echo
/bbr/divp;

  ?


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



[PHP] Namespace resolution performance implications

2009-07-31 Thread Andrew Mason
Hi Guys / Girls,
We are transitioning our framework to use the namespaces which are
available in php 5.3.

I found an explanation of the resolution rules here :
http://www.sitepoint.com/blogs/2009/07/14/php-namespaces-import-alias-resolution/
( also listed below)

and I was wondering what the performance implications of the different
stages of name resolution are. For example for the code in the
framework it's self would it be preferable to use a \Foo\Bar style
fully qualified class names in order for the resolution to be done at
compile time?

Thanks in advance
Andrew


1. Calls to fully-qualified functions, classes or constants are
resolved at compile-time.

2. Unqualified and qualified names are translated according to the
import rules, e.g. if the namespace A\B\C is imported as C, a call to
C\D\e() is translated to A\B\C\D\e().

3. Inside a namespace, all qualified names not already translated
according to import rules have the current namespace prepended, e.g.
if a call to C\D\e() is performed within namespace A\B, it is
translated to A\B\C\D\e().

4. Unqualified class names are translated according to current import
rules and the full name is substituted for short imported name, e.g.
if class C in namespace A\B is imported as X, new X() is translated to
new A\B\C().

5. Unqualified function calls within a namespace are resolved at
run-time. For example, if MyFunction() is called within namespace A\B,
PHP first looks for the function \A\B\MyFunction(). If that is not
found, it looks for \MyFunction() in the global space.

6. Calls to unqualified or qualified class names are resolved at
run-time. For example, if we call new C() within namespace A\B, PHP
will look for the class A\B\C. If that is not found, it will attempt
to autoload A\B\C.

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



[PHP] Regex Problem

2009-07-31 Thread Igor Escobar
Hi Folks,
I have a serious problem.

must create a regular expression against all that is between single quote or
double quotes. Easy? Ok, i know, but i need that everything must to be too
an single quote or double quote.

If i have this SQL command:

SELECT * FROM TSTRENIC.MEI_ACESSO WHERE UPPER(DS_MEI_ACS) LIKE *'%NOME' ASD
' AS'ASD'%' *AND USUARIO = *'oaksdpokasd'asda'* ORDER BY DS_MEI_ACS ASC;

SELECT * FROM TSTRENIC.MEI_ACESSO WHERE USUARIO_DATA BETWEEN *'2007-01-02'*AND
*'2008-07-08'*

Anyone have any idea?



I need an expression which case the fields in bold.


Regards,
Igor Escobar
Systems Analyst  Interface Designer

+ http://blog.igorescobar.com
+ http://www.igorescobar.com
+ @igorescobar (twitter)


Re: [PHP] ForEach Range Problems

2009-07-31 Thread Bastien Koert
On Fri, Jul 31, 2009 at 12:53 PM, Miller,
Teriontmil...@springfi.gannett.com wrote:




 I have this script that works, just a couple tweeks needed...

 1. I don't want it to default to A being selected
 2. I need the number range part to only display one # sign not 10 of them,
 somehow I have to have it pull any record that does not start with alpha


   ?php
                                                          $letter =
 isset($_GET['letter']) ? $_GET['letter'] :A;

                                                        echo 'div
 align=centerb';

 foreach(range('A','Z') as $c){
                                                          ($letter == $c)
                                                            ?
 printf('%snbsp',$c)
                                                            : printf('a
 href=browse.php?letter=%s%s/anbsp;',$c,$c);
                                                        }

                                                        echo 'br';
                                                        //Other


 foreach(range('0','9') as $n){
                                                          ($letter == $n)
                                                        ?
 printf('%snbsp',$n)
                                                        : printf('a
 href=?letter=%s#/anbsp;',$n,$n);
                                                      }

                                                        echo
 /bbr/divp;

                              ?


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



How about


?php
 $letter = isset($_GET['letter']) ? $_GET['letter'] :;

 echo 'div align=centerb';

 foreach(range('A','Z') as $c){
   ($letter == $c) ? printf('%snbsp',$c) : printf('a
href=browse.php?letter=%s%s/anbsp;',$c,$c);
 }

 echo 'br';

 //Other
 $bNumberShown = false;
 foreach(range('0','9') as $n){
   if($letter == $n) {
 printf('%snbsp',$n)
   }else{
 if ($bNumberShown){
   printf('a href=?letter=%s%s/anbsp;',$n,$n);
 }else{
   printf('a href=?letter=%s#%s/anbsp;',$n,$n);
   $bNumberShown = true;
 }
 }

  echo /bbr/divp;

?

-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] ForEach Range Problems

2009-07-31 Thread Miller, Terion



On 7/31/09 12:27 PM, Bastien Koert phps...@gmail.com wrote:

$letter = isset($_GET['letter']) ? $_GET['letter'] :;

 echo 'div align=centerb';

 foreach(range('A','Z') as $c){
   ($letter == $c) ? printf('%snbsp',$c) : printf('a
href=browse.php?letter=%s%s/anbsp;',$c,$c);
 }

 echo 'br';

 //Other
 $bNumberShown = false;
 foreach(range('0','9') as $n){
   if($letter == $n) {
 printf('%snbsp',$n)
   }else{
if ($bNumberShown){
   printf('a href=?letter=%s%s/anbsp;',$n,$n);
 }else{
   printf('a href=?letter=%s#%s/anbsp;',$n,$n);
   $bNumberShown = true;
 }
 }

  echo /bbr/divp;

Looks like it would work but I keep getting syntax error unexpected { at the 
first
 }else{
I have tried to move the brackets around but it just moves the error

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



Re: [PHP] ForEach Range Problems

2009-07-31 Thread Bastien Koert
On Fri, Jul 31, 2009 at 1:40 PM, Miller,
Teriontmil...@springfi.gannett.com wrote:



 On 7/31/09 12:27 PM, Bastien Koert phps...@gmail.com wrote:

 $letter = isset($_GET['letter']) ? $_GET['letter'] :;

  echo 'div align=centerb';

  foreach(range('A','Z') as $c){
   ($letter == $c) ? printf('%snbsp',$c) : printf('a
 href=browse.php?letter=%s%s/anbsp;',$c,$c);
  }

  echo 'br';

  //Other
  $bNumberShown = false;
  foreach(range('0','9') as $n){
   if($letter == $n) {
     printf('%snbsp',$n)
   }else{
    if ($bNumberShown){
       printf('a href=?letter=%s%s/anbsp;',$n,$n);
     }else{
       printf('a href=?letter=%s#%s/anbsp;',$n,$n);
       $bNumberShown = true;
     }
  }

  echo /bbr/divp;

 Looks like it would work but I keep getting syntax error unexpected { at the 
 first
  }else{
 I have tried to move the brackets around but it just moves the error


My bad, missed a closing curly brace on the foreach loop

?php
 $letter = isset($_GET['letter']) ? $_GET['letter'] :;

 echo 'div align=centerb';

 foreach(range('A','Z') as $c){
   ($letter == $c) ? printf('%snbsp',$c) : printf('a
href=browse.php?letter=%s%s/anbsp;',$c,$c);
 }

 echo 'br';

 //Other
 $bNumberShown = false;
 foreach(range('0','9') as $n){
   if($letter == $n) {
 printf('%snbsp',$n)
   }else{
 if ($bNumberShown){
   printf('a href=?letter=%s%s/anbsp;',$n,$n);
 }else{
   printf('a href=?letter=%s#%s/anbsp;',$n,$n);
   $bNumberShown = true;
 }
   }
 }
  echo /bbr/divp;

?

-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] ForEach Range Problems

2009-07-31 Thread Miller, Terion



On 7/31/09 12:43 PM, Bastien Koert phps...@gmail.com wrote:

On Fri, Jul 31, 2009 at 1:40 PM, Miller,
Teriontmil...@springfi.gannett.com wrote:



 On 7/31/09 12:27 PM, Bastien Koert phps...@gmail.com wrote:

 $letter = isset($_GET['letter']) ? $_GET['letter'] :;

  echo 'div align=centerb';

  foreach(range('A','Z') as $c){
   ($letter == $c) ? printf('%snbsp',$c) : printf('a
 href=browse.php?letter=%s%s/anbsp;',$c,$c);
  }

  echo 'br';

  //Other
  $bNumberShown = false;
  foreach(range('0','9') as $n){
   if($letter == $n) {
 printf('%snbsp',$n)
   }else{
if ($bNumberShown){
   printf('a href=?letter=%s%s/anbsp;',$n,$n);
 }else{
   printf('a href=?letter=%s#%s/anbsp;',$n,$n);
   $bNumberShown = true;
 }
  }

  echo /bbr/divp;

 Looks like it would work but I keep getting syntax error unexpected { at the 
 first
  }else{
 I have tried to move the brackets around but it just moves the error


My bad, missed a closing curly brace on the foreach loop

?php
 $letter = isset($_GET['letter']) ? $_GET['letter'] :;

 echo 'div align=centerb';

 foreach(range('A','Z') as $c){
   ($letter == $c) ? printf('%snbsp',$c) : printf('a
href=browse.php?letter=%s%s/anbsp;',$c,$c);
 }

 echo 'br';

 //Other
 $bNumberShown = false;
 foreach(range('0','9') as $n){
   if($letter == $n) {
 printf('%snbsp',$n)
   }else{
 if ($bNumberShown){
   printf('a href=?letter=%s%s/anbsp;',$n,$n);
 }else{
   printf('a href=?letter=%s#%s/anbsp;',$n,$n);
   $bNumberShown = true;
 }
   }
 }
  echo /bbr/divp;

?

--

Bastien

Cat, the other other white meat

Argh still nothing just the blank page of death...

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



Re: [PHP] ForEach Range Problems

2009-07-31 Thread Shawn McKenzie
Miller, Terion wrote:
 
 
 On 7/31/09 12:43 PM, Bastien Koert phps...@gmail.com wrote:
 
 On Fri, Jul 31, 2009 at 1:40 PM, Miller,
 Teriontmil...@springfi.gannett.com wrote:


 On 7/31/09 12:27 PM, Bastien Koert phps...@gmail.com wrote:

 $letter = isset($_GET['letter']) ? $_GET['letter'] :;

  echo 'div align=centerb';

  foreach(range('A','Z') as $c){
   ($letter == $c) ? printf('%snbsp',$c) : printf('a
 href=browse.php?letter=%s%s/anbsp;',$c,$c);
  }

  echo 'br';

  //Other
  $bNumberShown = false;
  foreach(range('0','9') as $n){
   if($letter == $n) {
 printf('%snbsp',$n)
   }else{
if ($bNumberShown){
   printf('a href=?letter=%s%s/anbsp;',$n,$n);
 }else{
   printf('a href=?letter=%s#%s/anbsp;',$n,$n);
   $bNumberShown = true;
 }
  }

  echo /bbr/divp;

 Looks like it would work but I keep getting syntax error unexpected { at the 
 first
  }else{
 I have tried to move the brackets around but it just moves the error

 
 My bad, missed a closing curly brace on the foreach loop
 
 ?php
  $letter = isset($_GET['letter']) ? $_GET['letter'] :;
 
  echo 'div align=centerb';
 
  foreach(range('A','Z') as $c){
($letter == $c) ? printf('%snbsp',$c) : printf('a
 href=browse.php?letter=%s%s/anbsp;',$c,$c);
  }
 
  echo 'br';
 
  //Other
  $bNumberShown = false;
  foreach(range('0','9') as $n){
if($letter == $n) {
  printf('%snbsp',$n)
}else{
  if ($bNumberShown){
printf('a href=?letter=%s%s/anbsp;',$n,$n);
  }else{
printf('a href=?letter=%s#%s/anbsp;',$n,$n);
$bNumberShown = true;
  }
}
  }
   echo /bbr/divp;
 
 ?
 
 --
 
 Bastien
 
 Cat, the other other white meat
 
 Argh still nothing just the blank page of death...

Maybe you need a ; after printf('%snbsp',$n).

Also, maybe you need an editor with a syntax highlighter?  You and PJ
should get together and decide on one.

-- 
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] ForEach Range Problems

2009-07-31 Thread Miller, Terion



--snip---

--
Well I almost have it with this, I keep getting an undefined index $letter 
error though and then it outputs the $menu how do I fix that

  //Create array with letters AND number sign  $letters 
= range('A','Z');  array_push($letters, '#');   
 $menu = '';  
foreach($letters as $letter) {  $menu .= ($letter 
== $_GET['letter'])? sprintf('%snbsp', 
$letter): sprintf('a 
href=browse.php?letter=%s%s/anbsp;', $letter, $letter);   
   }

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



Re: [PHP] ForEach Range Problems

2009-07-31 Thread Bastien Koert
On Fri, Jul 31, 2009 at 2:51 PM, Miller,
Teriontmil...@springfi.gannett.com wrote:



 --snip---

 --
 Well I almost have it with this, I keep getting an undefined index $letter 
 error though and then it outputs the $menu how do I fix that

  //Create array with letters AND number sign                          
 $letters = range('A','Z');                          array_push($letters, 
 '#');                                                    $menu = '';          
                 foreach($letters as $letter) {                              
 $menu .= ($letter == $_GET['letter'])                                ? 
 sprintf('%snbsp', $letter)                                : sprintf('a 
 href=browse.php?letter=%s%s/anbsp;', $letter, $letter);                 
          }




What if you just add a

$letters = '';

at the top?

-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] ForEach Range Problems

2009-07-31 Thread Miller, Terion



On 7/31/09 1:56 PM, Bastien Koert phps...@gmail.com wrote:

$letters = '';

Nope still gives the same error:  Notice: Undefined index: letter

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



Re: [PHP] ForEach Range Problems

2009-07-31 Thread Miller, Terion



On 7/31/09 2:00 PM, Miller, Terion tmil...@springfi.gannett.com wrote:




On 7/31/09 1:56 PM, Bastien Koert phps...@gmail.com wrote:

$letters = '';

Nope still gives the same error:  Notice: Undefined index: letter

Well getting closer with this but now my output menu is not a clickable link?

  $letter = 
isset($_GET['letter']) ? $_GET['letter'] :;   
 //Create array with letters AND number sign
   $letters = range('A','Z');   
   array_push($letters, '#');   
 $menu = '';  foreach($letters as $letter) {
  $menu .= ($letter)  ? 
sprintf('%s', $letter)  : sprintf('a 
href=browse.php?letter=%s%s/anbsp', $letter, $letter);
  }echo div 
align=\center\b{$menu}/bbr //div;

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



[PHP] Re: Regex Problem

2009-07-31 Thread Igor Escobar
The solution don't need to be with regex, if anyone can solve this with
other way will be very helpfull .


Regards,
Igor Escobar
Systems Analyst  Interface Designer

+ http://blog.igorescobar.com
+ http://www.igorescobar.com
+ @igorescobar (twitter)





On Fri, Jul 31, 2009 at 2:23 PM, Igor Escobar titiolin...@gmail.com wrote:

 Hi Folks,
 I have a serious problem.

 must create a regular expression against all that is between single quote
 or double quotes. Easy? Ok, i know, but i need that everything must to be
 too an single quote or double quote.

 If i have this SQL command:

 SELECT * FROM TSTRENIC.MEI_ACESSO WHERE UPPER(DS_MEI_ACS) LIKE *'%NOME'
 ASD ' AS'ASD'%' *AND USUARIO = *'oaksdpokasd'asda'* ORDER BY DS_MEI_ACS
 ASC;

 SELECT * FROM TSTRENIC.MEI_ACESSO WHERE USUARIO_DATA BETWEEN *'2007-01-02'
 * AND *'2008-07-08'*

 Anyone have any idea?



 I need an expression which case the fields in bold.


 Regards,
 Igor Escobar
 Systems Analyst  Interface Designer

 + http://blog.igorescobar.com
 + http://www.igorescobar.com
 + @igorescobar (twitter)






[PHP] Re: Regex Problem

2009-07-31 Thread Shawn McKenzie
Igor Escobar wrote:
 The solution don't need to be with regex, if anyone can solve this with
 other way will be very helpfull .
 
 
 Regards,
 Igor Escobar
 Systems Analyst  Interface Designer
 
 + http://blog.igorescobar.com
 + http://www.igorescobar.com
 + @igorescobar (twitter)
 
 
 
 
 
 On Fri, Jul 31, 2009 at 2:23 PM, Igor Escobar titiolin...@gmail.com wrote:
 
 Hi Folks,
 I have a serious problem.

 must create a regular expression against all that is between single quote
 or double quotes. Easy? Ok, i know, but i need that everything must to be
 too an single quote or double quote.

 If i have this SQL command:

 SELECT * FROM TSTRENIC.MEI_ACESSO WHERE UPPER(DS_MEI_ACS) LIKE *'%NOME'
 ASD ' AS'ASD'%' *AND USUARIO = *'oaksdpokasd'asda'* ORDER BY DS_MEI_ACS
 ASC;

 SELECT * FROM TSTRENIC.MEI_ACESSO WHERE USUARIO_DATA BETWEEN *'2007-01-02'
 * AND *'2008-07-08'*

 Anyone have any idea?



 I need an expression which case the fields in bold.


 Regards,
 Igor Escobar
 Systems Analyst  Interface Designer

 + http://blog.igorescobar.com
 + http://www.igorescobar.com
 + @igorescobar (twitter)


Not entirely sure I understand.  You want to BOLD the things contained
in quotes and you put the * there to show that?  If so, this is not tested:

$bolded = preg_replace('#([\'])(.*?)\1#', 'b\1\2\1/b', $text);

-- 
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] ForEach Range Problems

2009-07-31 Thread Bastien Koert
On Fri, Jul 31, 2009 at 3:10 PM, Miller,
Teriontmil...@springfi.gannett.com wrote:



 On 7/31/09 2:00 PM, Miller, Terion tmil...@springfi.gannett.com wrote:




 On 7/31/09 1:56 PM, Bastien Koert phps...@gmail.com wrote:

 $letters = '';

 Nope still gives the same error:  Notice: Undefined index: letter

 Well getting closer with this but now my output menu is not a clickable link?

                                                      $letter = 
 isset($_GET['letter']) ? $_GET['letter'] :;                                 
                        //Create array with letters AND number sign            
                                        $letters = range('A','Z');             
              array_push($letters, '#');                                       
              $menu = '';                          foreach($letters as 
 $letter) {                              $menu .= ($letter)                    
           ? sprintf('%s', $letter)                              : sprintf('a 
 href=browse.php?letter=%s%s/anbsp', $letter, $letter);                  
         }                                                    echo div 
 align=\center\b{$menu}/bbr //div;



check the view source for the link to see what is happening to make it fail
-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] ForEach Range Problems

2009-07-31 Thread Miller, Terion



On 7/31/09 3:08 PM, Bastien Koert phps...@gmail.com wrote:

On Fri, Jul 31, 2009 at 3:10 PM, Miller,
Teriontmil...@springfi.gannett.com wrote:



 On 7/31/09 2:00 PM, Miller, Terion tmil...@springfi.gannett.com wrote:




 On 7/31/09 1:56 PM, Bastien Koert phps...@gmail.com wrote:

 $letters = '';

 Nope still gives the same error:  Notice: Undefined index: letter

 Well getting closer with this but now my output menu is not a clickable link?

  $letter = 
 isset($_GET['letter']) ? $_GET['letter'] :; 
//Create array with letters AND number sign
$letters = range('A','Z'); 
  array_push($letters, '#');   
  $menu = '';  foreach($letters as 
 $letter) {  $menu .= ($letter)
   ? sprintf('%s', $letter)  : sprintf('a 
 href=browse.php?letter=%s%s/anbsp', $letter, $letter);  
 }echo div 
 align=\center\b{$menu}/bbr //div;



check the view source for the link to see what is happening to make it fail
--

Bastien

Cat, the other other white meat


I finally got it working pretty much..next I just have to apply it to the query 
so that if the user clicks the # it will pull the records that begin with a 
number instead of letter from the db...
On the home stretch...

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



Re: [PHP] Re: Regex Problem

2009-07-31 Thread Shawn McKenzie
Igor Escobar wrote:
 No no, i need to make an regex to match the bold areas in my string.
 Anything between single quotes or double quotes (including quotes and
 double quotes). Understand?


 Regards,
 Igor Escobar
 Systems Analyst  Interface Designer

 + http://blog.igorescobar.com
 + http://www.igorescobar.com
 + @igorescobar (twitter)

That's not going to happen without some other criteria.  There is no way
for the regex engine to guess at which sets of quotes belong inside
another set of quotes.

-Shawn

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



Re: [PHP] Re: Regex Problem

2009-07-31 Thread Shawn McKenzie
Shawn McKenzie wrote:
 Igor Escobar wrote:
 No no, i need to make an regex to match the bold areas in my string.
 Anything between single quotes or double quotes (including quotes and
 double quotes). Understand?


 Regards,
 Igor Escobar
 Systems Analyst  Interface Designer

 + http://blog.igorescobar.com
 + http://www.igorescobar.com
 + @igorescobar (twitter)

 That's not going to happen without some other criteria.  There is no way
 for the regex engine to guess at which sets of quotes belong inside
 another set of quotes.
 
 -Shawn

Especially since in one of your examples you don't even have an even
number of quotes.

-- 
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] ForEach Range Problems

2009-07-31 Thread Miller, Terion



-snip---

So I'm almost almost there, but now when I click the # it shows me all records, 
is my foreach range not right?

 //Create array with letters AND number sign
$letters = range('A','Z');array_push($letters, '#');
$menu = '';
$selectedLetter = isset($_GET['letter']) ? $_GET['letter'] : null;  
  foreach($letters as $letter) {$menu .= 
($letter == $selectedLetter)  ? sprintf('%snbsp', 
$letter)  : sprintf('a 
href=browse.php?letter=%s%s/anbsp;', $letter, $letter);   
 }echo div align=\center\b{$menu}/bbr //div;  

  
//Show all restaurants that start with $letter  not between A and Z 
   $other = ctype_digit($letter);   
  foreach(range('0','9') as 
$other) $sql = SELECT 
DISTINCT ID, name, address FROM restaurants WHERE name LIKE '{$other}%' ;  
   $result = mysql_query($sql) 
or die(mysql_error());  
   while($row = 
mysql_fetch_assoc($result)){

$name = $row['name'];   
  printf(   
 'a 
href=view.php?ID=%sb%s/bbr /%sbr /br //a',   
 $row['ID'],
  $row['name'], 
   $row['address']  
  );

}   


   //Show all restaurants that 
start with $letter$sql 
= SELECT DISTINCT ID, name, address FROM restaurants WHERE name LIKE 
'{$selectedLetter}%';
$result = mysql_query($sql) or die(mysql_error());  

 while($row = mysql_fetch_assoc($result)){  

  $name = 
$row['name']; 
printf(
'a href=view.php?ID=%sb%s/bbr /%sbr /br //a',   
 $row['ID'],
  $row['name'], 
   $row['address']  
  );

}

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



[PHP] Clean break.

2009-07-31 Thread Paul Halliday
Whats the cleanest (I have a really ugly) way to break this:

[21/Jul/2009:00:00:47 -0300]

into:

date=21/jul/2009
time=00:00:47

Caveats:

1) if the day is  10 the beginning of the string will look like [space1/...
2) the -0300 will differ depending on DST or TZ. I don't need it
though, it just happens to be there.

This is what I have (it works unless day  10):

$theParts = split([\], $theCLF);

// IP and date/time
$tmpParts = explode( , $theParts[0]);
$theIP = $tmpParts[0];
$x = explode(:, $tmpParts[3]);
$theDate = str_replace([,, $x[0]);
$theTime = $x[1]:$x[2]:$x[3];

the full text for this part looks like:

10.0.0.1 - - [21/Jul/2009:00:00:47 -0300] ... more stuff here

Anyway, any help would be appreciated.

thanks.

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



[PHP] Can a range be passed to a query?

2009-07-31 Thread Miller, Terion
I'm still struggling with using ranges... Can they be passed to a query
somehow...

I have this so far but it pulls nothing:

 //Show all  with $letter  not between A and Z

if ($selectedLetter = #) {

   $other = range('0','9');

$sql = SELECT DISTINCT ID, name, address FROM restaurants WHERE name LIKE
'$other';

 $result = mysql_query($sql) or die(mysql_error());

}
 
while($row = mysql_fetch_assoc($result)){



$name = $row['name'];

printf(
   
'a href=view.php?ID=%sb%s/bbr /%sbr /br //a',

$row['ID'],  
 
$row['name'],
 
$row['address']
   
);


}


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



Re: [PHP] Clean break.

2009-07-31 Thread Phpster





On Jul 31, 2009, at 5:22 PM, Paul Halliday paul.halli...@gmail.com  
wrote:



Whats the cleanest (I have a really ugly) way to break this:

[21/Jul/2009:00:00:47 -0300]

into:

date=21/jul/2009
time=00:00:47

Caveats:

1) if the day is  10 the beginning of the string will look like  
[space1/...

2) the -0300 will differ depending on DST or TZ. I don't need it
though, it just happens to be there.

This is what I have (it works unless day  10):

$theParts = split([\], $theCLF);

   // IP and date/time
   $tmpParts = explode( , $theParts[0]);
   $theIP = $tmpParts[0];
   $x = explode(:, $tmpParts[3]);
   $theDate = str_replace([,, $x[0]);
   $theTime = $x[1]:$x[2]:$x[3];

the full text for this part looks like:

10.0.0.1 - - [21/Jul/2009:00:00:47 -0300] ... more stuff here

Anyway, any help would be appreciated.

thanks.

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



Since it's a fixed length value, what about just using substr() to  
pull out the various bits?


Bastien

Sent from my iPod

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



[PHP] Script to Compare Database Structures

2009-07-31 Thread Matt Neimeyer
I know I CAN hack something together but I hate to reinvent the wheel.

I want to be able to compare the structure of two different clients
databases that might be on different servers that are firewalled away
from each other. Given the two structures it will list all the SQL
commands needed to make the database structure the same.

In a perfect world on one side you would pull up a PHP page that does
a generate structure which would create a downloadable file which
you could then upload to the other system which would then give a
listing of the SQL commands needed to make the local structure match
the uploaded structure.

Thanks in advance...

Matt

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



Re: [PHP] Can a range be passed to a query?

2009-07-31 Thread Phpster





On Jul 31, 2009, at 5:24 PM, Miller, Terion tmil...@springfi.gannett.com 
 wrote:


I'm still struggling with using ranges... Can they be passed to a  
query

somehow...

I have this so far but it pulls nothing:

//Show all  with $letter  not between A and Z

if ($

$result = mysql_query($sql) or die(mysql_error());

}

while($row = mysql_fetch_assoc($result)){



$name = $row['name'];

printf(

'a href=view.php?ID=%sb%s/bbr /%sbr /br //a',

$row['ID'],

$row['name'],

$row['address']

);


}


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




What about


selectedLetter = #) {

  $other = range('0','9');

$sql = SELECT DISTINCT ID, name, address FROM restaurants WHERE left 
(name, 1) between 0 and 9;





Bastien

Sent from my iPod

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



[PHP] Re: Clean break.

2009-07-31 Thread Ollisso
On Sat, 01 Aug 2009 00:22:21 +0300, Paul Halliday  
paul.halli...@gmail.com wrote:



Whats the cleanest (I have a really ugly) way to break this:

[21/Jul/2009:00:00:47 -0300]

into:

date=21/jul/2009
time=00:00:47


...
Why not just use regexp ?

For example:

$string = long text.. multiply lines...
[21/Jul/2009:00:00:47 -0300]

[ 1/Jul/2009:00:00:47 -0300]

[22/Jul/2009:00:00:47 -0300];


preg_match_all('#\[([ 0-9a-zA-Z/]+):([0-9:]+)  
[^]]+\]#',$string,$matches,PREG_SET_ORDER);


print_r($matches);

Output:
Array
(
[0] = Array
(
[0] = [21/Jul/2009:00:00:47 -0300]
[1] = 21/Jul/2009
[2] = 00:00:47
)

[1] = Array
(
[0] = [ 1/Jul/2009:00:00:47 -0300]
[1] =  1/Jul/2009
[2] = 00:00:47
)

[2] = Array
(
[0] = [22/Jul/2009:00:00:47 -0300]
[1] = 22/Jul/2009
[2] = 00:00:47
)

)


--

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



Re: [PHP] Re: Clean break.

2009-07-31 Thread Paul Halliday
I was trying to stay away from regex as much as possible due to the
overhead? I might be wrong here.

This script will be parsing a lot of requests/sec. Thousands, maybe
more, which it also needs to toss into a DB. I want to try and keep it
as fast as possible. This is tricky when you don't know what you are
doing :). My coding is limited to hammering away at the search box on
php.net until I get a push in the right direction. It's just a hack
from there.

Using phpster's substr suggestion has already sped this up considerably.


2009/7/31 Ollisso olli...@fromru.com:
 On Sat, 01 Aug 2009 00:22:21 +0300, Paul Halliday paul.halli...@gmail.com
 wrote:

 Whats the cleanest (I have a really ugly) way to break this:

 [21/Jul/2009:00:00:47 -0300]

 into:

 date=21/jul/2009
 time=00:00:47

 ...
 Why not just use regexp ?

 For example:

 $string = long text.. multiply lines...
        [21/Jul/2009:00:00:47 -0300]

        [ 1/Jul/2009:00:00:47 -0300]

        [22/Jul/2009:00:00:47 -0300];


 preg_match_all('#\[([ 0-9a-zA-Z/]+):([0-9:]+)
 [^]]+\]#',$string,$matches,PREG_SET_ORDER);

 print_r($matches);

 Output:
 Array
 (
    [0] = Array
        (
            [0] = [21/Jul/2009:00:00:47 -0300]
            [1] = 21/Jul/2009
            [2] = 00:00:47
        )

    [1] = Array
        (
            [0] = [ 1/Jul/2009:00:00:47 -0300]
            [1] =  1/Jul/2009
            [2] = 00:00:47
        )

    [2] = Array
        (
            [0] = [22/Jul/2009:00:00:47 -0300]
            [1] = 22/Jul/2009
            [2] = 00:00:47
        )

 )


 --

 --
 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] Script to Compare Database Structures

2009-07-31 Thread German Geek
have you tried mysqldiff?

++Tim Hinnerk Heuer++

http://www.ihostnz.com (should be .org)

Sponsors welcome to put ads under a linked to page. This is not automated
just yet. Only image, swf or preferably text or short html ads, no
animations please. Price negotiable.


2009/8/1 Matt Neimeyer m...@neimeyer.org

 I know I CAN hack something together but I hate to reinvent the wheel.

 I want to be able to compare the structure of two different clients
 databases that might be on different servers that are firewalled away
 from each other. Given the two structures it will list all the SQL
 commands needed to make the database structure the same.

 In a perfect world on one side you would pull up a PHP page that does
 a generate structure which would create a downloadable file which
 you could then upload to the other system which would then give a
 listing of the SQL commands needed to make the local structure match
 the uploaded structure.

 Thanks in advance...

 Matt

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




Re: [PHP] Can a range be passed to a query?

2009-07-31 Thread Paul M Foster
(Sorry, forgot to send this to the whole list.)

On Fri, Jul 31, 2009 at 05:24:45PM -0400, Miller, Terion wrote:

 I'm still struggling with using ranges... Can they be passed to a query
 somehow...
 
 I have this so far but it pulls nothing:
 
  //Show all  with $letter  not between A and Z
 
 if ($selectedLetter = #) {

Problem #1: The above expression will set $selectedLetter to '#', *not*
check whether $selectedLetter is equal to '#'.

 
$other = range('0','9');
 
 $sql = SELECT DISTINCT ID, name, address FROM restaurants WHERE name LIKE
 '$other';

Problem #2: The range() function returns an array (see documentation).
Echo the $sql variable to screen and you may find that it says:

SELECT DISTINCT ... LIKE 'Array'

Try this:

$values = implode(',', $other);
$sql = SELECT DISTINCT ... LIKE '$values';

(See documentation for implode().)

snip

Paul

-- 
Paul M. Foster

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



Re: [PHP] Script to Compare Database Structures

2009-07-31 Thread Paul M Foster
On Fri, Jul 31, 2009 at 05:38:44PM -0400, Matt Neimeyer wrote:

 I know I CAN hack something together but I hate to reinvent the wheel.
 
 I want to be able to compare the structure of two different clients
 databases that might be on different servers that are firewalled away
 from each other. Given the two structures it will list all the SQL
 commands needed to make the database structure the same.
 
 In a perfect world on one side you would pull up a PHP page that does
 a generate structure which would create a downloadable file which
 you could then upload to the other system which would then give a
 listing of the SQL commands needed to make the local structure match
 the uploaded structure.
 
 Thanks in advance...

I don't know what flavor of SQL you're using, but for SQL-compliant
databases, there is an information_schema table (I believe that's the
correct name) which contains most or all of the data you need. Query
that table into an array for each server, and compare the arrays.

Here's a query I've used:

SELECT table_name, column_name, data_type, column_default, is_nullable,
character_maximum_length, numeric_precision, numeric_scale FROM
information_schema.columns WHERE table_name = 'tablename' ORDER BY
ordinal_position

This will not tell you the relations between tables, nor which columns
are primary keys, etc. There may be another way to get this out of
information_schema.

Paul

--
Paul M. Foster

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



[PHP] Problem: Writing into Files?

2009-07-31 Thread Parham Doustdar
Hi there,
I've written a counter for my blog, which keeps the count of visitors in a 
file. However, when the visitors get too many, it resets to zero. Why?

Here's the piece of code:

[code]
$f = $dir . '/view_counter' .EXT;
$fp = fopen($f, r);
$count =fgets($fp, 1024);
fclose($fp);
$fw = fopen($f, w);
$cnew = $count + 1;
$countnew = fputs($fw, $count + 1);
return $cnew;
[/code]

I'm thinking this is caused by two visitors visiting the page at the same time; 
but is there a way to fix it, perhaps the reading/writing parameter?

Thanks!

-- 
---
Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
email: parham90 at GMail dot com