Re: [PHP] Keeping session info in $_SESSION or in database?

2011-08-15 Thread Philip Thompson
On Mon, Aug 15, 2011 at 2:36 PM, Stuart Dallas  wrote:

>
> On 15 Aug 2011, at 20:28, LAMP wrote:
>
> >
> > On Aug 15, 2011, at 2:11 PM, Philip Thompson wrote:
> >
> >> On Mon, Aug 15, 2011 at 1:43 PM, LAMP  wrote:
> >> Hi all,
> >> This is THE question that bothers me for a while... I always was keeping
> session info, like user ID, organization ID, selected book ID... within
> $_SESSION array. Main reason is to access and maintain it faster than
> keeping them inside session table. And, also, one less mysql connection.
> >> Though, in last project the $_SESSION grow up to around 30, even 50
> elements of the array. And several people mentioned it's better to keep so
> big session data in mysql than in $_SESSION.
> >>
> >> My question is pros and cons $_SESSION vs. mysql session. And, if the
> amount of data is only reason, when is better to keep all data in $_SESSION
> and when to store them in mysql?
> >>
> >> Thanks for any help,
> >> LAMP
> >>
> >> Hi all. Long time no see. I personally think 30-50 elements in an array
> is not a lot of data (unless you're storing hundreds of megs of data per
> element). You really have to weigh the pros and cons of using file-based
> session storage versus database session storage. With a quick google search,
> this article by Chris Shiftlett came up:
> http://shiflett.org/articles/storing-sessions-in-a-database. Specially
> look at the background section. It goes over a couple reasons to use a
> database. While this list is not exhaustive by any means, it should get you
> thinking. If the biggest reason for wanting to use a database over the file
> system is because of the space, then you may want to reconsider
> >>
> >> In file-based session storage, the session data is saved in a particular
> location (as specified in php.ini). So, if you have 10MB of data, this will
> be will stored in a file slightly larger than 10MB because I believe the
> data is serialized in some form. This file is accessed upon page load and is
> written to for the next page request. File I/O is generally pretty fast...
> generally much faster than database I/O.
> >>
> >> In the database storage, you must run queries to pull the data
> necessary. This requires a connection plus the time to query plus the time
> to organize the data. If you have 10MB of data, then you still have to pull
> all of that from the database, so I don't believe you're getting any speed
> advantage. If you're application is running on multiple servers, then you'd
> want to consider the database storage. IMO, only use the database (for
> session storage) if it solves a problem that can be easily fixed otherwise
> by using file-based session storage.
> >>
> >> Hope that helps,
> >> ~Philip
> >>
> >> --
> >> http://lonestarlightandsound.com/
> >
> >
> > I apologize for posting not-complete data :-)
> > The size of the data is, I believe, small. 1-2 words per array element or
> number. No image or something like that is stored in $_SESSION.  I believe
> no more than few Kb.
> >
> > My concern is not only speed, than handling (as you said "time to query
> plus the time to organize the data..."),as well as security. I read
> Shiflett's article but it dates from 2004 and I believe some stuff are
> changed too :-)
> >
> > As I said, I prefer working with $_SESSION instead storing data into
> session table, but always wondered is that correct approach.
>
> Whatever session storage mechanism you use, you can continue to use
> $_SESSION. The process Chris describes in his post replaces the engine that
> loads and saves the contents of $_SESSION. You might want to read a lot more
> about how sessions work before you consider customising the storage
> mechanism.
>
> -Stuart
>

I don't see that the default file-based session storage as any less secure
than another approach. If your session data is only several KB, then just
use the default unless you have a specific reason not to...

~Philip


Fwd: [PHP] Keeping session info in $_SESSION or in database?

2011-08-15 Thread Philip Thompson
Crap! I wish this list would have a reply-to list automatically

-- Forwarded message --
From: Philip Thompson 
Date: Mon, Aug 15, 2011 at 2:11 PM
Subject: Re: [PHP] Keeping session info in $_SESSION or in database?
To: LAMP 


On Mon, Aug 15, 2011 at 1:43 PM, LAMP  wrote:

> Hi all,
> This is THE question that bothers me for a while... I always was keeping
> session info, like user ID, organization ID, selected book ID... within
> $_SESSION array. Main reason is to access and maintain it faster than
> keeping them inside session table. And, also, one less mysql connection.
> Though, in last project the $_SESSION grow up to around 30, even 50
> elements of the array. And several people mentioned it's better to keep so
> big session data in mysql than in $_SESSION.
>
> My question is pros and cons $_SESSION vs. mysql session. And, if the
> amount of data is only reason, when is better to keep all data in $_SESSION
> and when to store them in mysql?
>
> Thanks for any help,
> LAMP
>

Hi all. Long time no see. I personally think 30-50 elements in an array is
not a lot of data (unless you're storing hundreds of megs of data per
element). You really have to weigh the pros and cons of using file-based
session storage versus database session storage. With a quick google search,
this article by Chris Shiftlett came up:
http://shiflett.org/articles/storing-sessions-in-a-database. Specially look
at the background section. It goes over a couple reasons to use a database.
While this list is not exhaustive by any means, it should get you thinking.
If the biggest reason for wanting to use a database over the file system is
because of the space, then you may want to reconsider

In file-based session storage, the session data is saved in a particular
location (as specified in php.ini). So, if you have 10MB of data, this will
be will stored in a file slightly larger than 10MB because I believe the
data is serialized in some form. This file is accessed upon page load and is
written to for the next page request. File I/O is generally pretty fast...
generally much faster than database I/O.

In the database storage, you must run queries to pull the data necessary.
This requires a connection plus the time to query plus the time to organize
the data. If you have 10MB of data, then you still have to pull all of that
from the database, so I don't believe you're getting any speed advantage. If
you're application is running on multiple servers, then you'd want to
consider the database storage. IMO, only use the database (for session
storage) if it solves a problem that can be easily fixed otherwise by using
file-based session storage.

Hope that helps,
~Philip

-- 
http://lonestarlightandsound.com/



-- 
http://lonestarlightandsound.com/


Re: [PHP] phpsadness

2011-06-02 Thread Philip Thompson
On Thu, Jun 2, 2011 at 12:02 PM, Daniel Brown  wrote:

> On Tue, May 31, 2011 at 22:13, Bill Guion  wrote:
> >
> > So if I understand, you want an explode() with empty parameters to
> explode
> > the host machine?
>
>That's correct.  If it causes too much userland confusion, we can
> alias it as detonate() as well.
>
>
It would be nice if there were a "Like" feature here...

~Philip

-- 
http://lonestarlightandsound.com/


Re: [PHP] Re: Need pro advice: Is Pear installed and/or setup correctly?

2011-05-27 Thread Philip Thompson
On Fri, May 27, 2011 at 1:36 PM, Micky Hulse wrote:

> On Fri, May 27, 2011 at 10:27 AM, Micky Hulse
>  wrote:
> > Would it be safe for me to conclude that Pair is not setup properly?
>
> Haha, "Pear" the package, not the host. :D
>
> http://www.pair.com/
>
> Typo. My bad.
>
> Also, what the heck does this mean:
>
> "It is not safe to rely on the system's timezone settings. Please use
> the date.timezone setting, the TZ environment variable or the
> date_default_timezone_set() function. In case you used any of those
> methods and you are still getting this warning, you most likely
> misspelled the timezone identifier. We selected 'America/New_York' for
> 'EDT/-4.0/DST' instead in /home/USER/public_html/test.php on line 6"
>

The host is apparently using PHP 5.3 - this message started to appear in
this version. Use date_default_timezone_set() somewhere in your code to
explicitly set your timezone. I'm in the central US, so I use
'America/Chicago'. See the docs for more info.

Not sure about your original question.

Happy coding,
~Philip

http://lonestarlightandsound.com/


Re: [PHP] Re: php to store data

2011-05-03 Thread Philip Thompson
On Tue, May 3, 2011 at 5:18 AM, Florin Jurcovici  wrote:

> Hi.
>
> Create a page containing just:
>
>  phpinfo()
> ?>
>
> open it in a browser, then see if SQLite appears in the resulting web
> page. If yes, you're done - you can use an actual database, although
> an embedded one. But this should also mean that you have file write
> access from PHP - since SQLite creates databases in files, which it
> needs to be able to write. (Although brain-damaged setups where SQLite
> is installed but write access to the disk cannot be excluded - you
> need to test.)
>
> If you don't have write access to the disk, my guess is that paying
> for mySQL is the cheapest solution - and a very good one, actually.
>
> br,
>
> flj


Paying for mysql (non enterprise) just seems wrong...

~Philip

http://lonestarlightandsound.com/


Re: [PHP] ORM doctrine

2010-12-09 Thread Philip Thompson
On Dec 10, 2010, at 12:00 AM, Paul M Foster wrote:

> On Thu, Dec 09, 2010 at 07:41:32PM -0800, Daevid Vincent wrote:
>> 
>>> -Original Message-
 If you value CPU time over developer time, by all means avoid ORM
 frameworks (and *all* frameworks). The point of a common
>>> framework is to
 trade a small bit of performance for a large amount of
>>> developer time. If
 you will only use the framework once, the payoff will be
>>> much less. The
 goal is to choose frameworks that you can leverage again and again.
>> 
> 
> [snip]
> 
>> 
>> That's just it. DO NOT make a "framework". Make some helper routines for
>> common tasks like sql_query(), sql_insert(), sql_update(),
>> sql_select_box(), etc. and stick to the "basics".
>> 
>> Frameworks are a waste of time and energy -- homegrown or off-the-shelf.
>> They try to be all things to all people and turn into a "jack of trades,
>> master of none". They're bloated and cumbersome and force you to wedge
>> square pegs into round holes all the time.
> 
> I have to agree with the "toolkit" idea.
> 
> I just came off of job where they had an existing investment in Drupal,
> so we were stuck with it. No offense to any Drupalers out there. It's a
> very slick, cleverly thought out framework. But building anything
> non-trivial with the framework requires a significant learning curve and
> coding investment. And many things you'll want to do, you could do ten
> times faster by hand.
> 
> This is the second framework I've done any significant research into.
> And my original decision to build a set of "tools" and use them for
> various tasks over and over seems the soundest course. The more those
> tools interlock, the more they become a framework, and the less flexible
> they become.
> 
> The tools, used in a "habitual context" (models go here, views go there,
> etc.) makes for a much easier time of it. Not to mention that your
> thousands of site visitors won't be loading 150K of code each time just
> to view one page. (Yes, I've heard of caching. It's a system which was
> built to compensate for coders who waste too much CPU time and memory.)
> 
> Paul

I've used good ole' procedural PHP, built a homegrown "framework" and now I use 
CakePHP, which has ORM. Yes, at first, it was a little confusing to understand. 
But once you get it, it's really easy to create a database-driven, dynamic 
application with little effort. Like most things in programming, you have to 
find what works for you. While it is good to consider that others may have to 
work with your _flawless_ code some day - so you better make it understandable 
- many times clients just want what you can give them as soon as possible. What 
I've found is that by using a framework (such as Cake) I am able to give the 
client what they want... and quickly. If I ever run into a problem that can't 
be easily solved by the framework, I resort to my experience with "direct PHP" 
and just create a manual solution. That's the beauty of PHP.

CPU cycles are cheap and caching is there to speed things up, so I don't 
completely understand those who complain about these things...

Happy coding,
~Philip

[PHP] Re: Cake

2010-08-13 Thread Philip Thompson
On Aug 13, 2010, at 10:49 AM, Philip Thompson wrote:

> Hi all.
> 
> Having an issue with some CakePHP 1.3 stuff. I've read and read and read and 
> haven't found my solution. I'm fairly new to Cake, so be nice. I'm trying to 
> access a method from a different controller than the one I'm in and it's not 
> letting me.
> 
> -location.php (model) - create the relationship
> public $belongsTo = 'Address';
> 
> -locations_controller.php - grab all the locations (+ addresses for each 
> location) and format the addresses
> $locations = $this->Location->find('all');
> ...
> $this->Location->Address->format(...);   // This line throws the error
> ...
> 
> -addresses_controller.php
> public function format (...) { ... }
> 
> From my understanding, everything is defined correctly, but it thinks that 
> I'm calling a query when it errors:
> 
> Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check 
> the manual that corresponds to your MySQL server version for the right syntax 
> to use near 'format' at line 1 
> [CORE/cake/libs/model/datasources/dbo_source.php, line 681]
> 
> It thinks that the method "format()" is a query. Why?! I just want it to call 
> that method. Please help!
> 
> Thanks in advance,
> ~Philip

I'm sure this is a rookie mistake, but I figured it out. I was putting the 
format() method in the addresses_controller file when I should have been 
putting it into the address model file. Upon putting it there, it worked as 
expected!

Thanks!

~Philip



[PHP] Cake

2010-08-13 Thread Philip Thompson
Hi all.

Having an issue with some CakePHP 1.3 stuff. I've read and read and read and 
haven't found my solution. I'm fairly new to Cake, so be nice. I'm trying to 
access a method from a different controller than the one I'm in and it's not 
letting me.

-location.php (model) - create the relationship
public $belongsTo = 'Address';

-locations_controller.php - grab all the locations (+ addresses for each 
location) and format the addresses
$locations = $this->Location->find('all');
...
$this->Location->Address->format(...);   // This line throws the error
...

-addresses_controller.php
public function format (...) { ... }

From my understanding, everything is defined correctly, but it thinks that I'm 
calling a query when it errors:

Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check the 
manual that corresponds to your MySQL server version for the right syntax to 
use near 'format' at line 1 [CORE/cake/libs/model/datasources/dbo_source.php, 
line 681]

It thinks that the method "format()" is a query. Why?! I just want it to call 
that method. Please help!

Thanks in advance,
~Philip

Re: [PHP] generate animated gifs

2010-08-02 Thread Philip Thompson
On Aug 2, 2010, at 5:29 PM, Ashley Sheridan wrote:

> On Mon, 2010-08-02 at 18:43 -0300, Martín Marqués wrote:
> 
>> Is there a way (I haven't found it yet) to create with a sequence of
>> gifs an animated gif using php-gd?
>> 
>> -- 
>> Martín Marqués
>> select 'martin.marques' || '@' || 'gmail.com'
>> DBA, Programador, Administrador
>> 
> 
> Not natively with GD. For more complicated image creation, such as
> animated GIFs, you should look at ImageMagick. This tool has some
> extremely powerful options, and there is a PHP module for working with
> it if you can't or don't want to get dirty on the command line.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

I thought that GIF was patented or copyrighted or something - didn't know if it 
was possible to create GIFs with ImageMagick/PHP. Did I pull that from left 
field?

~Philip

http://lonestarlightandsound.com/


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



[PHP] CakePHP

2010-08-02 Thread Philip Thompson
Hi all.

Long time no talk. I'm getting a little bit more involved with CakePHP and I 
wanted to get some feedback from some seasoned veterans. From what I've played 
around with so far, I enjoy its structure and ability to create sites quickly. 
I was curious about some of the pros and cons that others have had with 
CakePHP. Thoughts? Enlighten me!

Thanks,
~Philip

http://lonestarlightandsound.com/


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




Re: [PHP] displaying database output in a table

2010-05-27 Thread Philip Thompson
On May 25, 2010, at 8:27 PM, David Mehler wrote:

> Hello,
> I'm trying to display mysql database output in a formatted table. My
> problem is i'm getting a blank screen with no errors. I've got
> debugging on, and have run the cli php on this file which produces no
> errors either, but neither does it give me any output.
> My eventual goal is to select the two nearest future events to the
> current date. Having done that I want to display the name, location,
> start date, start time, and a summary. Right now though I just want to
> put all information in the database in to a table.
> 
> Here's the code. Pointers welcome.
> Thanks.
> Dave.
> 
>  require_once($_SERVER['DOCUMENT_ROOT'] . "/dbconnect.php");

I ran into a similar issue yesterday. Tracked it down and figured out the 
"required" file did not exist. It didn't show up in my dev environment b/c I 
had the file. When we pushed it to QA, the file had not been uploaded. The 
require_once() stops execution if the file isn't found. Try changing it to 
include_once() and see if you can _any_ output.

Hope this helps.
~Philip


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



Re: [PHP] strtotime woes

2010-05-05 Thread Philip Thompson
On May 5, 2010, at 10:12 AM, Peter Lind wrote:

> On 5 May 2010 16:58, Philip Thompson  wrote:
>> Hello all.
>> 
>> Long time no see! Anyway, I'm having an issue with strtotime(). Why do the 
>> following return valid timestamps?
>> 
>> > echo strtotime ('a').': '.date ("m/d/Y", strtotime ('a'))."";
>> echo strtotime ('a,a').': '.date ("m/d/Y", strtotime ('a,a'))."";
>> echo strtotime ('a,a,a').': '.date ("m/d/Y", strtotime ('a,a,a'))."";
>> ?>
>> 
>> These result in today's date:
>> 
>> 1273049449: 05/05/2010
>> 1273049449: 05/05/2010
>> 1273049449: 05/05/2010
>> 
>> Each time the page is reloaded, the seconds jump up... but still today's 
>> date. Why is this? I can repeat the same results by changing the 'a' to any 
>> other single letter: "g" or "h,k" or "r,s,t" or whatever - all the same 
>> result.
>> 
> 
> This was discusses a little while ago, have a look at
> news.php.net/php.general/303839/Logical-reason-for-strtotime-east-and-strtotime-west-returningvalid-results.html
> and the responses.
> 
> Regards
> Peter

Thanks for the link. I did a little bit more research and found a site that may 
help explain what is happening.

http://wwp.greenwichmeantime.com/info/timezone.htm

In the column labeled "Zone" are all the letters of the alphabet (except J). 
So, then I thought to print the times with the date() functions above - they 
were various time(zones). Basically, I think strotime() is just ignoring the 
characters after the first comma in the values above, so then it was finding 
valid timezones. Odd.

Hope this helps someone in the future

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



[PHP] strtotime woes

2010-05-05 Thread Philip Thompson
Hello all.

Long time no see! Anyway, I'm having an issue with strtotime(). Why do the 
following return valid timestamps?

";
echo strtotime ('a,a').': '.date ("m/d/Y", strtotime ('a,a'))."";
echo strtotime ('a,a,a').': '.date ("m/d/Y", strtotime ('a,a,a'))."";
?>

These result in today's date:

1273049449: 05/05/2010
1273049449: 05/05/2010
1273049449: 05/05/2010

Each time the page is reloaded, the seconds jump up... but still today's date. 
Why is this? I can repeat the same results by changing the 'a' to any other 
single letter: "g" or "h,k" or "r,s,t" or whatever - all the same result.

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



Re: [PHP] MySQL Appeal from Monty

2009-12-16 Thread Philip Thompson
On Dec 16, 2009, at 1:48 PM, Yousif Masoud wrote:

> On Wed, Dec 16, 2009 at 3:14 PM, Philip Thompson  
> wrote:
> On Dec 15, 2009, at 6:03 AM, Ashley Sheridan wrote:
> 
> > On Tue, 2009-12-15 at 02:53 +, Joseph Masoud wrote:
> >>
> >> On 14 Dec 2009, at 22:01, Ashley Sheridan 
> >> wrote:
> >>
> >> > On Mon, 2009-12-14 at 15:59 -0600, Philip Thompson wrote:
> >> >
> >> >> On Dec 14, 2009, at 12:51 AM, Lester Caine wrote:
> >> >>
> >> >>> Lenin wrote:
> >> >>>> You might also like this:
> >> >>>> Come on Monty - Lukas Smith http://bit.ly/5lmwwD
> >> >>>
> >> >>> I've been watching some of this debate with interest, but I'll
> >> >>> stay with a database that has none of the baggage that MySQL has
> >> >>> always had, and IS currently replacing Oracle in many large sites :)
> >> >>>
> >> >>> --
> >> >>> Lester Caine - G8HFL
> >> >>
> >> >> Do share your db of interest... (and please don't say MSSQL).
> >> >>
> >> >> ~Philip
> >> >>
> >> >>
> >> >
> >> >
> >> > MSSQL has nearly brought me to tears and could have easily made me
> >> > bald
> >> > through hair pulling!
> >> >
> >> > I have to say, I do like MySQL, it's very flexible and fast, and being
> >> > able to choose different storage engines for different tables in the
> >> > same DB is brilliant! I really don't think there's anything to overly
> >> > worry about from Oracle, as the two DB's have different audiences.
> >> >
> >> > Thanks,
> >> > Ash
> >> > http://www.ashleysheridan.co.uk
> >> >
> >> >
> >> Unfortunately, I do not share your optimism.  I believe that Oracle
> >> taking over MySQL would be a disaster of epic proportions.
> >>
> >> The "different audiences" theory has been bought up several times but
> >> I haven't [to date] seen a sound justification for it. Oracle wants
> >> everyone to use ... Oracle, I can't see how this "different audiences"
> >> theory is going to make Oracle promote MySQL, perhaps someone can tell
> >> me?
> >>
> >> I don't think the EU would be able to do anything about it.  The
> >> powerful companies almost always get what they want.
> >>
> >> I don't think Monty wouldn't be doing this unless he felt that
> >> something [put mildly] bad is coming.
> >>
> >> What has happened, has happened.  Trying to figure out who is to blame
> >> for this mess is pointless. Ideally, It would be nice if Oracle took
> >> its claws off MySQL and found another project to ruin.
> >>
> >> Note: I am *not* trying to spread FUD
> >
> > I've always been led to believe that you go with MySQL if you want speed, 
> > Oracle if you want data integrity. I know they both handle each one 
> > admirably, but Oracle is known more for guarding the data against mishaps 
> > and MySQL is known more for performance. I just think it may be a little 
> > early to be condemning Oracle yet, we should wait a little to at least see 
> > what stance they have on the whole thing. And before you ask, no I have no 
> > connection to Oracle, I'm an avid MySQL fan!
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> 
> Let's not forget one of the biggest decisions on why people choose MySQL over 
> Oracle/MSSQL it's way cheap. So cheap they're nearly giving it away. Oh 
> wait! They ARE giving it away. You start to piss people off whenever you take 
> away their working, free option. Also by being open source, you have plenty 
> of people that have the opportunity to work with it. The biggest reason I 
> haven't messed with Oracle (except in college for my db class) is that it's 
> expensive. Don't underestimate how cheap people are. There's your "different 
> audience."
> 
> ~Philip
> Your rant has been repeated so many times that it is becoming like a 
> corporate mantra.  Some of the biggest software companies in the world use 
> open source software (which is free as in free beer).  Are companies that use 
> Linux or FreeBSD as their server software "cheap"?  For the remainder of my 
> argument, I will assume that your asser

Re: [PHP] PHP + ODBC

2009-12-16 Thread Philip Thompson
On Dec 16, 2009, at 9:22 AM, Andrew Ballard wrote:

> On Tue, Dec 15, 2009 at 10:13 AM, Philip Thompson 
> wrote:
>> On Dec 14, 2009, at 8:47 PM, James McLean wrote:
>>> Why not just use the built in MySQL libraries or PDO?
>> 
>> Oh, that would be "my" preference. However, the database that I
>> really need to connect to is an MSSQL one and the allowed connection
>> type is ODBC.
> 
> Is there any chance that you have to work with fields that will return
> more than 4k of text? If so, you may have problems with ODBC. I can't
> remember if I ever used odbc_connect() and its related functions with
> SQL Server (I mostly use it to read Excel spreadsheets), but I know we
> couldn't use PDO (with either the PDO_MSSQL or PDO_ODBC drivers)
> because of a limit on TEXTSIZE that we couldn't get around. On our
> older stuff, we're still using the mssql library, but on our newer
> stuff we're using the SQL Server Driver for PHP. It connects via ODBC,
> but it is the best library I've found for working with SQL Server in
> PHP.
> 
> 
> Andrew

So, instead of using odbc_* functions, just use the mssql_* functions?

~Philip


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



Re: [PHP] MySQL Appeal from Monty

2009-12-16 Thread Philip Thompson
On Dec 15, 2009, at 6:03 AM, Ashley Sheridan wrote:

> On Tue, 2009-12-15 at 02:53 +, Joseph Masoud wrote:
>> 
>> On 14 Dec 2009, at 22:01, Ashley Sheridan   
>> wrote:
>> 
>> > On Mon, 2009-12-14 at 15:59 -0600, Philip Thompson wrote:
>> >
>> >> On Dec 14, 2009, at 12:51 AM, Lester Caine wrote:
>> >>
>> >>> Lenin wrote:
>> >>>> You might also like this:
>> >>>> Come on Monty - Lukas Smith http://bit.ly/5lmwwD
>> >>>
>> >>> I've been watching some of this debate with interest, but I'll  
>> >>> stay with a database that has none of the baggage that MySQL has  
>> >>> always had, and IS currently replacing Oracle in many large sites :)
>> >>>
>> >>> -- 
>> >>> Lester Caine - G8HFL
>> >>
>> >> Do share your db of interest... (and please don't say MSSQL).
>> >>
>> >> ~Philip
>> >>
>> >>
>> >
>> >
>> > MSSQL has nearly brought me to tears and could have easily made me  
>> > bald
>> > through hair pulling!
>> >
>> > I have to say, I do like MySQL, it's very flexible and fast, and being
>> > able to choose different storage engines for different tables in the
>> > same DB is brilliant! I really don't think there's anything to overly
>> > worry about from Oracle, as the two DB's have different audiences.
>> >
>> > Thanks,
>> > Ash
>> > http://www.ashleysheridan.co.uk
>> >
>> >
>> Unfortunately, I do not share your optimism.  I believe that Oracle  
>> taking over MySQL would be a disaster of epic proportions.
>> 
>> The "different audiences" theory has been bought up several times but  
>> I haven't [to date] seen a sound justification for it. Oracle wants  
>> everyone to use ... Oracle, I can't see how this "different audiences"  
>> theory is going to make Oracle promote MySQL, perhaps someone can tell  
>> me?
>> 
>> I don't think the EU would be able to do anything about it.  The  
>> powerful companies almost always get what they want.
>> 
>> I don't think Monty wouldn't be doing this unless he felt that  
>> something [put mildly] bad is coming.
>> 
>> What has happened, has happened.  Trying to figure out who is to blame  
>> for this mess is pointless. Ideally, It would be nice if Oracle took  
>> its claws off MySQL and found another project to ruin.
>> 
>> Note: I am *not* trying to spread FUD
> 
> I've always been led to believe that you go with MySQL if you want speed, 
> Oracle if you want data integrity. I know they both handle each one 
> admirably, but Oracle is known more for guarding the data against mishaps and 
> MySQL is known more for performance. I just think it may be a little early to 
> be condemning Oracle yet, we should wait a little to at least see what stance 
> they have on the whole thing. And before you ask, no I have no connection to 
> Oracle, I'm an avid MySQL fan!
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 

Let's not forget one of the biggest decisions on why people choose MySQL over 
Oracle/MSSQL it's way cheap. So cheap they're nearly giving it away. Oh 
wait! They ARE giving it away. You start to piss people off whenever you take 
away their working, free option. Also by being open source, you have plenty of 
people that have the opportunity to work with it. The biggest reason I haven't 
messed with Oracle (except in college for my db class) is that it's expensive. 
Don't underestimate how cheap people are. There's your "different audience."

~Philip

Re: [PHP] PHP + ODBC

2009-12-16 Thread Philip Thompson
On Dec 15, 2009, at 9:50 AM, Richard Quadling wrote:

> 2009/12/15 Philip Thompson :
>> On Dec 14, 2009, at 8:47 PM, James McLean wrote:
>> 
>>> On Tue, Dec 15, 2009 at 10:03 AM, Philip Thompson
>>>  wrote:
>>>> My head hurts from hitting it on my desk all day, so I thought I'd turn to 
>>>> a fresher set of eyes. The issue I'm having is getting PHP to connect 
>>>> ODBC. I can get it to work using isql from the command line. Can you 
>>>> verify my settings:
>>>> 
>>> [snipped]
>>>> 
>>>> I've tried the above DSNs and many other versions of it ad nauseum. The 
>>>> specific error I'm getting is... "[unixODBC][Driver Manager]Data source 
>>>> name not found, and no default driver specified." I really have searched 
>>>> high and low for a solution, but to no avail. Any thoughts?
>>> 
>>> Why not just use the built in MySQL libraries or PDO?
>> 
>> Oh, that would be "my" preference. However, the database that I really need 
>> to connect to is an MSSQL one and the allowed connection type is ODBC. I was 
>> just testing first with a MySQL connection to get it working (I don't have 
>> the MSSQL credentials yet). Turned out I was VERY close with my solution, 
>> which a coworker figured out this morning. The [ODBC Data Sources] entry for 
>> MySQL needed to specified correctly in /etc/odbc.ini.
>> 
>> [ODBC Data Sources]
>> MySQL = MySQL
>> 
>> [MySQL]
>> Description...
>> Driver...
>> 
>> I could have sworn I tried that, but who knows
>> 
>> Thank you!
>> ~Philip
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
> 
> You can use a DNS-string too ...
> 
> odbc_pconnect("Driver={SQL Server Native Client
> 10.0};Server={$s_Server};Database={$s_DB};MARS_Connection=Yes;",
> $s_User, $s_Pswd, SQL_CUR_USE_DRIVER);

I'm actually using a combination of the DSN*-string and the odbc.ini settings. 
Thank you!

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



Re: [PHP] Best ajax library

2009-12-15 Thread Philip Thompson
On Dec 15, 2009, at 3:12 AM, Joseph Masoud wrote:

> On 15 Dec 2009, at 08:50, Ali Asghar Toraby Parizy 
>  wrote:
> 
>> Which one is more active than others? I mean which project extends
>> faster and better, in future?
>> 
>> On Tue, Dec 15, 2009 at 1:37 AM, Philip Thompson  
>> wrote:
>>> On Dec 14, 2009, at 4:27 AM, Ali Asghar Toraby Parizy wrote:
>>> 
>>>> Hi
>>>> I think the best choice is jquery until now.
>>>> But, is it reasonable to combine jquery and other library to client
>>>> side and server side scripting respectively?
>>>> By the way, where i can find good lessons about jquery and php?
>>> 
>>> I really like this js library.
>>> 
>>> http://mootools.net/
>>> 
>>> It's based off of jquery or prototype... I can't remember.
>>> 
>>> ~Philip
>>> 
> JQuery and Mootools are two very different approaches of creating a 
> JavaScript framework. Both shine in different ways.
> 
> I use JQuery when I want to get things done quickly (using the Yii framework 
> or on custom projects).  I use mootols when I develop Joomla! Extensions and 
> it's amazing.  Which is more suitable boils down to what your project needs.
> 
> I'm messing around with Ext at the moment and it's really nice too!
> 
> The ultimate answer to your question is; "it depends". 

Along those lines of "it depends"... to my knowledge, most of the larger/more 
popular js frameworks consider other libraries when being developed. Meaning, 
the chances of a naming conflict are lowered. Not that I recommend it, but it 
does allow for using multiple libraries for a single project - that's another 
thread.

I can't speak for the other libraries, but I know that MooTools is constantly 
being updated and improved. I doubt that it will be leaving anytime soon. Check 
out some extended functionality of MooTools... Clientcide. It's created by the 
same author of MooTools to work with it.

http://www.clientcide.com/

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



Re: [PHP] PHP + ODBC

2009-12-15 Thread Philip Thompson
On Dec 14, 2009, at 8:47 PM, James McLean wrote:

> On Tue, Dec 15, 2009 at 10:03 AM, Philip Thompson
>  wrote:
>> My head hurts from hitting it on my desk all day, so I thought I'd turn to a 
>> fresher set of eyes. The issue I'm having is getting PHP to connect ODBC. I 
>> can get it to work using isql from the command line. Can you verify my 
>> settings:
>> 
> [snipped]
>> 
>> I've tried the above DSNs and many other versions of it ad nauseum. The 
>> specific error I'm getting is... "[unixODBC][Driver Manager]Data source name 
>> not found, and no default driver specified." I really have searched high and 
>> low for a solution, but to no avail. Any thoughts?
> 
> Why not just use the built in MySQL libraries or PDO?

Oh, that would be "my" preference. However, the database that I really need to 
connect to is an MSSQL one and the allowed connection type is ODBC. I was just 
testing first with a MySQL connection to get it working (I don't have the MSSQL 
credentials yet). Turned out I was VERY close with my solution, which a 
coworker figured out this morning. The [ODBC Data Sources] entry for MySQL 
needed to specified correctly in /etc/odbc.ini.

[ODBC Data Sources]
MySQL = MySQL

[MySQL]
Description...
Driver...

I could have sworn I tried that, but who knows

Thank you!
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP + ODBC

2009-12-14 Thread Philip Thompson
Hello all.

My head hurts from hitting it on my desk all day, so I thought I'd turn to a 
fresher set of eyes. The issue I'm having is getting PHP to connect ODBC. I can 
get it to work using isql from the command line. Can you verify my settings:

/etc/odbc.ini:

[MySQL]
Description = MySQL 3.51 ODBC driver
Driver  = MySQL
Host= s-irv-web02
Server  = s-irv-web02
UID = user
Password= pass
Database= clients
Port= 3306

/etc/odbcinst.ini:

[MySQL]
Description = ODBC 3.51 for MySQL
Driver  = /usr/lib/libmyodbc3.so
Setup   = /usr/lib/libodbcmyS.so
FileUsage   = 1
UsageCount  = 2

Again, isql allows me to connect with the same settings as above: isql MySQL 
user pass

I've tried several settings in PHP to attempt to connect to it. All have been 
fruitless:



I've tried the above DSNs and many other versions of it ad nauseum. The 
specific error I'm getting is... "[unixODBC][Driver Manager]Data source name 
not found, and no default driver specified." I really have searched high and 
low for a solution, but to no avail. Any thoughts?

Thanks in advance,
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Best ajax library

2009-12-14 Thread Philip Thompson
On Dec 14, 2009, at 4:27 AM, Ali Asghar Toraby Parizy wrote:

> Hi
> I think the best choice is jquery until now.
> But, is it reasonable to combine jquery and other library to client
> side and server side scripting respectively?
> By the way, where i can find good lessons about jquery and php?

I really like this js library.

http://mootools.net/

It's based off of jquery or prototype... I can't remember.

~Philip

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



Re: [PHP] PHP live chat

2009-12-14 Thread Philip Thompson
On Dec 14, 2009, at 2:14 AM, Angelo Zanetti wrote:

> Hi all, 
> 
> I know there are a lot of scripts that one can pay for, for "live chat" -
> website support.
> 
> Are there are any free open source ones that work well?
> 
> I found: www.phplivechat.com
> 
> But still waiting to evaluate it.
> 
> Please send you comments, good or bad and what you would recommend or not
> recommend and why
> 
> Thanks in advance.
> 
> Angelo

We used phplivechat at my last company. I'm pretty sure I was the one who set 
it up, and I don't remember hating it. It seemed to work pretty reliably and 
our customers seemed to have enjoyed it. I'd recommend it.

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



Re: [PHP] MySQL Appeal from Monty

2009-12-14 Thread Philip Thompson

On Dec 14, 2009, at 12:51 AM, Lester Caine wrote:

> Lenin wrote:
>> You might also like this:
>> Come on Monty - Lukas Smith http://bit.ly/5lmwwD
> 
> I've been watching some of this debate with interest, but I'll stay with a 
> database that has none of the baggage that MySQL has always had, and IS 
> currently replacing Oracle in many large sites :)
> 
> -- 
> Lester Caine - G8HFL

Do share your db of interest... (and please don't say MSSQL).

~Philip


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



Re: [PHP] Passing HTML array index to JS?

2009-12-08 Thread Philip Thompson

On Dec 8, 2009, at 11:10 AM, tedd wrote:

> At 9:07 PM -0600 12/7/09, Philip Thompson wrote:
>> 
>> -snip-
> 
> Good stuff.
> 
> Thanks,
> 
> tedd

You say so much with so little...

~Philip


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



Re: [PHP] request for support

2009-12-08 Thread Philip Thompson
On Dec 8, 2009, at 6:12 AM, Ashley Sheridan wrote:

> On Tue, 2009-12-08 at 12:08 +, Tarek Kaddoura wrote:
>> __
>> Subject: RE: [PHP] request for support
>> From: a...@ashleysheridan.co.uk
>> To: stevewiese...@hotmail.com
>> CC: php-general@lists.php.net
>> Date: Tue, 8 Dec 2009 11:53:53 +
>> 
>> On Tue, 2009-12-08 at 11:53 +, Tarek Kaddoura wrote:
>> 
>> 
>>sorry sorry thats a typo error
>>the code im using is:
>>PHPIniDir "C:/PHP/"
>>LoadModule php5_module "C:/PHP/php5apache2.dll"
>> 
>>__
>> 
>>Subject: Re: [PHP] request for support
>>From: a...@ashleysheridan.co.uk
>>To: stevewiese...@hotmail.com
>>CC: php-general@lists.php.net
>>Date: Tue, 8 Dec 2009 11:45:38 +
>> 
>>On Tue, 2009-12-08 at 11:29 +, Tarek Kaddoura wrote: 
>> 
>> 
>>I'm using PHP 5.2.11 with Apache 2 (and i also tried Apache 
>> 2.2)
>> 
>>However, when I add this entry to my httpd.conf:
>>
>>LoadModule php4_module "C:/Program 
>> Files/php/sapi/php4apache.dll"
>>
>>Apache will crash when trying to start the service.
>>If I comment the line out, Apache starts just fine.
>> 
>>Thanks for your help.
>>Regards, 
>> 
>>
>>Well, you say you've got PHP 5 installed, yet you're trying to
>>load a PHP 4 module in. Which do you want? I don't think
>>Apache can run 4 and 5 at the same time without complications.
>> 
>>Thanks,
>>Ash
>>http://www.ashleysheridan.co.uk
>> 
>> Don't forget to hit reply to all on the list, and try not to top
>> post! :p
>> 
>> What does it say on the command line when you try to start the service
>> up?
>> 
>> In a root privaleged console type:
>> 
>> /etc/init.d/httpd start
>> 
>> 
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>> 
>> No Ashley im using Windows,
>> whenever i start the apache service, it either crashes or promptes me
>> that the operation has failed
>> if i comment these 2 lines out, the apache service starts normally
> 
> Why don't you try a Wamp install, rather than installing the individual
> components?
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

Why don't you check the apache logs to see what's (not) happening?

~Philip



Re: [PHP] Passing HTML array index to JS?

2009-12-07 Thread Philip Thompson
On Dec 7, 2009, at 6:32 PM, Skip Evans wrote:

> Hey Philip,
> 
> But will that ID value identify the right member of each array? I thought 
> about that but just assumed that it would not.
> 
> Skip
> 
> Philip Thompson wrote:
>> On Dec 7, 2009, at 5:02 PM, Skip Evans wrote:
>>> Hey all,
>>> 
>>> I have an HTML field like this
>>> 
>>> >> style="text-align: right;" onblur="calculateBidUnit();">
>>> 
>>> ... and what I need to do is pass to the calculateBidUnit function the 
>>> value of quantity, do a calculation on it and plug into this field.
>>> 
>>> 
>>> 
>>> Which of course I know how to do for non-array values, but not sure how to 
>>> get the values to do the calculation on the JS side if the fields are in an 
>>> array.
>>> 
>>> Any help, as always, is greatly appreciated,
>>> Skip
>> This question is probably more appropriate for a JS list... but I'm not 
>> mean, so I'll let you know. The easiest way would be to update the blur 
>> event qty input:
>> onblur="calculateBidUnit(this.value);"
>> Now you have the value sent to that function. Another way would be to give 
>> your input and output an id each - let's say 'qty' and 'bid_unit_value', 
>> respectively. Then reference those ids in your function. This gives you the 
>> following:
>> > onblur="calculateBidUnit();" id="qty" />
>> 
>> 
>> function calculateBidUnit () {
>>var qty = document.getElementById('qty');
>>var buv = document.getElementById('bid_unit_value');
>>buv.value = qty.value;
>> }
>> 
>> I'll give you a small warning. All browsers are not alike, so my 
>> recommendation would be to use a library that handles the cross-browser 
>> compatibility portion of javascript (I use Mootools). Nonetheless, the above 
>> *should* work. Learning the bare bones of javascript will help with the more 
>> complicated stuff and you'll be smarter for it! =P
>> Hope that helps,
>> ~Philip

Each text input will only contain 1 value... and contain 1 unique "id." So, if 
you have multiple input boxes with the same name (qty[]), only the $_POST 
output will contain an array of each value. See below...








function calc (value) {
document.getElementById('buv').value = value;
}


When you blur qty1, buv will receive the value 1; blur qty2, buv will be 2; and 
so on. The last input box that you blur on will determine buv's final value 
(unless you throw in some logic to handle this)...


function calc (value) {
var buv = document.getElementById('buv');
if (buv.value == '') buv.value = value;
}


So, let's say you blur on qty2 and then submit the form, your PHP script will 
have this in $_POST...

Array
(
[qty] => Array
(
[0] => 1
[1] => 2
[3] => 3
)
[bid_unit_value] => Array
(
[0] => 2
)
)

If this is not what you're wanting, you will need to modify the behavior above. 
If you're wanting the bid_unit_value to contain all the values of each blur, 
you may want to do something like this...


function calc (value) {
var buv = document.getElementById('buv');
if (buv.value == '') buv.value = value;
else buv.value += '|'+value;
}


Which may result from each blur in $_POST to be...

Array
(
[qty] => Array
(
[0] => 1
[1] => 2
[3] => 3
)
[bid_unit_value] => Array
(
[0] => 2|1|3
)
)

Or something along those lines. Then you can just explode() on that first index 
to get individual values. Maybe you can clarify your ultimate goal and we can 
assist you in what the best plan is.

Hope that helps,
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Passing HTML array index to JS?

2009-12-07 Thread Philip Thompson
On Dec 7, 2009, at 5:02 PM, Skip Evans wrote:

> Hey all,
> 
> I have an HTML field like this
> 
>  style="text-align: right;" onblur="calculateBidUnit();">
> 
> ... and what I need to do is pass to the calculateBidUnit function the value 
> of quantity, do a calculation on it and plug into this field.
> 
> 
> 
> Which of course I know how to do for non-array values, but not sure how to 
> get the values to do the calculation on the JS side if the fields are in an 
> array.
> 
> Any help, as always, is greatly appreciated,
> Skip

This question is probably more appropriate for a JS list... but I'm not mean, 
so I'll let you know. The easiest way would be to update the blur event qty 
input:

onblur="calculateBidUnit(this.value);"

Now you have the value sent to that function. Another way would be to give your 
input and output an id each - let's say 'qty' and 'bid_unit_value', 
respectively. Then reference those ids in your function. This gives you the 
following:





function calculateBidUnit () {
var qty = document.getElementById('qty');
var buv = document.getElementById('bid_unit_value');
buv.value = qty.value;
}


I'll give you a small warning. All browsers are not alike, so my recommendation 
would be to use a library that handles the cross-browser compatibility portion 
of javascript (I use Mootools). Nonetheless, the above *should* work. Learning 
the bare bones of javascript will help with the more complicated stuff and 
you'll be smarter for it! =P

Hope that helps,
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] cookies and carts

2009-12-07 Thread Philip Thompson
On Dec 7, 2009, at 4:46 PM, Ashley Sheridan wrote:

> On Mon, 2009-12-07 at 16:48 -0600, Philip Thompson wrote:
>> 
>> On Dec 7, 2009, at 4:40 PM, Ashley Sheridan wrote:
>> 
>> > On Mon, 2009-12-07 at 14:39 -0800, Allen McCabe wrote:
>> > 
>> >> I have a shopping cart type system set up which keeps track of the cart
>> >> contents using a SESSION variable, where $_SESSION['cart'][$item_id'] is
>> >> equal to the quantity, so the name/value pair is all the information I 
>> >> need.
>> >> 
>> >> But sessions are unreliable on the free server I am currently using for 
>> >> this
>> >> website (not my choice), so I had start using cookies because users were
>> >> being sporadically logged out, sometimes just on a page refresh.
>> >> 
>> >> I want to find a way to set a cookie to remember the cart items as well, 
>> >> and
>> >> I thought setting a cookie for each item/quantity pair was the way to go
>> >> until I started trying to figure out how to unset all those cookies if the
>> >> user empties their cart.
>> >> 
>> >> Is there any way to set cookies with an array for the name? Intead of
>> >> $_COOKIE['item_number'] have $_COOKIE['cart']['item_number'] like I have 
>> >> the
>> >> SESSION?
>> > 
>> > 
>> > What about storing a unique ID in the cookie, and matching it up with
>> > information for that user in a database. It's sort of simulating a
>> > sessions, but without the session handler getting involved, which looks
>> > slightly messed up from what you've said.
>> > 
>> > Thanks,
>> > Ash
>> > http://www.ashleysheridan.co.uk
>> 
>> Blast your speedier typing!! =P
>> 
>> ~Philip
>> 
> 
> By the power of Kenco!
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 

I hope you don't kiss your mother with that mouth!!



Re: [PHP] cookies and carts

2009-12-07 Thread Philip Thompson
On Dec 7, 2009, at 4:40 PM, Ashley Sheridan wrote:

> On Mon, 2009-12-07 at 14:39 -0800, Allen McCabe wrote:
> 
>> I have a shopping cart type system set up which keeps track of the cart
>> contents using a SESSION variable, where $_SESSION['cart'][$item_id'] is
>> equal to the quantity, so the name/value pair is all the information I need.
>> 
>> But sessions are unreliable on the free server I am currently using for this
>> website (not my choice), so I had start using cookies because users were
>> being sporadically logged out, sometimes just on a page refresh.
>> 
>> I want to find a way to set a cookie to remember the cart items as well, and
>> I thought setting a cookie for each item/quantity pair was the way to go
>> until I started trying to figure out how to unset all those cookies if the
>> user empties their cart.
>> 
>> Is there any way to set cookies with an array for the name? Intead of
>> $_COOKIE['item_number'] have $_COOKIE['cart']['item_number'] like I have the
>> SESSION?
> 
> 
> What about storing a unique ID in the cookie, and matching it up with
> information for that user in a database. It's sort of simulating a
> sessions, but without the session handler getting involved, which looks
> slightly messed up from what you've said.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

Blast your speedier typing!! =P

~Philip


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



Re: [PHP] cookies and carts

2009-12-07 Thread Philip Thompson
On Dec 7, 2009, at 4:39 PM, Allen McCabe wrote:

> I have a shopping cart type system set up which keeps track of the cart
> contents using a SESSION variable, where $_SESSION['cart'][$item_id'] is
> equal to the quantity, so the name/value pair is all the information I need.
> 
> But sessions are unreliable on the free server I am currently using for this
> website (not my choice), so I had start using cookies because users were
> being sporadically logged out, sometimes just on a page refresh.
> 
> I want to find a way to set a cookie to remember the cart items as well, and
> I thought setting a cookie for each item/quantity pair was the way to go
> until I started trying to figure out how to unset all those cookies if the
> user empties their cart.
> 
> Is there any way to set cookies with an array for the name? Intead of
> $_COOKIE['item_number'] have $_COOKIE['cart']['item_number'] like I have the
> SESSION?

Don't do it this way. At some point (don't know if it's still true), IE had a 
limit of 20 cookies per domain - this includes cookie arrays. The proper way to 
do this would be to hold some sort of key in a cookie:

user_cart = 'some unique value for this user'

Then, in your PHP code, grab the value of $_COOKIE['user_cart'] to reference 
data in a database. Then, you pull the information from the database with this 
unique key and use it to display the appropriate items. This is the most secure 
way to do it (with the proper security measures ;) and it doesn't put 100's of 
needless cookies on the user's machine.

Hope this helps.
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP+Firebird numeric format problem

2009-11-30 Thread Philip Thompson
On Nov 30, 2009, at 5:37 AM, helderfelipe wrote:

> I have a query who is returning a NUMERIC(18,8) column.
> 
> In the IBExpert, te resultset is:
> 
> 30,9127
> 836,5800
> 
> But PHP returns in a strange format:
> 
> 3.9127
> 83.65800
> 
> Somebody help ?

That "strange format" you're referring to looks like US_EN locale (or similar). 
I'm guessing you're not from the U.S.? =D If you need to reformat the output, 
consider

http://php.net/number_format

Hope that helps.
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] function not returning query

2009-11-25 Thread Philip Thompson
On Nov 25, 2009, at 4:32 AM, Ashley Sheridan wrote:

> On Tue, 2009-11-24 at 23:27 -0800, Allen McCabe wrote:
> 
>> If I were to loop through my inputs, I could just exclude any
>> problematic names, eg.:
>> 
>> foreach ($_POST as $var = $val)
>> {
>>   if ($var != filter.x || $var != filter.y)
>>  {
>>$var = $val;
>>  }
>> }
>> 
>> Like that?



> Not really, what if someone else decided they wanted to throw in their
> own form field values in the hope of breaking your system? It's much
> better to be specifically looking for certain form fields and certain
> field values/ranges. For example, if you had some fields that would
> filter something by cost, you might have two form fields named 'max' and
> 'min' which would be ranges for the cost. You should check that these
> fields only contain numbers for example before processing them. Any data
> coming from the client-side is untrustworthy and should be regarded as
> tainted until you can prove otherwise.
> 
> Thanks,
> Ash

The system Ash is referring to is a whitebox approach. You know what you should 
get in, so only accept those values. A simple thing to accomplish what you're 
trying to do, Allen, would be to create an array of required/accepted fields...

 $val) {
if (in_array ($var, $acceptable)) {
// Do whatever here
} else {
// Not acceptable - throw error message or do nothing
}
}
?>

Hope that helps.
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Query based on Server offset TimeStamp

2009-11-23 Thread Philip Thompson
On Nov 23, 2009, at 7:37 PM, Don Wieland wrote:

> Hello,
> 
> I have a mySQL database server in Florida USA (EST) and I want to do a query 
> on a record in California, USA (PST) 3 hours earlier using PST instead of EST.
> 
> I would like to add to my CORE page that offset of the timezone so I can use 
> it in a query like:
> 
> Select * FROM aTable WHERE ServerOffsetTimeStap >= Row_Start_TimeStamp AND 
> ServerOffsetTimeStap <= Row_End_TimeStamp
> 
> How would I do this?
> 
> Appreciate any help you can offer. Thanks!

When I store timestamps, I store them in GMT time. This way, no matter when you 
pull it out of the database, you *know* when it was stored - even in a 
different timezone. To achieve this...



Maybe this will make it a little easier to query accordingly...? Hope this 
stirs your brain.

~Philip

PS... Others may profess that you use UTC instead of GMT, but that's a 
different thread.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] function not returning query

2009-11-23 Thread Philip Thompson
On Nov 23, 2009, at 6:22 PM, Allen McCabe wrote:

> Hi, thanks for reading, I hope you can help:
> 
> In my main file for an orders page I have the following code:
> 
> 
> if (isset($_GET['filterby']))
> {
>  $resultOrders = adminFilterQuery();
>  $numberOfOrders = mysql_num_rows($resultOrders);
> }
> else
> {
>  $resultOrders = mysql_query("SELECT * FROM afy_order;") or
> die(mysql_error("Could not query the database!"));
>  $numberOfOrders = mysql_num_rows($resultOrders);
> }

You reduce this part by one line by putting the following after the else 
statement and removing the other 2:

$numberOfOrders = mysql_num_rows ($resultOrders);

Also, these queries don't need a semi-colon (;) to end the query. PHP handles 
this part. Remove them.


> adminFilterQuery() is a custom function that is supposed to return a
> mysql_query, here are the last few lines of this function:
> 
> 
> $query = "SELECT * FROM afy_order WHERE school_id = '{$school}' ORDER BY
> {$order_by_param};";
> $result = mysql_query($query);
> return $result;
> 
> l am getting this error when I try to filter my query using a form in tandem
> with the quey building function:
> 
> *Warning*: mysql_num_rows(): supplied argument is not a valid MySQL result
> resource
> 
> where the line is the one where I use the mysql_num_rows function.
> 
> What am I missing here?
> 
> Thanks!

Do you get this warning with both queries? Make sure that your queries are 
using a valid mysql connection. You may also consider using a database class to 
perform the repetitive tasks so that you really only have to be concerned with 
the queries you're writing...?

query('SELECT * FROM afy_order');
$numRows = $db->numRows($result);
?>

Of course this is just a simple example, but you get the idea. Hope that stirs 
your brain!

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



Re: [PHP] It's not behaving. Error reporting, that is

2009-11-04 Thread Philip Thompson

On Nov 3, 2009, at 11:24 AM, Kim Madsen wrote:


Hi Philip

Try to post a link to a page, that prints phpinfo()

--  
Kind regards

Kim Emax

Philip Thompson wrote on 2009-11-03 17:11:

Hi all.
This seems like a trivial issue to fix, but I'm having issues. I'm  
running a script via command line and it's throwing out PHP  
"notices." Well, I want to suppress those notices. At the top of my  
script I have the line...


...thinking that this would get rid of the notices. However, it did  
not. They still appear. I even attempted using ini_set(), but to no  
avail. I then set error_reporting in php.ini - this made no  
difference. (I shouldn't have to restart apache when running via  
command line, but for giggles, I did.) I then changed  
display_errors to Off. You guessed it - no change! This immediately  
brought up the question... "Well, what php.ini is this script  
using?" Here's my results...

[pthomp...@s-irv-pthompson scripts]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
...
Yup, according to PHP I'm using the correct ini. Now I'm at a loss.  
Can anyone shed some light on this big brain fart I'm having?  
Thanks in advance.

~Philip



--
Kind regards
Kim Emax - masterminds.dk


That's all good and dandy. But this is a cli application. And besides,  
the computer is not accessible via the Internet.


Thanks,
~Philip

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



[PHP] It's not behaving. Error reporting, that is

2009-11-03 Thread Philip Thompson

Hi all.

This seems like a trivial issue to fix, but I'm having issues. I'm  
running a script via command line and it's throwing out PHP "notices."  
Well, I want to suppress those notices. At the top of my script I have  
the line...




...thinking that this would get rid of the notices. However, it did  
not. They still appear. I even attempted using ini_set(), but to no  
avail. I then set error_reporting in php.ini - this made no  
difference. (I shouldn't have to restart apache when running via  
command line, but for giggles, I did.) I then changed display_errors  
to Off. You guessed it - no change! This immediately brought up the  
question... "Well, what php.ini is this script using?" Here's my  
results...


[pthomp...@s-irv-pthompson scripts]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
...

Yup, according to PHP I'm using the correct ini. Now I'm at a loss.  
Can anyone shed some light on this big brain fart I'm having? Thanks  
in advance.


~Philip

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



Re: [PHP] Limit query/function time

2009-10-22 Thread Philip Thompson

On Oct 22, 2009, at 3:30 PM, Phpster wrote:


Have you run an explain plan on the query?

Bastien

Sent from my iPod


Yes, I have. For giggles, I wanted to run it again. Here it is  
(slightly stripped down) and it looks good to me.


mysql> EXPLAIN SELECT
-> `p`.`patient_id`,
-> `p`.`address_id`,
-> `p`.`patient_sub_id`,
-> AES_DECRYPT(`p`.`patient_first_name`, 'hidden_key') AS  
`patient_first_name`,
-> AES_DECRYPT(`p`.`patient_last_name`, 'hidden_key') AS  
`patient_last_name`,
-> AES_DECRYPT(`p`.`patient_middle_name`, 'hidden_key') AS  
`patient_middle_name`,

-> AES_DECRYPT(`p`.`patient_dob`, 'hidden_key') AS `patient_dob`
-> FROM `patient` `p`
-> INNER JOIN `center_patient` `cp` ON `p`.`patient_id` =  
`cp`.`patient_id`
-> WHERE ((`p`.`patient_id` = '256783' OR `p`.`patient_sub_id` =  
'256783') AND `cp`.`center_id` = '109')

-> ORDER BY `patient_id` DESC;
++-++-- 
+--+
| id | key_len | ref| rows |  
Extra|
++-++-- 
+--+
|  1 | 4,4 | NULL   |2 | Using union 
(PRIMARY,patient_sub_id); Using where; Using filesort |
|  1 | 8   | p.patient_id,const |1 | Using  
index  |
++-++-- 
+--+

2 rows in set (0.00 sec)

There are about 350,000 records in `patient` and `center_patient`  
tables. The average number of rows returned from this query is less  
than 5.


~Philip


On Oct 22, 2009, at 4:14 PM, Philip Thompson  
 wrote:



Hi all.

I'm running into a random issue where sometimes it take several  
minutes (up to 10 or 15) to complete a query. According to 1 or 2  
references, this may be a mysql bug. These links explain the  
similar problem I'm experiencing:


http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully  
queried (in milliseconds) approximately 50,000 times before it took  
several minutes to query, which hung all the other processes on the  
database. Because it occurs successfully so many times, I know the  
query is good.


Is it possible to set a time limit on a single function in PHP?  
E.g., when I call mysql_query() and it takes 30 seconds, then quit  
processing that function and continue on. I know I could  
set_time_limit() to a specific time, but that would cause a fatal  
error... and I want to be able to catch it.


Any thoughts on what direction I should go? Also, I'm going to do  
some research to see if a newer version of mysql has fixed this  
bug. We're running 5.0.45.


Thanks,
~Philip


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



Re: [PHP] Limit query/function time

2009-10-22 Thread Philip Thompson

On Oct 22, 2009, at 3:26 PM, Eddie Drapkin wrote:

On Thu, Oct 22, 2009 at 4:14 PM, Philip Thompson > wrote:

Hi all.

I'm running into a random issue where sometimes it take several  
minutes (up
to 10 or 15) to complete a query. According to 1 or 2 references,  
this may
be a mysql bug. These links explain the similar problem I'm  
experiencing:


http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully  
queried
(in milliseconds) approximately 50,000 times before it took several  
minutes
to query, which hung all the other processes on the database.  
Because it

occurs successfully so many times, I know the query is good.

Is it possible to set a time limit on a single function in PHP?  
E.g., when I

call mysql_query() and it takes 30 seconds, then quit processing that
function and continue on. I know I could set_time_limit() to a  
specific
time, but that would cause a fatal error... and I want to be able  
to catch

it.

Any thoughts on what direction I should go? Also, I'm going to do  
some

research to see if a newer version of mysql has fixed this bug. We're
running 5.0.45.

Thanks,
~Philip


You could use ErrorException and catch that:
http://www.php.net/manual/en/class.errorexception.php
Or you could just set your own error handler:
http://www.php.net/manual/en/function.set-error-handler.php

Something I don't know if you've thought of that came to mind, though,
is the MySQL query cache.  It's entirely likely that you have a query
that takes several minutes to run, then is stored in query cache for
the next 50,000 iterations of the query.  Have you observed this same
behavior without the query cache enabled (it also looks like the bug
mentioned in the second link - the one that pertains to the 5.0.x
branch of mysql - has to do with an overly large query cache)?  Based
on that post, I'd guess that your next action would be to disable the
query cache and determine from there if it's a slow query or actually
the bug in MySQL.


I didn't think you could catch fatal errors - isn't that why they're  
fatal?


I will check into the query cache thing. However, the query that I'm  
running isn't exactly the same each time. Each iteration has a  
different ID value in the WHERE clause.


Thank you,
~Philip



[PHP] Limit query/function time

2009-10-22 Thread Philip Thompson

Hi all.

I'm running into a random issue where sometimes it take several  
minutes (up to 10 or 15) to complete a query. According to 1 or 2  
references, this may be a mysql bug. These links explain the similar  
problem I'm experiencing:


http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully  
queried (in milliseconds) approximately 50,000 times before it took  
several minutes to query, which hung all the other processes on the  
database. Because it occurs successfully so many times, I know the  
query is good.


Is it possible to set a time limit on a single function in PHP? E.g.,  
when I call mysql_query() and it takes 30 seconds, then quit  
processing that function and continue on. I know I could set_time_limit 
() to a specific time, but that would cause a fatal error... and I  
want to be able to catch it.


Any thoughts on what direction I should go? Also, I'm going to do some  
research to see if a newer version of mysql has fixed this bug. We're  
running 5.0.45.


Thanks,
~Philip

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



Re: [PHP] Spam opinions please

2009-10-22 Thread Philip Thompson

On Oct 20, 2009, at 1:48 PM, Gary wrote:

NO I have not, I think my issue is I hate when I run across one, it  
usually
takes me more than one try to actually figure out what the charactor  
is, so

hence my disdain.


GAry


Here are some captchas:

"What's three minus two?"
"Which word is listed first in the dictionary: apple, banana, pizza?"
"Add 4 plus 5"

Create a list of simple questions that only humans can answer. I find  
these to be less annoying.


~Philip



"Paul M Foster"  wrote in message
news:20091020184001.gi3...@quillandmouse.com...

On Tue, Oct 20, 2009 at 02:31:53PM -0400, Gary wrote:

I have several sites that are getting hit with form spam.  I have  
the

script
set up to capture the IP address so I know from where they come.   
I found

a
short script that is supposed to stop these IP addresses from  
accessing

the
form page, it redirects the spammer to another page (I was going to
redirect
to a page that has lots of pop-ups, scantily clad men and offers  
of joy

beyond imagination), but someone suggested I redirect to the Federal
Trade
Commission or perhpas the FBI.

Any thoughts on the script and its effectivness?

http://www.google.com/";);
  exit();
} ?>Gary



Have you tried CAPTCHA?

Paul


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



Re: [PHP] Please don't kick me!

2009-10-22 Thread Philip Thompson

On Oct 20, 2009, at 3:44 PM, Kim Madsen wrote:


Philip Thompson wrote on 2009-10-20 21:58:

I got it to draw the different background colors successfully.  
However, drawing borders is not as straight forward. I'm sure I  
could get it working as well... but I'd rather it work *out of the  
box*. Thanks for the suggestion. ;)


Well, you're always welcome to contribute to an open source project  
you take advantage of ;o)


Tis true. However, my passion does not include creating a better PDF  
generator. After doing a lil bit more research, I came across this one  
and I really like it so far.


http://realobjects.com/PDFreactor.939.0.html

It's definitely not free, but it seems to do what I need... so far.

Thanks,
~Philip


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



Re: [PHP] Please don't kick me!

2009-10-20 Thread Philip Thompson

On Oct 20, 2009, at 2:40 PM, Floyd Resler wrote:

As far as I know ezPDF can't do what you want it to do.  Of course,  
you could always modify the code the suite your needs.  Since it  
already draws tables it probably wouldn't be too difficult to modify  
it draw row backgrounds of different colors.


Take care,
Floyd


I got it to draw the different background colors successfully.  
However, drawing borders is not as straight forward. I'm sure I could  
get it working as well... but I'd rather it work *out of the box*.  
Thanks for the suggestion. ;)


~Phil



On Oct 20, 2009, at 3:25 PM, Philip Thompson wrote:


On Oct 19, 2009, at 4:21 PM, Floyd Resler wrote:

Nope.  I've never had any troubles with it.  I've been able to  
produce all kinds of PDFs including loan agreements, inventory  
pick lists with barcodes, and various others.  I find it  
incredibly powerful and easy to use.


Take care,
Floyd


Sorry if this is slightly OT.

I've been messing around with ezPdf for a little bit and it doesn't  
appear to be able to allow for custom background colors or borders  
on a per-row basis. Meaning, I have the option to color every other  
line a single color... but I can't color every line a different  
color if I want. Am I missing something here?


Basically, with the reports I'm currently generating, every row  
could be a different color than the previous - it depends on  
various factors. This is easy to accomplish with HTML/CSS. If this  
isn't possible (or at least easily-accomplishable), then ezPdf may  
not be for me.


Thanks,
~Philip


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



Re: [PHP] Please don't kick me!

2009-10-20 Thread Philip Thompson

On Oct 19, 2009, at 4:21 PM, Floyd Resler wrote:

Nope.  I've never had any troubles with it.  I've been able to  
produce all kinds of PDFs including loan agreements, inventory pick  
lists with barcodes, and various others.  I find it incredibly  
powerful and easy to use.


Take care,
Floyd


Sorry if this is slightly OT.

I've been messing around with ezPdf for a little bit and it doesn't  
appear to be able to allow for custom background colors or borders on  
a per-row basis. Meaning, I have the option to color every other line  
a single color... but I can't color every line a different color if I  
want. Am I missing something here?


Basically, with the reports I'm currently generating, every row could  
be a different color than the previous - it depends on various  
factors. This is easy to accomplish with HTML/CSS. If this isn't  
possible (or at least easily-accomplishable), then ezPdf may not be  
for me.


Thanks,
~Philip

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



Re: [PHP] Get rid of warning massage

2009-10-20 Thread Philip Thompson

On Oct 20, 2009, at 10:34 AM, resea soul wrote:


Hi,

I'm using the function file_get_contents($url). If the url is  
invalid the

function displays a warning message while I am using my own customized
message. I want to get rid of the warning message.

Thank you


@file_get_contents(...)



Re: [PHP] Please don't kick me!

2009-10-19 Thread Philip Thompson

On Oct 19, 2009, at 3:52 PM, Floyd Resler wrote:


Phillip,
	I use ezpdf (http://www.ros.co.nz/pdf/).  I've been using it for  
years and have found it very capable of making any PDF I want.


Take care,
Floyd


This one seems fairly neat. However, it appears as though the author  
no longer keeps up with it - last entry on 6/17/2006. Have you ever  
run into any problems or setbacks with it?


Thanks,
~Philip

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



[PHP] Please don't kick me!

2009-10-19 Thread Philip Thompson

Hi all.

I know this question has been asked a thousand times on the list, but  
my searches in the archives are not being nice to me. So... please  
don't kick me.


Currently, we use DOMPDF to generate PDFs from HTML. However, it's no  
longer maintained and it has a few bugs that we just can no longer  
live with. What PDF generating software do you use? It does not have  
to be free, but it must run on linux and may be command line or run  
through code. Some of the ones I have researched are...


html2pdf
html2ps
html2fpdf
xhtml2pdf
fpdf
tcpdf

You're thoughts would be appreciated. Oh, my preference would be to  
send HTML/CSS to a script and it just automagically convert to PS/PDF.


Thanks,
~Philip

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



Re: [PHP] Need unrounded precision

2009-10-14 Thread Philip Thompson

On Oct 12, 2009, at 2:37 PM, Andrea Giammarchi wrote:

bitwise right shift is probably the fastest cast to int so far ...  
still in many languages, intval is a function call


being a cast in both cases (int) is good as well ... bitwise,  
casting, works with strings, arrays, boolean, whatever as well.


I don't think there is any difference in php, except when the  
integer is "too big" ... but this was not the case, we had to deal  
with 1 to 10 :-)


Regards


From: jbo...@mindsites.com
To: an_...@hotmail.com
CC: php-general@lists.php.net
Date: Mon, 12 Oct 2009 11:33:10 -0500
Subject: RE: [PHP] Need unrounded precision


Hmmm... Didn't think about this, but % only works with int values


it was just future prof precaution since this statement is false  
for many other languages.

In few words I am not sure PHP6 does the same ... never mind so far


Good to know.  In that case, I would probably just use intval()  
instead of >> since it's clearer and bitwise shifts aren't  
necessarily integer only either.


Jaime


I like the bitwise shifting, but here's another potential (albeit  
probably slower) solution.


$a = 28.56018;
list (,$dec) = explode ('.', $a);
$b = $dec{0};

Cheers,
~Philip

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



Re: [PHP] Re: ternary operator sintax help

2009-10-06 Thread Philip Thompson

On Oct 6, 2009, at 2:26 PM, MEM wrote:


Sorry all,
It's ok. The sintax:

'.$erros['anexo'].'' :''); ?>

Was right all the time.

Anyway, I've learn something new: having a var with '' is not the  
same thing
as not been unset. So we must pay attention on what cases we use  
isset, or

!empty.


Thanks a lot,
Márcio


-Original Message-
From: João Cândido de Souza Neto [mailto:j...@consultorweb.cnt.br]
Sent: terça-feira, 6 de Outubro de 2009 19:53
To: php-general@lists.php.net
Subject: [PHP] Re: ternary operator sintax help

'.$erros['anexo'].'' :''); ?>

""MEM""  escreveu na mensagem
news:002401ca46b4$ed6ad6a0$c84083...@com...
Hello all,

I'm trying to display a div, only when some php value is set.
Since this will be near html, I'd like to keep it on one line. So,  
I'd

love
to use shortcuts and a ternary operator for the effect.

I'm having something like this right now, but the div still appears
even if
the error is NOT set.

'
.$erros['anexo'].'' :''; ?>

:(

Can I have your help with the right syntax ?


Another one to consider...

strlen ($item) > 0 ? 'not empty' : 'empty';

Because "empty()" will return true if 0 is the value, sometimes you  
have to check for the length of the item.


~Philip


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



Re: [PHP] Self-Process php forms or not?

2009-10-06 Thread Philip Thompson

On Oct 5, 2009, at 7:42 PM, Manuel Lemos wrote:


Hello,

on 10/05/2009 03:02 PM Philip Thompson said the following:

I try to avoid the use of hidden form elements as much as possible,
especially for tracking whether a user has submitted a form or  
not...


I use name="submit" for the submit button instead, that will pass  
the

value of the submit button to the action script.

above all i use a template engine, smarty to take care of the
presentation for me(like deciding whether to show the form and/or a
success/failure message)


That only works if the user clicks on that submit button. If the  
user
hits the enter key in a text input, the form is submitted but the  
submit

input variable is not set. That is why an hidden input is a safer
solution.


If you need the button to be *clicked*...



Or something along those lines.


That does not make much sense and is pointless. First that syntax you
mentioned probably requires JQuery or some other large Javascript
library. something like this['submitButton'].click() would emulate the
click event. Second, by the time that onsubmit is called, the event  
that

triggered it was already dispatched. Emulating the click on a button
would probably fire the form submission and onsubmit code would be run
again, leading to an infinite loop sucking machine CPU.


It makes perfect sense and is not pointless. Yes, it is library- 
specific javascript. However, it was used to show an example and make  
a point. I assume that most the subscribers here are able to decipher  
the code and determine what the intent was. And no, this will not  
cause an infinite loop. The onsubmit is called first and will process  
whatever action you specify, and then move on. *If* the submit button  
wasn't *clicked* and you needed it to be, then this would emulate that  
functionality. I'm not saying this is the best solution on how to deal  
with the previous question but it is *a* solution.


Here's some code that you can see there's no infinite loop and shows  
which events are called first.


--



loop? i don't think so


Times submitted: 

name="theForm" onsubmit="document.getElementById('submitBtn').click();  
return false;">


>




document.theForm.text.focus();


--

The above code works as expected in Safari 4.0.3, FF3.5.3 and IE8.

Cheers,
~Philip

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



Re: [PHP] Self-Process php forms or not?

2009-10-05 Thread Philip Thompson

On Oct 2, 2009, at 3:00 AM, Manuel Lemos wrote:


Hello,

on 10/02/2009 04:41 AM kranthi said the following:

I try to avoid the use of hidden form elements as much as possible,
especially for tracking whether a user has submitted a form or not...

I use name="submit" for the submit button instead, that will pass the
value of the submit button to the action script.

above all i use a template engine, smarty to take care of the
presentation for me(like deciding whether to show the form and/or a
success/failure message)


That only works if the user clicks on that submit button. If the user
hits the enter key in a text input, the form is submitted but the  
submit
input variable is not set. That is why an hidden input is a safer  
solution.


If you need the button to be *clicked*...



Or something along those lines.

~Philip

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



Re: [PHP] Where's my memory going?!

2009-09-30 Thread Philip Thompson

On Sep 29, 2009, at 6:15 PM, Eddie Drapkin wrote:


On Tue, Sep 29, 2009 at 6:51 PM, Jim Lucas  wrote:

Philip Thompson wrote:

On Sep 29, 2009, at 4:38 PM, Jim Lucas wrote:


Philip Thompson wrote:

On Sep 28, 2009, at 4:40 PM, jeff brown wrote:

Yes, that's the best way to clean up after yourself.  And you  
really

should use that on anything you have sitting around daemon like.

Jeff

Philip Thompson wrote:

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:
well this sound clearly to me like you are not freeing  
resultsets
you are not going to use anymore. In long scripts you have to  
take

care of this. on short scripts you can be a bit weak on that,
because the resultsets are closed and freed on script ending.

assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message
news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com...

Hi all.

I have a script that opens a socket, creates a persistent  
mysql
connection, and loops to receive data. When the amount of  
specified
data has been received, it calls a class which processes the  
data

and
inserts it into the database. Each iteration, I unset/ 
destruct that

class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on  
where to

start to see where I'm losing my memory?

Thanks in advance,
~Philip
I am not using mysql_free_result(). Is that highly recommended  
by all?

Thanks,
~Philip


I took your suggestions and made sure to clean up after myself.  
I'm

running into something that *appears* to be a bug with
mysql_free_result(). Here's a snippet of my db class.

query($sql);
   echo "Memory usage after  query: " . number_format
(memory_get_usage ()) . "\n";

   if (!$assoc) { $result = $this->fetch_row($resultSet); }
   else {
   $result = $this->fetch_array($resultSet);
   echo "Memory usage after  fetch: " . number_format
(memory_get_usage ()) . "\n";
   }

   $this->freeResult($resultSet);
   echo "Memory usage after   free: " . number_format
(memory_get_usage ()) . "\n";

   return $result;
   }

   function freeResult ($result)
   {
   if (is_resource ($result)) {
   if (!mysql_free_result ($result)) { echo "Memory  
could not

be freed\n"; }
   }
   unset ($result); // For good measure
   }

   function fetch_row ($set) {
   return mysql_fetch_row ($set);
   }

   function fetch_array ($set) {
   return mysql_fetch_array ($set, MYSQL_ASSOC);
   }
}

// I seem to be losing memory when I call this
$db->fetch($sql);
?>

The result I get with this is...

Memory usage before query: 6,406,548
Memory usage after  query: 6,406,548
Memory usage after  fetch: 6,406,548
Memory usage after   free: 6,406,572

As you may notice, the memory actually goes UP after the  
*freeing* of
memory. Why is this happening?! What have I done wrong? Is this  
a bug?

Any thoughts would be appreciated.



First off, my question would be, is your query actually working?
Because I
would imagine that if you were getting results back from the DB,  
that

the amount
of memory being used would increase between step 1 & 2.

Check to make sure that you are getting results.


I'm confident the queries are working (there's many of them and I  
know

the data they're returning is correct), but they may not always be
returning results. The memory value does change in some instances...

Memory usage before query: 5,138,372
Memory usage after  query: 5,138,396
Memory usage after   free: 5,138,556

This was one that use fetch_row() instead of fetch_array(), but  
the same
difference. I did some searching around and I think it's a bug in  
PHP
and/or Zend Memory Management engine. As I mentioned in a previous  
post
about mysql_query() not allocating memory appropriately, I believe  
this

could quite possibly be the case. Several people have reported bugs
similar to this... unfortunately, they are marked as (erroneously?)
bogus or said it has been fixed (when, IMO, it has not).

http://bugs.php.net/bug.php?id=40883
http://bugs.php.net/bug.php?id=28424
http://bugs.php.net/bug.php?id=41871

I'm using version 5.2.6 on Fedora 8 and the bug still appears to be
there. I think I'm going to take a different approach to fix this.  
I'll
create a shell script to loop and invoke the socket listener  
script, and

when it gathers data, call the import script. This way, the php
script(s) will end execution after each iteration and release the
memory. Is this reasonable?

This has been a long day. Thanks for your input. Any more thoughts  
are

welcome.

~Philip



Doesn't PHP only give back a "pointer" back from MySQL when it runs  
a query?
Then what PHP does is uses that "pointer" to mysql to request the  
next 

Re: [PHP] Where's my memory going?!

2009-09-30 Thread Philip Thompson

On Sep 29, 2009, at 5:51 PM, Jim Lucas wrote:


Philip Thompson wrote:

On Sep 29, 2009, at 4:38 PM, Jim Lucas wrote:


Philip Thompson wrote:

On Sep 28, 2009, at 4:40 PM, jeff brown wrote:

Yes, that's the best way to clean up after yourself.  And you  
really

should use that on anything you have sitting around daemon like.

Jeff

Philip Thompson wrote:

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:
well this sound clearly to me like you are not freeing  
resultsets
you are not going to use anymore. In long scripts you have to  
take

care of this. on short scripts you can be a bit weak on that,
because the resultsets are closed and freed on script ending.

assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message
news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com...

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of  
specified
data has been received, it calls a class which processes the  
data

and
inserts it into the database. Each iteration, I unset/ 
destruct that

class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on  
where to

start to see where I'm losing my memory?

Thanks in advance,
~Philip
I am not using mysql_free_result(). Is that highly recommended  
by all?

Thanks,
~Philip


I took your suggestions and made sure to clean up after myself. I'm
running into something that *appears* to be a bug with
mysql_free_result(). Here's a snippet of my db class.

query($sql);
  echo "Memory usage after  query: " . number_format
(memory_get_usage ()) . "\n";

  if (!$assoc) { $result = $this->fetch_row($resultSet); }
  else {
  $result = $this->fetch_array($resultSet);
  echo "Memory usage after  fetch: " . number_format
(memory_get_usage ()) . "\n";
  }

  $this->freeResult($resultSet);
  echo "Memory usage after   free: " . number_format
(memory_get_usage ()) . "\n";

  return $result;
  }

  function freeResult ($result)
  {
  if (is_resource ($result)) {
  if (!mysql_free_result ($result)) { echo "Memory could  
not

be freed\n"; }
  }
  unset ($result); // For good measure
  }

  function fetch_row ($set) {
  return mysql_fetch_row ($set);
  }

  function fetch_array ($set) {
  return mysql_fetch_array ($set, MYSQL_ASSOC);
  }
}

// I seem to be losing memory when I call this
$db->fetch($sql);
?>

The result I get with this is...

Memory usage before query: 6,406,548
Memory usage after  query: 6,406,548
Memory usage after  fetch: 6,406,548
Memory usage after   free: 6,406,572

As you may notice, the memory actually goes UP after the  
*freeing* of
memory. Why is this happening?! What have I done wrong? Is this a  
bug?

Any thoughts would be appreciated.



First off, my question would be, is your query actually working?
Because I
would imagine that if you were getting results back from the DB,  
that

the amount
of memory being used would increase between step 1 & 2.

Check to make sure that you are getting results.


I'm confident the queries are working (there's many of them and I  
know

the data they're returning is correct), but they may not always be
returning results. The memory value does change in some instances...

Memory usage before query: 5,138,372
Memory usage after  query: 5,138,396
Memory usage after   free: 5,138,556

This was one that use fetch_row() instead of fetch_array(), but the  
same

difference. I did some searching around and I think it's a bug in PHP
and/or Zend Memory Management engine. As I mentioned in a previous  
post
about mysql_query() not allocating memory appropriately, I believe  
this

could quite possibly be the case. Several people have reported bugs
similar to this... unfortunately, they are marked as (erroneously?)
bogus or said it has been fixed (when, IMO, it has not).

http://bugs.php.net/bug.php?id=40883
http://bugs.php.net/bug.php?id=28424
http://bugs.php.net/bug.php?id=41871

I'm using version 5.2.6 on Fedora 8 and the bug still appears to be
there. I think I'm going to take a different approach to fix this.  
I'll
create a shell script to loop and invoke the socket listener  
script, and

when it gathers data, call the import script. This way, the php
script(s) will end execution after each iteration and release the
memory. Is this reasonable?

This has been a long day. Thanks for your input. Any more thoughts  
are

welcome.

~Philip



Doesn't PHP only give back a "pointer" back from MySQL when it runs  
a query?
Then what PHP does is uses that "pointer" to mysql to request the  
next row of

results?

Couldn't you use the unbuffered-query function for this?

htt

Re: [PHP] Where's my memory going?!

2009-09-29 Thread Philip Thompson

On Sep 29, 2009, at 4:38 PM, Jim Lucas wrote:


Philip Thompson wrote:

On Sep 28, 2009, at 4:40 PM, jeff brown wrote:


Yes, that's the best way to clean up after yourself.  And you really
should use that on anything you have sitting around daemon like.

Jeff

Philip Thompson wrote:

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:

well this sound clearly to me like you are not freeing resultsets
you are not going to use anymore. In long scripts you have to take
care of this. on short scripts you can be a bit weak on that,
because the resultsets are closed and freed on script ending.

assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message
news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com...

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of  
specified
data has been received, it calls a class which processes the  
data and
inserts it into the database. Each iteration, I unset/destruct  
that

class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on  
where to

start to see where I'm losing my memory?

Thanks in advance,
~Philip
I am not using mysql_free_result(). Is that highly recommended by  
all?

Thanks,
~Philip


I took your suggestions and made sure to clean up after myself. I'm
running into something that *appears* to be a bug with
mysql_free_result(). Here's a snippet of my db class.

query($sql);
   echo "Memory usage after  query: " . number_format
(memory_get_usage ()) . "\n";

   if (!$assoc) { $result = $this->fetch_row($resultSet); }
   else {
   $result = $this->fetch_array($resultSet);
   echo "Memory usage after  fetch: " . number_format
(memory_get_usage ()) . "\n";
   }

   $this->freeResult($resultSet);
   echo "Memory usage after   free: " . number_format
(memory_get_usage ()) . "\n";

   return $result;
   }

   function freeResult ($result)
   {
   if (is_resource ($result)) {
   if (!mysql_free_result ($result)) { echo "Memory could not
be freed\n"; }
   }
   unset ($result); // For good measure
   }

   function fetch_row ($set) {
   return mysql_fetch_row ($set);
   }

   function fetch_array ($set) {
   return mysql_fetch_array ($set, MYSQL_ASSOC);
   }
}

// I seem to be losing memory when I call this
$db->fetch($sql);
?>

The result I get with this is...

Memory usage before query: 6,406,548
Memory usage after  query: 6,406,548
Memory usage after  fetch: 6,406,548
Memory usage after   free: 6,406,572

As you may notice, the memory actually goes UP after the *freeing* of
memory. Why is this happening?! What have I done wrong? Is this a  
bug?

Any thoughts would be appreciated.



First off, my question would be, is your query actually working?   
Because I
would imagine that if you were getting results back from the DB,  
that the amount

of memory being used would increase between step 1 & 2.

Check to make sure that you are getting results.


I'm confident the queries are working (there's many of them and I know  
the data they're returning is correct), but they may not always be  
returning results. The memory value does change in some instances...


Memory usage before query: 5,138,372
Memory usage after  query: 5,138,396
Memory usage after   free: 5,138,556

This was one that use fetch_row() instead of fetch_array(), but the  
same difference. I did some searching around and I think it's a bug in  
PHP and/or Zend Memory Management engine. As I mentioned in a previous  
post about mysql_query() not allocating memory appropriately, I  
believe this could quite possibly be the case. Several people have  
reported bugs similar to this... unfortunately, they are marked as  
(erroneously?) bogus or said it has been fixed (when, IMO, it has not).


http://bugs.php.net/bug.php?id=40883
http://bugs.php.net/bug.php?id=28424
http://bugs.php.net/bug.php?id=41871

I'm using version 5.2.6 on Fedora 8 and the bug still appears to be  
there. I think I'm going to take a different approach to fix this.  
I'll create a shell script to loop and invoke the socket listener  
script, and when it gathers data, call the import script. This way,  
the php script(s) will end execution after each iteration and release  
the memory. Is this reasonable?


This has been a long day. Thanks for your input. Any more thoughts are  
welcome.


~Philip

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



Re: [PHP] Where's my memory going?!

2009-09-29 Thread Philip Thompson

On Sep 29, 2009, at 3:23 PM, Philip Thompson wrote:


On Sep 29, 2009, at 3:07 PM, jeff brown wrote:


Philip Thompson wrote:

On Sep 28, 2009, at 4:40 PM, jeff brown wrote:
Yes, that's the best way to clean up after yourself.  And you  
really should use that on anything you have sitting around daemon  
like.


Jeff

Philip Thompson wrote:

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:
well this sound clearly to me like you are not freeing  
resultsets you are not going to use anymore. In long scripts  
you have to take care of this. on short scripts you can be a  
bit weak on that, because the resultsets are closed and freed  
on script ending.


assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com 
...

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of  
specified
data has been received, it calls a class which processes the  
data and
inserts it into the database. Each iteration, I unset/destruct  
that

class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on  
where to

start to see where I'm losing my memory?

Thanks in advance,
~Philip
I am not using mysql_free_result(). Is that highly recommended  
by all?

Thanks,
~Philip
I took your suggestions and made sure to clean up after myself.  
I'm running into something that *appears* to be a bug with  
mysql_free_result(). Here's a snippet of my db class.

  echo "\nMemory usage before query: " . number_format  
(memory_get_usage ()) . "\n";

  $resultSet = $this->query($sql);
  echo "Memory usage after  query: " . number_format  
(memory_get_usage ()) . "\n";

  if (!$assoc) { $result = $this->fetch_row($resultSet); }
  else {
  $result = $this->fetch_array($resultSet);
  echo "Memory usage after  fetch: " . number_format  
(memory_get_usage ()) . "\n";

  }


/*


  $this->freeResult($resultSet);

*/
mysql_free_result($resultSet);

  echo "Memory usage after   free: " . number_format  
(memory_get_usage ()) . "\n";

  return $result;
  }
  function freeResult ($result)
  {
  if (is_resource ($result)) {
  if (!mysql_free_result ($result)) { echo "Memory could  
not be freed\n"; }

  }
  unset ($result); // For good measure
  }
  function fetch_row ($set) {
  return mysql_fetch_row ($set);
  }
  function fetch_array ($set) {
  return mysql_fetch_array ($set, MYSQL_ASSOC);
  }
}
// I seem to be losing memory when I call this
$db->fetch($sql);
?>
The result I get with this is...
Memory usage before query: 6,406,548
Memory usage after  query: 6,406,548
Memory usage after  fetch: 6,406,548
Memory usage after   free: 6,406,572
As you may notice, the memory actually goes UP after the *freeing*  
of memory. Why is this happening?! What have I done wrong? Is this  
a bug? Any thoughts would be appreciated.

Thanks,
~Philip


try the above...

jeff


Unfortunately, the same result:

Memory usage before query: 6,524,676
Memory usage after  query: 6,524,676
Memory usage after  fetch: 6,524,676
Memory usage after   free: 6,524,700

Memory usage before query: 6,524,792
Memory usage after  query: 6,524,792
Memory usage after  fetch: 6,524,792
Memory usage after   free: 6,524,816

Memory usage before query: 6,524,932
Memory usage after  query: 6,524,932
Memory usage after  fetch: 6,524,932
Memory usage after   free: 6,524,956

Each iteration shows a 24 byte difference between fetching the array  
and freeing the result. Thoughts? This is baffling to me.


Thanks,
~Philip


I did a little searching and found this article:

http://www.ibm.com/developerworks/opensource/library/os-php-v521/

He gives the same example I do with mysql_free_result() not  
appropriately freeing the memory. He concludes with "we can assume  
that mysql_query() is allocating memory incorrectly." However, he  
never explains his thoughts on why or anything else. Thanks, Tracy.


So am I chasing a tangent? Should my focus be moved to mysql_query()  
instead? Thoughts?


Thanks,
~Philip

PS... Yes, this is giving me a headache.

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



Re: [PHP] Where's my memory going?!

2009-09-29 Thread Philip Thompson

On Sep 29, 2009, at 3:07 PM, jeff brown wrote:


Philip Thompson wrote:

On Sep 28, 2009, at 4:40 PM, jeff brown wrote:
Yes, that's the best way to clean up after yourself.  And you  
really should use that on anything you have sitting around daemon  
like.


Jeff

Philip Thompson wrote:

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:
well this sound clearly to me like you are not freeing  
resultsets you are not going to use anymore. In long scripts you  
have to take care of this. on short scripts you can be a bit  
weak on that, because the resultsets are closed and freed on  
script ending.


assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com 
...

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of  
specified
data has been received, it calls a class which processes the  
data and
inserts it into the database. Each iteration, I unset/destruct  
that

class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on  
where to

start to see where I'm losing my memory?

Thanks in advance,
~Philip
I am not using mysql_free_result(). Is that highly recommended by  
all?

Thanks,
~Philip
I took your suggestions and made sure to clean up after myself. I'm  
running into something that *appears* to be a bug with  
mysql_free_result(). Here's a snippet of my db class.

   echo "\nMemory usage before query: " . number_format  
(memory_get_usage ()) . "\n";

   $resultSet = $this->query($sql);
   echo "Memory usage after  query: " . number_format  
(memory_get_usage ()) . "\n";

   if (!$assoc) { $result = $this->fetch_row($resultSet); }
   else {
   $result = $this->fetch_array($resultSet);
   echo "Memory usage after  fetch: " . number_format  
(memory_get_usage ()) . "\n";

   }


/*


   $this->freeResult($resultSet);

*/
 mysql_free_result($resultSet);

   echo "Memory usage after   free: " . number_format  
(memory_get_usage ()) . "\n";

   return $result;
   }
   function freeResult ($result)
   {
   if (is_resource ($result)) {
   if (!mysql_free_result ($result)) { echo "Memory could  
not be freed\n"; }

   }
   unset ($result); // For good measure
   }
   function fetch_row ($set) {
   return mysql_fetch_row ($set);
   }
   function fetch_array ($set) {
   return mysql_fetch_array ($set, MYSQL_ASSOC);
   }
}
// I seem to be losing memory when I call this
$db->fetch($sql);
?>
The result I get with this is...
Memory usage before query: 6,406,548
Memory usage after  query: 6,406,548
Memory usage after  fetch: 6,406,548
Memory usage after   free: 6,406,572
As you may notice, the memory actually goes UP after the *freeing*  
of memory. Why is this happening?! What have I done wrong? Is this  
a bug? Any thoughts would be appreciated.

Thanks,
~Philip


try the above...

jeff


Unfortunately, the same result:

Memory usage before query: 6,524,676
Memory usage after  query: 6,524,676
Memory usage after  fetch: 6,524,676
Memory usage after   free: 6,524,700

Memory usage before query: 6,524,792
Memory usage after  query: 6,524,792
Memory usage after  fetch: 6,524,792
Memory usage after   free: 6,524,816

Memory usage before query: 6,524,932
Memory usage after  query: 6,524,932
Memory usage after  fetch: 6,524,932
Memory usage after   free: 6,524,956

Each iteration shows a 24 byte difference between fetching the array  
and freeing the result. Thoughts? This is baffling to me.


Thanks,
~Philip


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



Re: [PHP] Where's my memory going?!

2009-09-29 Thread Philip Thompson

On Sep 28, 2009, at 4:40 PM, jeff brown wrote:

Yes, that's the best way to clean up after yourself.  And you really  
should use that on anything you have sitting around daemon like.


Jeff

Philip Thompson wrote:

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:
well this sound clearly to me like you are not freeing resultsets  
you are not going to use anymore. In long scripts you have to take  
care of this. on short scripts you can be a bit weak on that,  
because the resultsets are closed and freed on script ending.


assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com 
...

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of specified
data has been received, it calls a class which processes the data  
and

inserts it into the database. Each iteration, I unset/destruct that
class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on where  
to

start to see where I'm losing my memory?

Thanks in advance,
~Philip
I am not using mysql_free_result(). Is that highly recommended by  
all?

Thanks,
~Philip


I took your suggestions and made sure to clean up after myself. I'm  
running into something that *appears* to be a bug with  
mysql_free_result(). Here's a snippet of my db class.


echo "\nMemory usage before query: " . number_format  
(memory_get_usage ()) . "\n";

$resultSet = $this->query($sql);
echo "Memory usage after  query: " . number_format  
(memory_get_usage ()) . "\n";


if (!$assoc) { $result = $this->fetch_row($resultSet); }
else {
$result = $this->fetch_array($resultSet);
echo "Memory usage after  fetch: " . number_format  
(memory_get_usage ()) . "\n";

}

$this->freeResult($resultSet);
echo "Memory usage after   free: " . number_format  
(memory_get_usage ()) . "\n";


return $result;
}

function freeResult ($result)
{
if (is_resource ($result)) {
if (!mysql_free_result ($result)) { echo "Memory could  
not be freed\n"; }

}
unset ($result); // For good measure
}

function fetch_row ($set) {
return mysql_fetch_row ($set);
}

function fetch_array ($set) {
return mysql_fetch_array ($set, MYSQL_ASSOC);
}
}

// I seem to be losing memory when I call this
$db->fetch($sql);
?>

The result I get with this is...

Memory usage before query: 6,406,548
Memory usage after  query: 6,406,548
Memory usage after  fetch: 6,406,548
Memory usage after   free: 6,406,572

As you may notice, the memory actually goes UP after the *freeing* of  
memory. Why is this happening?! What have I done wrong? Is this a bug?  
Any thoughts would be appreciated.


Thanks,
~Philip


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



Re: [PHP] Re: Where's my memory going?!

2009-09-28 Thread Philip Thompson

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:

well this sound clearly to me like you are not freeing resultsets  
you are not going to use anymore. In long scripts you have to take  
care of this. on short scripts you can be a bit weak on that,  
because the resultsets are closed and freed on script ending.


assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com 
...

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of specified
data has been received, it calls a class which processes the data and
inserts it into the database. Each iteration, I unset/destruct that
class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on where to
start to see where I'm losing my memory?

Thanks in advance,
~Philip


I am not using mysql_free_result(). Is that highly recommended by all?

Thanks,
~Philip

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



Re: [PHP] Where's my memory going?!

2009-09-28 Thread Philip Thompson

On Sep 28, 2009, at 4:18 PM, Jim Lucas wrote:


Philip Thompson wrote:

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of specified  
data
has been received, it calls a class which processes the data and  
inserts

it into the database. Each iteration, I unset/destruct that class I
call. However, the script keeps going up in memory and eventually  
runs
out, causing a fatal error. Any thoughts on where to start to see  
where

I'm losing my memory?

Thanks in advance,
~Philip



We cannot tell you anything without see an example of what your  
script is doing.


Let us see some code!


I was wondering if you were gonna ask that! Umm... I don't know if I  
can show you the code b/c it's not as trivial as I explained it above.  
I'll tell you what, I give you something to chew on and you let me  
know if it's enough.


core = new coreFunctions (false, 'interface');
parent::__construct ($this->core, $host, $port, $clients);
$this->readFunction = 'processData';
$this->startPersistentListener();
}

public function processData ($data)
{
if ($this->filetype == 'demographics') {
$demoImporter = new Demographics ();
$ret = $demoImporter->importFromDataStream ($data);
$demoImporter->__destruct();
unset ($demoImporter);
echo "Memory usage: " . number_format (memory_get_usage  
()) . "\n";

return $ret;
}
}
}

class Socket
{
public function startPersistentListener ()
{
// Create a persistent listening socket connection
$this->create();
$this->setOption(SOL_SOCKET, SO_KEEPALIVE, 1);
$this->bind();
$this->listen();
$this->clients = array($this->sock);

while ($this->isAlive) {
// Create the list of connected clients
$this->createClients();

if ($this->select() < 1) {
// No clients - go to the next iteration
continue;
}

$this->accept();
$this->read();
}
}
}

set_time_limit (0);
new SocketListener ();
?>

I stripped out a lot of code, but this is the basics. I have a  
listener class that extends the socket class. When the socket class  
receives some data, it calls the processData() method - which creates  
a new instance of the Demographics class. It destroys the instance  
after it's finished. The line where I echo the memory usage indicates  
that the memory continues to grow until it just explodes.


There's a lot more going on behind the scenes that *could* cause the  
memory leak, but hopefully this will give you somewhere to go.


Thanks!
~Philip

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



[PHP] Where's my memory going?!

2009-09-28 Thread Philip Thompson

Hi all.

I have a script that opens a socket, creates a persistent mysql  
connection, and loops to receive data. When the amount of specified  
data has been received, it calls a class which processes the data and  
inserts it into the database. Each iteration, I unset/destruct that  
class I call. However, the script keeps going up in memory and  
eventually runs out, causing a fatal error. Any thoughts on where to  
start to see where I'm losing my memory?


Thanks in advance,
~Philip

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



Re: [PHP] NULLS vs Empty result in PHP

2009-09-23 Thread Philip Thompson

On Sep 23, 2009, at 9:48 AM, Dan Shirah wrote:



From reading the other responses to this thread, it seems that you  
want

to
"skip" or "exclude" rows in the results where my_column === null.

If this is correct, why not do it in the SELECT statement to begin  
with?


$my_query = "SELECT my_column FROM my_database WHERE my_column IS NOT
NULL";

That should do it.



I want to exclude the rows that might be NULL, "" (empty), or  
""

(empty series of spaces)

From all of the input so far, it seems that using trim() on the  
variable and

then use empty() is the best way to pick all three types up.


I don't think you're using mysql, but your selected db may have a  
similar option. I would do the work in the sql.


$sql = "SELECT * FROM `table` WHERE TRIM(`column`) <> '' AND `column`  
IS NOT NULL";

$result = query($sql);
while ($row = fetch_row ($result)) {
echo "Not empty, multiple spaces or NULL!";
}
?>

So, if you have any extraneous spaces, they will be removed. It also  
accounts for nulls. No work is required by PHP to determine the values  
you need. Just use what it returns. This should work.


Hope this helps.
~Philip


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



Re: [PHP] Extract links from strings

2009-09-23 Thread Philip Thompson

On Sep 21, 2009, at 6:20 PM, Jim Lucas wrote:


Jim Lucas wrote:

Jônatas Zechim wrote:

Hi there, i've the following strings:

$string1 = 'Lorem ipsum dolor http://site.com sit amet';
$string2 = 'Lorem ipsum dolor http://www.site.com/ sit amet';
$string3 = 'Lorem ipsum dolor http://www.site.net sit amet';

How can I extract the URL from these strings?
They can be [http:// + url] or [www. + url].

Zechim




Something like this should work for you.

http://site.com sit amet';
$urls[] = 'Lorem ipsum dolor https://www.site.com/ sit amet';
$urls[] = 'Lorem ipsum dolor www.site1.net sit amet';
$urls[] = 'Lorem ipsum dolor www site2.net sit amet';

foreach ( $urls AS $url ) {
if ( preg_match('%((https?://|www\.)[^\s]+)%', $url, $m) ) {
print_r($m);
}
}

?>



Actually, try this.  It seems to work a little better.

http://site.com sit amet';
$urls[] = 'Lorem ipsum dolor https://www.site.com/ or http://www.site2.com/' 
;

$urls[] = 'Lorem ipsum dolor www.site1.net sit amet';
$urls[] = 'Lorem ipsum dolor www site2.net sit amet';

foreach ( $urls AS $url ) {
if ( preg_match_all('%(https?://[^\s]+|www\.[^\s]+)%',
$url,
$m,
(PREG_SET_ORDER ^ PREG_OFFSET_CAPTURE)
) ) {
print_r($m);
}
}

?>


What if the sub domain was not 'www'?

http://no-www.org/

Cheers,
~Philip


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



Re: [PHP] ie6 "memory could not be read" help!

2009-09-17 Thread Philip Thompson

On Sep 17, 2009, at 4:04 AM, Ashley Sheridan wrote:


On Thu, 2009-09-17 at 16:41 +0800, Shelley wrote:

Hi all,

With IE6,

After the pages i developed was loaded, there seems to be no problem,
but when you then click a link, refresh the page, etc. it shows  
"memory

could not be 'read'" error message.

However, when you load other sites, google.com, for example, there  
is no

such problem.

Anybody knows how to fix this problem?

Any help is appreciated & thanks in advance.



http://support.microsoft.com/kb/899811

first result from a Google search

Thanks,
Ash


Since this post is not PHP-related, I'll continue the trend. Are  
people still using IE6? In sites I design, I prevent the user from  
viewing it. If they're still on IE6, I don't want them to use my sites.


Cheers,
~Philip

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



Re: [PHP] Sockets (reading)

2009-08-26 Thread Philip Thompson

On Aug 26, 2009, at 2:47 PM, Bob McConnell wrote:


From: Philip Thompson

On Aug 26, 2009, at 11:56 AM, Bob McConnell wrote:

From: Philip Thompson


During a socket read, why would all the requested number of bytes

not

get sent? For example, I request 1000 bytes:



This is actually in a loop, so I can get all the data if split up.
So,
for example, here's how the data split up in 3 iterations (for 1000
bytes):

650 bytes
200 bytes
150 bytes

But if I can accept up to 2048 bytes per socket read, why would it
not
pull all 1000 bytes initially in 1 step? Any thoughts on this would



be
greatly appreciated!


Because that's the way TCP/IP works, by design. TCP is a stream
protocol. It guarantees all of the bytes written to one end of the
pipe
will come out the other end in the same order, but not necessarily  
in

the same groupings. There are a number of buffers along the way that
might split them up, as well as limits on packet sizes in the  
various

networks it passed through. So you get what is available in the last
buffer when a timer expires, no more, and no less.

If you have serialized data that needs to be grouped in specific
blocks,
your application will need to keep track of those blocks,

reassembling

or splitting the streamed data as necessary. You could use UDP which
does guarantee that packets will be kept together, but that protocol
doesn't guarantee delivery.


Thank you for your input.

Is it guaranteed that at least 1 byte will be sent each time? For
example, if I know the data length...



Or is this a completely unreasonable and unnecessary way to get the
data?


While I have written a lot of code to manage sockets over the years,  
and
coded a UDP/IP stack, I have never done it in PHP. And  
unfortunately, I
don't have time to experiment right now. My boss is waiting for the  
next

product release from me.

Getting one byte at a time is somewhat wasteful, as it requires more
system calls than necessary. That's a lot of wasted overhead.

Whether you always get one or more bytes depends on a number of  
factors,
including whether the calls PHP uses are blocking or non-blocking,  
plus

there may be ways to switch the socket back and forth.

Have you tried doing a Google search on the group of PHP functions you
expect to use. That should come up with some sample code to look at.

Bob McConnell


I agree that one byte at a time is wasteful. I'm sure others haven't  
implemented something along these lines, but I wrote a much more  
efficient way to make sure I grab all the data of a known length...


if (($data = @socket_read ($socket, $len - $offset,  
PHP_BINARY_READ)) === false) {

return false;
}

$offset += strlen ($data);
$socketData .= $data;
}

return $socketData;
}
?>

If not all the data is obtained on a read, it will loop until the  
amount of data is the same as the length requested. This is working  
quite well.


Thanks Bob and the others!

~Philip

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



Re: [PHP] Sockets (reading)

2009-08-26 Thread Philip Thompson

On Aug 26, 2009, at 11:56 AM, Bob McConnell wrote:


From: Philip Thompson


During a socket read, why would all the requested number of bytes not
get sent? For example, I request 1000 bytes:



This is actually in a loop, so I can get all the data if split up.  
So,

for example, here's how the data split up in 3 iterations (for 1000
bytes):

650 bytes
200 bytes
150 bytes

But if I can accept up to 2048 bytes per socket read, why would it  
not
pull all 1000 bytes initially in 1 step? Any thoughts on this would  
be

greatly appreciated!


Because that's the way TCP/IP works, by design. TCP is a stream
protocol. It guarantees all of the bytes written to one end of the  
pipe

will come out the other end in the same order, but not necessarily in
the same groupings. There are a number of buffers along the way that
might split them up, as well as limits on packet sizes in the various
networks it passed through. So you get what is available in the last
buffer when a timer expires, no more, and no less.

If you have serialized data that needs to be grouped in specific  
blocks,

your application will need to keep track of those blocks, reassembling
or splitting the streamed data as necessary. You could use UDP which
does guarantee that packets will be kept together, but that protocol
doesn't guarantee delivery.

Bob McConnell


Thank you for your input.

Is it guaranteed that at least 1 byte will be sent each time? For  
example, if I know the data length...


if (($data = @socket_read ($socket, 1, PHP_BINARY_READ)) !==  
false) {

$input .= $data;
}
}

return $input;
?>

Or is this a completely unreasonable and unnecessary way to get the  
data?


Thanks,
~Philip

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



[PHP] Sockets (reading)

2009-08-26 Thread Philip Thompson

Hi.

During a socket read, why would all the requested number of bytes not  
get sent? For example, I request 1000 bytes:




This is actually in a loop, so I can get all the data if split up. So,  
for example, here's how the data split up in 3 iterations (for 1000  
bytes):


650 bytes
200 bytes
150 bytes

But if I can accept up to 2048 bytes per socket read, why would it not  
pull all 1000 bytes initially in 1 step? Any thoughts on this would be  
greatly appreciated!


Thanks,
~Philip

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



Re: [PHP] Re: XSS Preventing.

2009-06-23 Thread Philip Thompson

On Jun 23, 2009, at 9:29 AM, Martin Zvarík wrote:


Don't htmlentiies() before DB save.  In general:
- mysql_real_escape_string() before DB insertion
- htmlentities() before dispaly



I, on the other hand, would do htmlentities() BEFORE insertion.


Pros:
---
The text is processed once and doesn't have to be htmlentitied()  
everytime you read the database - what a stupid waste of performance  
anyway.



Cons:
---
Instead "&" you'll see "&" ... is that a problem? Not for me and  
I believe 80% of others who use DB to store & view on web.


I had a problem with storing & into the database instead of just  
&. When I wanted to search for something and "&" was in the value,  
typing "&" would not find the result. I fixed that by not using  
htmlentities() before inputing data into the database. IMO, using  
htmlentities() or htmlspecialchars() before inserting into db is  
inherently wrong. Making calls to those functions should have  
negligible impact on the application - there are other ways to improve  
the performance of your application.


My too scents,
~Philip



Martin


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



Re: [PHP] Boolean Parameter to 3 Options?

2009-04-29 Thread Philip Thompson

On Apr 29, 2009, at 11:42 AM, Matt Neimeyer wrote:


I have a function that currently takes a boolean value as a parameter.
But now I want to expand it to 3 options...  So if I have...

function doFooBar($doFoo = false)
  {
  if($doFoo)
 { echo "Did Foo"; }
  else
 { echo "Did Bar"; }
  }

Is it as "simple" as changing it like follows to avoid having to
change existing code that won't use the new values.

function doFooBar($doFoo = 0)
  {
  if($doFoo == 2)
 { echo "Did Baz"; }
  else if($doFoo == 1)
 { echo "Did Foo"; }
  else
 { echo "Did Bar"; }
  }

Something about that disturbs me. Perhaps because any time I think "Oh
it will be as simple as..." it usually isn't.

Thanks in advance!

Matt


Unless you're doing a strict comparison (===), it probably won't make  
a lot of difference. However, if you sent "true" to the function, I  
believe it will reach the last else condition. You may revisit all the  
locations you call it and update them appropriately.


Those are my initial thoughts

~Philip


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



Re: [PHP] Re: Unit Testing

2009-04-27 Thread Philip Thompson

On Apr 27, 2009, at 11:38 AM, Simon wrote:


As a programmer, i always test what I'm coding as i code it (mostly to
make sure i dont include typos), but i feel it is best to make proper
testing once the component is ready and working fine.  If your project
is large, it might be a good idea to break it in several 'modules' or
section if possible and treat each of them as separate projects
(testing would be done on a module once this one is ready).

You may be interested in looking for information on the net on 'IT
project management' which usually describe when is the best time to
test according to a certain structure...

Simon

On Mon, Apr 27, 2009 at 12:16 PM, Nathan Rixham   
wrote:

Philip Thompson wrote:


Hi. I did some searching in the archives, but didn't quite find  
what I was

looking for. Maybe a few of you can assist me...

We have an application that's currently in production, but we're
constantly modifying/upgrading it. We did not do unit testing  
early on

because of the lack of time. Now that some time has opened up, we're
considering unit testing. My question is. is it reasonable to  
start unit
testing at this point in time with the application mostly built?  
Besides
being really time-consuming, what are the pitfalls of starting  
unit testing

at this stage?

Thanks in advance,
~Philip


maybe a useless answer, but, no pitfalls - just do it - I'm always  
surprised
by my unit test results, its invaluable and it's never too late to  
start.


just think about the next years worth of bugs found by the client  
not being

there!


A question I have about unit testing. The point is to test individual  
"units"... correct? So, let's say I have this core class which creates  
instances of other classes. Well, if I only want test the core class,  
I don't want to instantiate the other classes... correct? Example:


class1 = new Class1 ($this);
$this->class2 = new Class2 ($this);
}
}

// CoreTest.php
require ('../PHPUnit/Framework.php');
require ('../includes/Core.php');

class CoreTest extends PHPUnit_Framework_TestCase {
protected function setUp () {
$this->core = new Core();
}
}
?>

So, here, Class1 and Class2 will be instantiated. However, I don't  
really care for them to be so that I can test all the methods in the  
core class. Is this a perfect example of how the original design of  
the core class is not conducive to implementing unit tests? Without  
rewriting the core class, is there a way to test this?


Thanks,
~Philip

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



[PHP] Unit Testing

2009-04-27 Thread Philip Thompson
Hi. I did some searching in the archives, but didn't quite find what I  
was looking for. Maybe a few of you can assist me...


We have an application that's currently in production, but we're  
constantly modifying/upgrading it. We did not do unit testing early on  
because of the lack of time. Now that some time has opened up, we're  
considering unit testing. My question is. is it reasonable to  
start unit testing at this point in time with the application mostly  
built? Besides being really time-consuming, what are the pitfalls of  
starting unit testing at this stage?


Thanks in advance,
~Philip

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



Re: [PHP] 800 pound gorilla

2009-04-20 Thread Philip Thompson

On Apr 20, 2009, at 8:48 AM, Marc Christopher Hall wrote:

Sun buys MySQL and now Oracle buys Sun (not final, yet). What will  
happen
with the main db we PHP'ers have come to know and love especially  
since v 5


Probably nothing. It would not behoove Oracle to get rid of or  
significantly modify MySQL. It appears that Oracle will just get  
richer... =D


~Philip

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



Re: [PHP] niewbie - call methods from another class

2009-04-20 Thread Philip Thompson

On Apr 19, 2009, at 9:43 AM, MEM wrote:


Hello, I have something like this:

$stmt = $this->_dbh->prepare("INSERT INTO DOG (name_dog, race_dog,  
id_vet)

VALUES (?, ?, ?)");

$stmt->bindParam(1, $this->getNameDog() );
$stmt->bindParam(2, $this->getRaceDog());
$stmt->bindParam(3, );


$stmt->execute();
  }

To make this insert function work, I need to fill the id_vet  
database column

with some values.
I cannot use $this->getIdVet() because this method is not in dog  
class, is

on the veterinary class.
So my question is:
How can I access the getIdVet() that is on the veterinary class to  
put it on

the insert dog method?


Thanks a lot,
Márcio


Try this

id;
}
}

class dog {
public function add () {
$vet = new veterinary ();

$stmt = $this->_dbh->prepare("INSERT INTO DOG (name_dog,  
race_dog, id_vet) VALUES (?, ?, ?)");


$stmt->bindParam(1, $this->getNameDog());
$stmt->bindParam(2, $this->getRaceDog());
$stmt->bindParam(3, $vet->getIdVet());
$stmt->execute();
}
}
?>

Of course here you will have to determine how the vet id is set. The  
method getIdVet has a redundant name. Since it's already in the  
veterinary class, just use getId() or id(). However, you'll probably  
want to change the above implementation to not create the veterinary  
in the add() method. You'll probably want to create it in the dog  
constructor...


vet = new veterinary ($vetId);
}
...
}
?>

And use $this->vet instead of $vet in the dog->add() method. Hope that  
helps. Do a little reading to try to understand using objects a little  
bit more.


http://php.net/object

~Philip


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



Re: [PHP] PHP/MYSQL/ Encrypting Sensetive information

2009-04-17 Thread Philip Thompson

On Apr 17, 2009, at 10:17 AM, Stefan Langwald wrote:


MySQLs own Function AES_(EN|DE)CRYPT is pretty cool for this case.
--

Stefan Langwald


We use MySQL's AES_(EN|DE)CRYPT. It's fast, easy to use and uses 128  
bit encryption (optionally 256).


http://dev.mysql.com/doc/refman/5.1/en/encryption-functions.html

~Philip



2009/4/17 דניאל דנון :
If its by a user-basis, something that can be a bit risky but  
possible - You
can encrypt it, password is hashed on database, and the key to the  
other

data is the un-encrypted password..

On Fri, Apr 17, 2009 at 5:00 PM, Russell Jones   
wrote:



We are looking at a project where we will potentially need to store
sensetive information in a few fields of a MySQL table. Any  
recommendations
on where to look for best practices in doing this? for encrypting  
the data,
etc.? We will need to be able to decrypt the data as well,  
although this

can
probably be done locally, so hashing alone is not really an option.

Russell Jones


--
Use ROT26 for best security


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



Re: [PHP] Accessors

2009-02-19 Thread Philip Thompson

On Feb 19, 2009, at 10:55 AM, Jochem Maas wrote:


please keep replies on list.


Sorry!


Philip Thompson schreef:

On Feb 19, 2009, at 2:59 AM, Jochem Maas wrote:


Philip Thompson schreef:

Hi all.






What are your thoughts? Does this seem like a reasonable  
implementation?
Useful? Pointless? Hit me up - I can handle *constructive*  
criticism.

But for now, it's late and past my bedtime.


how do you set a property to null?


Oh sure, point that out! JK. I thought of that as well. For members
where 'null' is an option, you may just want to create a definitive
accessor or modify the __call() function. Use a string to represent  
null

- I'll use 'nil' from objective-c. Something like this...


yes but then someone might want to set the value to 'nil' or '__nil'
or any other magic value you might want to use.

what about capturing a method name prefix:

$person->unsetFirst();


Yes, that is quite a viable option. I thought about the same thing,  
except for setting the member. Modify the __call method to check for  
'set' before the member name


$person->setFirst('John');
$person->setFirst(null);

If you do it this way, there is no doubt that you are wanting to set  
the value. And it even allows null.


~Philip



$member;
   return $value;
   }

   // Test to see if value is 'nil'. If so, set to null.
   if (!is_array ($args[0]) && $args[0] == 'nil') {
   $args[0] = null;
   }

   $this->$member = $args;
   }
   else {
   die ("Fatal Error: Call to undefined member: $member.  
Exiting...");

   }
}

$person = new Person();
$person->first('Billy');
$person->first('nil');
?>

I suppose it's a possibility that someone will assign 'nil' to a  
member

as an actual value, so put in some more checking or modify the null
keyword - maybe '__nil' or whatever? That a possibility?

Cheers,
~Phil


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



[PHP] Accessors

2009-02-18 Thread Philip Thompson

Hi all.

Maybe I'm wanting more Java-like functionality out of PHP, but I don't  
really like getting and setting members directly (even for public  
members) - I'd rather use accessors. This way you can control what is  
getting set and what is returning. However, I also don't really want  
to create a million get/set accessor methods - this is no fun and  
takes up a lot of space. After reading around a little bit, it got me  
thinking about overloading in PHP (which I'm sure we all know is  
completely different than any other language... but that's another  
day). I didn't want to use the standard __get and __set methods  
because that still leaves me with the same notation for getting/ 
setting members. So, instead, I used a close relative of __get and  
__set. Meet brother __call. Could it really be this trivial to get the  
notation I'm wanting? Yes. Yes it is. Ok, enough talking... onto the  
code.


$member;
return $value;
}

// Oh, args is not empty! Set the value
$this->$member = $args;
}
else {
// Blow up!
die ("Fatal Error: Call to undefined member: $member.  
Exiting...");

}
}
}

$person = new Person();

// Set the (private) first and last names
$person->first('Billy');
$person->last('Bob');

// Get the (private) first and last names
echo $person->first() . " " . $person->last()."";

// Set the (public) age
$person->age(103);

// Get the (public) age
echo "Age: ".$person->age()."";

// Explosions
$person->first = 'Buford';
$person->pizza('Is yummy');
?>

Now if you're reading this and thinking "Duh!" then good for you.  
However, I know there's at least 1 soul on this list who may benefit  
from this. But don't stop at the example above. If you want to add  
validation to the members you're getting/setting, build that into your  
code. If you want each member to be a specific type, include that as  
well (I'll leave the implementation up to you). ;-)


So let's recap.

•  This functionality allows me to not have to write 2 accessors for  
every member
•  This allows me to use methods instead of directly getting/setting  
members (even though I can still access public members directly... if  
I want)
•  Keeps code consistent and less confusing - I know how to get and  
set every member


What are your thoughts? Does this seem like a reasonable  
implementation? Useful? Pointless? Hit me up - I can handle  
*constructive* criticism. But for now, it's late and past my bedtime.


Cheers,
~Philip

"innerHTML is a string. The DOM is not a string, it's a hierarchal  
object structure. Shoving a string into an object is impure and  
similar to wrapping a spaghetti noodle around an orange and calling it  
lunch."

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



Re: [PHP] CLI not obeying php.ini

2009-02-05 Thread Philip Thompson

On Feb 5, 2009, at 4:20 PM, Boyd, Todd M. wrote:


-Original Message-
From: Philip Thompson [mailto:philthath...@gmail.com]
Sent: Thursday, February 05, 2009 3:45 PM
To: PHP General list
Subject: [PHP] CLI not obeying php.ini

In my php.ini, I have

error_reporting = E_ALL & ~E_NOTICE

When I run a script from the command line, I get a lot of notices
even when I said I don't want them. Also, in my script, I specified
error_reporting(E_ERROR) in attempts to explicitly tell it what I
want. It doesn't work either.

Why am I still getting notices?! BTW, I don't receive notices via a
web browser, just CLI.

I double-checked to see what INI file was loaded and it's the one I
expected to see:

[pthomp...@pthompson scripts]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini

Thoughts on what's happening would be awesome! Thanks in advance.


In addition to what's already been said, you could try forcing a  
php.ini
file in the current directory by trying the -c command line option.  
I've

done it to try messing with a handful of values here and there for
particular scripts.

HTH,

// Todd


I tried this as well. No luck.

[pthomp...@pthompson scripts]$ php -c /etc -f updateLabels.php >  
labels.log


This issue is mainly annoying and not really a bigger issue b/c  
clients don't see it. Hrm. Oh well. Still open to suggestions. Should  
I try kicking my (virtual) machine? =D


~Philip

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



Re: [PHP] CLI not obeying php.ini

2009-02-05 Thread Philip Thompson

On Feb 5, 2009, at 4:10 PM, Chris wrote:


Philip Thompson wrote:

In my php.ini, I have
error_reporting = E_ALL & ~E_NOTICE
When I run a script from the command line, I get a lot of  
notices even when I said I don't want them. Also, in my script,  
I specified error_reporting(E_ERROR) in attempts to explicitly tell  
it what I want. It doesn't work either.
Why am I still getting notices?! BTW, I don't receive notices via a  
web browser, just CLI.
I double-checked to see what INI file was loaded and it's the one I  
expected to see:

[pthomp...@pthompson scripts]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Thoughts on what's happening would be awesome! Thanks in advance.


Are you including another script (eg pear mail or mbd2 or whatever)?  
Maybe it's setting something and overriding your attempt. A quick  
grep would be able to check that.


I am including other classes. I did a grep on the whole directory and  
the only location that had error_reporting was the spot I wrote into  
my script to force it to E_ERROR. Odd, I know...


Thanks,
~Philip

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



Re: [PHP] CLI not obeying php.ini

2009-02-05 Thread Philip Thompson

On Feb 5, 2009, at 4:17 PM, Ashley Sheridan wrote:


On Thu, 2009-02-05 at 15:45 -0600, Philip Thompson wrote:

In my php.ini, I have

error_reporting = E_ALL & ~E_NOTICE

When I run a script from the command line, I get a lot of notices
even when I said I don't want them. Also, in my script, I specified
error_reporting(E_ERROR) in attempts to explicitly tell it what I
want. It doesn't work either.

Why am I still getting notices?! BTW, I don't receive notices via a
web browser, just CLI.

I double-checked to see what INI file was loaded and it's the one I
expected to see:

[pthomp...@pthompson scripts]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini

Thoughts on what's happening would be awesome! Thanks in advance.

~Philip


Depending on what distro (I'm assuming Linux, who would run PHP on
anything else? ;) ) you may have a separate php.ini for the CLI. I
believe SUSE does this, and it could well be that other distros use a
similar model.

If you are running SUSE, the config files should be in /etc/php5/


Ash
www.ashleysheridan.co.uk


There are other .ini files located in /etc/php.d, but none specify  
error_reporting...


~Phil

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



[PHP] CLI not obeying php.ini

2009-02-05 Thread Philip Thompson

In my php.ini, I have

error_reporting = E_ALL & ~E_NOTICE

When I run a script from the command line, I get a lot of notices  
even when I said I don't want them. Also, in my script, I specified  
error_reporting(E_ERROR) in attempts to explicitly tell it what I  
want. It doesn't work either.


Why am I still getting notices?! BTW, I don't receive notices via a  
web browser, just CLI.


I double-checked to see what INI file was loaded and it's the one I  
expected to see:


[pthomp...@pthompson scripts]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini

Thoughts on what's happening would be awesome! Thanks in advance.

~Philip

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



[PHP] Re: Imagick->setImageFormat()

2009-01-29 Thread Philip Thompson

On Jan 29, 2009, at 4:20 PM, Philip Thompson wrote:


Hello all.

I'm pretty new to Imagick. I'm merely attempting the examples on the  
PHP site (http://php.net/manual/en/imagick.examples-1.php), but I'm  
having some issues. I'm attempting the reflection of an image  
example and when I attempt to:


$canvas->setImageFormat("png");

I get an error that reads:

Fatal error: Uncaught exception 'ImagickException' in /home/www/pc4/ 
image.php:67 Stack trace: #0 /home/www/pc4/image.php(67): Imagick- 
>setimageformat('png') #1 {main} thrown in /home/www/pc4/image.php  
on line 67


Note that I CAN do this: $canvas->setImageFormat("gif");

I'm running Fedora Core 8. My first thought was that my machine  
doesn't support PNG. So I checked for libpng, and it's there and up  
to date. I've looked at my http error logs and I've google'd to no  
avail. Do you have any thoughts on why I can't use the "png" format?


Thanks in advance,
~Philip


Ok, I figured it out. Along with that error message I was receiving  
"identify: no decode delegate for this image format" when I attempted  
to open up a PNG image. Well, after some searching, I discovered that  
that basically means you don't have the libraries to support that  
image type. The weird part is, I did have libpng. However, I think I  
may have installed it after I built ImageMagick. So, I rebuilt  
ImageMagick. This time I looked at the configuration and png support  
was enabled. It works now! Yay!


This person was having a similar issue and it helped me figure out  
what I need to know:

http://www.vbulletin.com/forum/archive/index.php/t-197439.html

Also, directions for installing ImageMagick from source:
http://www.imagemagick.org/script/install-source.php

Cheers!
~Philip

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



[PHP] Imagick->setImageFormat()

2009-01-29 Thread Philip Thompson

Hello all.

I'm pretty new to Imagick. I'm merely attempting the examples on the  
PHP site (http://php.net/manual/en/imagick.examples-1.php), but I'm  
having some issues. I'm attempting the reflection of an image example  
and when I attempt to:


$canvas->setImageFormat("png");

I get an error that reads:

Fatal error: Uncaught exception 'ImagickException' in /home/www/pc4/ 
image.php:67 Stack trace: #0 /home/www/pc4/image.php(67): Imagick- 
>setimageformat('png') #1 {main} thrown in /home/www/pc4/image.php on  
line 67


Note that I CAN do this: $canvas->setImageFormat("gif");

I'm running Fedora Core 8. My first thought was that my machine  
doesn't support PNG. So I checked for libpng, and it's there and up to  
date. I've looked at my http error logs and I've google'd to no avail.  
Do you have any thoughts on why I can't use the "png" format?


Thanks in advance,
~Philip

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



Re: [PHP] Client/Server Printing

2009-01-20 Thread Philip Thompson

On Jan 20, 2009, at 9:16 AM, Paul M Foster wrote:


I'd like a side check on what I'm doing to print on our internal
network.

We have an internal server/site which uses PHP code I've written to
"run" the business-- invoicing, A/P, inventory, etc. Some things, like
invoices and reports, need to be printed. Now remember, the code is on
the server, and we access it from our client machines on our desks.  
When

we print, we do so to our local printers, attached to the client
machines.

So the best way I could think of to making printing work was to  
generate

PDFs of whatever needs to be printed, dump the PDF on the server, and
provide a link to the PDF on the web page. The user clicks on the
generated PDF, and his/her browser opens up Acrobat or xpdf, and  
prints

from that application to their local machine.

Is that a reasonable way to implement this? Any better ideas?

Paul


We've addressed this issue in two ways. Originally our application was  
locally hosted. The solution for us was:


exec ("psexec.exe -d -i -w ". escapeshellarg($filepath) ." -u  
$user -p ". escapeshellcmd ($pass) . " -e gswin32c.exe -q -dNOPAUSE - 
dNOPROMPT -dQUIET -dBATCH -dNumCopies=$copies -sDEVICE=msinwpr2 - 
sOutputFile=\"spool\\$printerShare\" \"$pdfFilepath\" 2>&1");

}
else {
exec ("/usr/bin/lpr -# $copies -P ".  
escapeshellarg($printerShare) ." \"$pdfFilepath\" 2>&1");

}
?>

The Windows version uses psexec to call ghostscript. So you do have to  
use third-party utilities for Windows (but they are small). However,  
if on *nix, then you can use the built in lpr. Of course, just put  
that code in a function that is called when clicked on a link to print.


http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
http://www.ghostscript.com/

Our online solution uses a third-party utility for printing  
(Cloverleaf/Secure Courier). Essentially we have a (print) server and  
each of our clients have a client-version that connects to the print  
server. In our application, we use sockets to send print jobs to the  
server. The server then divvies out the print jobs to the specific  
client id specified in the data sent through the socket. However,  
since all your servers/clients are local, the first option may be more  
realistic.


Hope that helps,

~Philip

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



Re: [PHP] how to display new icon for news posted within 2 days?

2009-01-15 Thread Philip Thompson
2 things. In that query, you can't have a comma in your 172,800. It's  
going to fail b/c 800 isn't a column name. Unless it actually is, then  
you're good to go. =D Secondly, to be more user friendly, if the user  
has viewed that news item, then mark it as read (take away the  
new.gif). There are a couple of ways to achieve this. One, you can use  
cookies to keep track of what they've read. The other is to keep track  
in the database (sorta like user preferences). Good luck.


~Philip

PS... Sorry to top post. It was the trend of the email and I didn't  
want to break it.


On Jan 15, 2009, at 7:50 AM, Phpster wrote:


That should work as well

Bastien

Sent from my iPod

On Jan 15, 2009, at 4:14 AM, paragasu  wrote:


is it possible to do it like
SELECT *, UNIX_TIMESTAMP(post_date)-172,800 as is_new FROM tbl

$post = mysqli_fetch_object($sql);
if($post->is_new)
echo '';

On 1/14/09, Phpster  wrote:

Make it easy and store the date as a unix timestamp. Then it's a
simple testto do

If ((current timestamp - db timestamp) < 172,800 ){
echo '';
}

Conversely, you can use strtotime() to convert the date.

Bastien

Sent from my iPod

On Jan 14, 2009, at 10:36 PM, paragasu  wrote:


i do have a mysql table with one date field.
what i want is to display and tiny icon (red new icon) so user will
notice it is a new post.
i am looking for the simplest solutions here.

i believe we can calculate whether the date is within two days of  
user

current time.
then we display an icon based on it.

can anyone help?

thanks


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



Re: [PHP] searching by tags....

2008-10-16 Thread Philip Thompson

On Oct 14, 2008, at 6:17 PM, Jochem Maas wrote:


Nathan Rixham schreef:

Ashley Sheridan wrote:

On Tue, 2008-10-14 at 14:54 -0700, Ryan S wrote:

quite a few sites seem to have a very neat way of implementing this
with (url rewriting?) something like
http://sitename/blog/tags/tag-comes-here/


As for getting those search terms, well a link in a page can  
contain GET

values, such as http://www.somedomain.com/blog?tag=search_term .
Alternatively, you could use mod-rewrite to rewrite the URL and  
turn the

path into tag variables. This is the same as the above but with the
added benefit that users can type in tags directly more easily, and
there are apparently benefits for SEO with this method as well  
(but I'm

not sure how true that is)


it's very true; from the google webmaster guidelines:

If you decide to use dynamic pages (i.e., the URL contains a "?"
character), be aware that not every search engine spider crawls  
dynamic
pages as well as static pages. It helps to keep the parameters  
short and

the number of them few.

previously it was text along the lines of "google doesn't index all
pages with query parameters, so avoid them where possible"

additionally one of the weightier points in categorising pages within
the SERPS is the text in the url (especially if the page is actually
about /the_tag_in_the_url : see http://www.google.com/search?q=tags)


^-- some what 
ironic :-)


LOL! Thanks for the outburst of laughter. ;)

~Philip


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



Re: [PHP] Plotting Tool

2008-10-09 Thread Philip Thompson

On Oct 8, 2008, at 4:13 PM, Daniel Brown wrote:


On Wed, Oct 8, 2008 at 5:09 PM, Ashley Sheridan
<[EMAIL PROTECTED]> wrote:


I really meant standards when I said basics. IMHO, standards are the

[snip!]

   None of the list-newbies get smiley-less jokes here anymore.  What
is this world coming to?!?


Don't worry, Dan. I knew you were joking!! =D

~Philip

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



Re: [PHP] AJAX and PHP

2008-10-06 Thread Philip Thompson

On Oct 4, 2008, at 7:38 AM, Ashley Sheridan wrote:


On Sat, 2008-10-04 at 13:48 +0200, Nitsan Bin-Nun wrote:
It depends how much stuff you have in the first div, it there are a  
lot of
images and the user will have to load them again (in case there is  
no cache)
and you care for the traffic those images cost - it would be better  
to use

AJAX.

But generally - they both okay, I personally would use reload of  
the whole
page just because of the time it would take me to develop it with  
ajax ;)


HTH,
Nitsan

On Sat, Oct 4, 2008 at 12:10 PM, Alain Roger <[EMAIL PROTECTED]>  
wrote:



HI,

i'm currently working on some web application and i would like to  
know what

is the best way to do what i want.
basically like all application i have a menu and based on selected  
item

menu
i want to display a page (basically 50 % of this new page is DB
result/grid.

As usual i have 2 divs, one for the menu one for the content of DB  
to

display.
i would like to know if it's not better to use AJAX to load the  
content of
the second div (DB result and other stuff) instead to every time  
load a new

page which load menu and content of DB ?

what are your experiences on such thing ?
thx.

--
Alain

Windows XP SP3
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008


Also, it depends on who you think will be visiting the site, as an
increasing number of people browse the web with devices that have no
JavaScript capabilities, so they wouldn't be able to use an Ajax site.


Jump into the now. As an increasing number of people browse the web  
with (handheld?) devices, the support will also increase. However, it  
also depends on the audience you're trying to reach. IMO, I wouldn't  
limit your site for the few who a) don't have js enabled or b) have a  
device that doesn't support any standard web browser features anyway.


~Philip

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



Re: [PHP] Php4 => Php5

2008-10-06 Thread Philip Thompson

On Oct 3, 2008, at 12:22 PM, Jim Lucas wrote:


Maciek Sokolewicz wrote:


P.S. you are quite late with migrating, PHP 5 has been out for  
several

years now



As stated in many other threads.  Some people do not have a choice.   
They are

not allowed to upgrade.  Or, as is in many cases, the cost of fixing
everything after upgrading out weighs the benefits of the upgrade  
itself.


Or wait a little bit longer because 6 will be out soon†. ;)

~Philip

† Relative term


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



Re: [PHP] extract column from multidimentional array

2008-09-29 Thread Philip Thompson

On Sep 29, 2008, at 11:08 AM, Boyd, Todd M. wrote:


-Original Message-
From: It flance [mailto:[EMAIL PROTECTED]
Sent: Monday, September 29, 2008 11:04 AM
To: php-general@lists.php.net
Subject: [PHP] extract column from multidimentional array

Hi,

below you will find the code for a small script where i'm able to
extract a row but not a column.

So the question is how can I do that.

Here is the code:




Being that PHP is row-major (like most programming languages), that
won't work. Loop through the array and build a new one out of just the
1st column from every row (or whatever column you're looking for):



HTH,

Todd Boyd
Web Programmer


Or in his original code

$col = $arr[0][0];

to get the first (element of the first sub array). Think of your array  
as this


$arr = array(
0 => array(0=>'00', 1=>'01', 2=>'02', 3=>'03'),
1 => array(0=>'10', 1=>'11', 2=>'12', 3=>'13'),
2 => array(0=>'20', 1=>'21', 2=>'22', 3=>'23'),
);

Notice the specific keys? That should help in determining which keys  
you're looking for.


I'm probably totally off by what you're asking, but Todd's response  
hopefully helped you as well. =D


~Philip



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



Re: [PHP] The Data Literacy Test

2008-09-26 Thread Philip Thompson

On Sep 24, 2008, at 8:22 PM, Shelley wrote:


2008/9/25 Philip Thompson <[EMAIL PROTECTED]>
On Sep 24, 2008, at 7:29 AM, Maciek Sokolewicz wrote:

tedd wrote:
At 12:25 PM +0100 9/24/08, Ashley Sheridan wrote:
On Wed, 2008-09-24 at 09:20 +0800, Shelley wrote:

<http://phparch.cn/index.php/php/34-php-basics/202-the-data-literacy-test 
>The

Data Literacy Test:

http://www.phparch.cn/index.php/php/34-php-basics/202-the-data-literacy-test

What the smeg is this?
I don't know, but I figure 27.
Cheers,
tedd

yes, I think 27 aswell...

- Tul

No no no. We all know the answer is 42.

? How come 42?


Just in case it's not clear what the others have commented about 42...

http://wikipedia.org/wiki/Answer_to_Life,_the_Universe,_and_Everything

~Philip

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



Re: [PHP] The Data Literacy Test

2008-09-24 Thread Philip Thompson

On Sep 24, 2008, at 7:29 AM, Maciek Sokolewicz wrote:


tedd wrote:

At 12:25 PM +0100 9/24/08, Ashley Sheridan wrote:

On Wed, 2008-09-24 at 09:20 +0800, Shelley wrote:


The

Data Literacy Test:

http://www.phparch.cn/index.php/php/34-php-basics/202-the-data-literacy-test


What the smeg is this?

I don't know, but I figure 27.
Cheers,
tedd


yes, I think 27 aswell...

- Tul


No no no. We all know the answer is 42.

~Phil


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



Re: [PHP] was [PHP] Re: render html

2008-09-22 Thread Philip Thompson

On Sep 22, 2008, at 10:29 AM, tedd wrote:


At 10:15 AM -0500 9/22/08, Philip Thompson wrote:
And  is just not right at all (at least for XHTML, and I  
doubt for any other doctype). You can look at the DTD for XHTML and  
see that  is not an option.


http://www.w3.org/QA/2002/04/valid-dtd-list.html

~Philip



I never use the  tag, but if you look here:

http://www.w3.org/TR/2006/REC-xml-20060816/#dt-empty

You can see that they use it as an example, namely:

-- quote

Examples of empty elements:
http://www.w3.org/Icons/WWW/w3c_home"; />



-- un-quote

Cheers,

tedd


Odd. Never seen that. Well, it should be removed from existence!  
Nothing ever goes between br tags!


I like chicken.

Now how would that appear on screen?! Nobody knows! =D

~Phil

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



Re: [PHP] Re: Encrypt database table

2008-09-22 Thread Philip Thompson

On Sep 22, 2008, at 9:52 AM, Nathan Rixham wrote:


[EMAIL PROTECTED] wrote:

Hi,
What methods do you guys use to keep a mysql table encryped, or  
well atleast a major part of it. Security is very important and I  
want to use a public and private key. Is GPG the only safe way?  
It's hell of an overhead using GPG on every col, even a very short  
string is easily 1000 characters when encrypted in gpg.

Best Regards Emil
Personally my initial instinct is store everything on a secure non  
public facing database server and don't worry about encrypting the  
tables; if somebody can get in to your server and into the database  
then things need looked at higher up the access chain.


I understand what you're saying, but I don't completely agree with  
this. What happens when the DBA has a table of names and SSNs on  
screen and then gets up from his desk to run to the bathroom? In the  
fear that he may ruin is best slacks (err, jeans), he forgets to close  
the DB viewer or lock his desktop. Mr. ShouldntBeInHere walks by, sees  
the monitor of data and takes a picture with his new iPhone 3G and  
keeps walking. Well, now he just grabbed 50 names and SSNs. Uh oh!


Now, I understand that Mr. DBA should be held responsible for not  
taking the necessary precautions to make sure that no one else got to  
his database. However, if the database had been encrypted, then maybe,  
just maybe those names wouldn't have been exploited. But, in an effort  
to make sure that he is taking all the necessary precautions,  
shouldn't he have encrypted his database as well?



If it's a staffing thing then that's what permissions are for; and  
if it's for storing things like credit card details; just don't -  
the major payment gateways will do this for you so all you need to  
store is the transaction id's and auth codes.


regards

nathan


Also, there was this same question last Friday (I think) about  
encrypting DBs. Search the archives and/or ask a MySQL list.


But to not be a complete jerk... I use AES.

~Philip

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



Re: [PHP] was [PHP] Re: render html

2008-09-22 Thread Philip Thompson

On Sep 22, 2008, at 9:24 AM, tedd wrote:


At 8:37 PM +0100 9/21/08, Stut wrote:
That's what the DocType is. It tells the browser what version of  
(X)HTML you're using and therefore which tags are allowed and which  
are not. It has a major effect on some browsers, and if you use the  
right one it can help a lot when trying to make pages look the same  
in all browsers. Worth reading up on.


-Stut


-Stut:

I've done a lot of reading about DOCTYPE's and I realize that the  
DOCTYPE statement tells the browser what version of (X)HTML the web  
page is, but I never made the connection that would limit how one  
could use the  tag.


You know, you can read about the "br" tag everywhere without any  
mention of DOCTYPE.


So in the end, we have , , , and  --  
depending on what DOCTYPE you're using -- that sure makes things  
simpler, huh?


Thanks for enlightening me on this.

Cheers,

tedd


If you're using XHTML at all, when you do a 'br' tag, the '/' is  
required. Since XHTML (a type of XML) is only valid if well-formed,  
not having the trailing '/' causes the document to not be valid XML.


It does not matter if you have the space or not before the forward  
slash - the white space is ignored there anyway. So,




is not valid XHTML, but

 and 

are. I personally use the one without the space. And  is just  
not right at all (at least for XHTML, and I doubt for any other  
doctype). You can look at the DTD for XHTML and see that  is  
not an option.


http://www.w3.org/QA/2002/04/valid-dtd-list.html

~Philip

PS... tedd, I merely piggy-backed off of your email. This was meant  
for the list as a whole. ;)


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



Re: [PHP] Re: Problem with sorting

2008-09-22 Thread Philip Thompson


On Sep 21, 2008, at 2:24 PM, Eric Butera wrote:


On Sun, Sep 21, 2008 at 3:26 PM, Ashley Sheridan
<[EMAIL PROTECTED]> wrote:

On Sun, 2008-09-21 at 15:21 -0400, Eric Butera wrote:

On Sun, Sep 21, 2008 at 3:17 PM, Ashley Sheridan
<[EMAIL PROTECTED]> wrote:

On Sun, 2008-09-21 at 14:34 -0400, Eric Butera wrote:


Michelle Konzack wrote:



*   Do not Cc: me, because I READ THIS LIST, if I write  
here   *
*Keine Cc: am mich, ich LESE DIESE LISTE wenn ich hier  
schreibe*




Cute, get gmail and you won't have such problems.

I quite like the double emails thing, it makes me feel like I'm  
more popular

:p


Ash
www.ashleysheridan.co.uk


I could also always bcc replies to you so you get three.  How great
would that be? :D
Wow, I'd be like really popular if everyone did that! Does this  
really

mean that I need to get out more and make friends outside of the
Interweb?!


Ash
www.ashleysheridan.co.uk




No, the fact we're having this exchange on a Sunday is an  
indicator.  :(  *sigh*


LOL!

~Phil

PS... This was read and replied to on a Monday. =P


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



Re: [PHP] SESSIONS vs. MySQL

2008-09-22 Thread Philip Thompson

On Sep 20, 2008, at 7:28 AM, Ashley Sheridan wrote:


On Fri, 2008-09-19 at 10:17 -0500, Philip Thompson wrote:

Hi all.

Let me start out by saying, I have STFW and read through the list
archives. Now that that's out of the way.

To speed up our application, we want to implement using SESSIONs in
some locations. Beforehand, on every page, we would run approximately
30-40 queries just to get the page setup - user information and other
stuff. Now while we can't take away all of the setup queries, we  
would

like to reduce the startup number.

Ok, so I've implemented this in several places where information
basically does not change from page to page. Jumping to the point/
question... when does it become more inefficient to store lots of
information in SESSION variables than to run several more queries?
Note, we are actually storing sessions in the database - so a read/
write is required on each page load - it's not file sessions.

Now I know this can depend on the complexity of the queries and how
much data is actually stored inside the sessions... but initial
thoughts? To give you a number, the strlen of the _SESSION array is
325463 - which is equivalent to the number of bytes (I think).

Thanks,
~Philip

Why do you have so many queries? Is there any way you could use  
joins to

drop that number down. It might not seem like  lot when only a few
people are using the site, but it will start being a problem when you
get more people using it.


Ash


Well, there are different queries depending on how *far* you get into  
the app. If you fail at level 2, why already grab the data that's need  
at level 5 or 6? And besides, using joins is expensive. The queries  
pull different data - if there's no relation between tables, a join  
won't work. However, because the database is normalized (to the 3rd  
degree), we use joins all over the place.


~Phil


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



Re: [PHP] SESSIONS vs. MySQL

2008-09-19 Thread Philip Thompson

On Sep 19, 2008, at 4:01 PM, Stut wrote:


On 19 Sep 2008, at 21:44, Philip Thompson wrote:


On Sep 19, 2008, at 1:12 PM, Stut wrote:


On 19 Sep 2008, at 18:47, Philip Thompson wrote:

4. Grab user privs


IMHO you should only grab these when you need them.


I will need these on most pages anyway. Because of the  
architecture, the security class (which uses these a lot) is a  
separate part.


Fair enough, but I would suggest this is an ideal candidate for  
being kept in the session.


Yes, I agree - these can prob be moved into the session.


5. Grab user session (for application)


Again, why isn't this already in $_SESSION for every page request  
expect the first per visit?


This "user session" deals with merely keeping up with the time -  
how long has it been since this user accessed the site? Keep logged  
in? Logged in elsewhere? This uses the db and cookies. Note, this  
was designed into the app from the beginning... using the _SESSION  
var is new to the app as of this week. Yes, we can probably move  
this functionality into the new _SESSION stuff


Sounds like a lot of work for little benefit, but it sounds like it  
might be hard to remove so I'd probably live with it for a while too.


It may be some work... but it doesn't make sense to have session stuff  
in two different places. (I inherited this architecture, so I've been  
limited as to what I can do to some extent.) The question I have to  
ask myself now... will it be worth it in the future to have moved the  
session stuff to 1 class now? And do I have the time/resources to? =D



6. Begin transaction
7. Lock user session row
8. Update user session
9. Commit transaction


If all you're doing is issuing an update command there is no need  
to do so in a transaction and definitely no need to lock the row.  
An update is atomic.


Maybe what you actually mean to do here is lock it before you get  
the session data, make changes to it and then unlock it once  
you're done changing it. Doing that would likely keep the row  
locked for the entire duration of a request which can start  
causing problems as traffic increases.


I'm starting the transaction because MySQL "SELECT... FOR UPDATE"  
requires a transaction to lock the row. But now that I think about  
it... the reason we use the lock is so that we don't have  
collisions in data - specifically here the user session. However,  
the user session row is only accessed by a single user (his/her  
own). And since they can only be logged in at one location, there's  
virtually no way for a collision. Right? I can remove queries 6, 7,  
and 9, right?


Yes, you only need the update statement.


Ok, here, only the update is needed. But for other locations where  
multiple users may be accessing the same record, I should lock it.


Note that these are the 10 queries that happen after the initial  
SESSION load. I supposed I could reduce this by 1 or 2 queries -  
I could store the page id/information in the session. Now with  
that said, the queries are negligible (in elapsed time) and  
required.


However, I'm always open up to suggestions/improvements =D


You may think they're required, but I'm betting they're not if you  
really think about it. However, if your DB can handle it then why  
fix something that ain't broken.


It can handle it now. But I'm not worried about now. We have less  
than 10 clients/offices using the app. This may grow up to 100  
within the next year. That's when there's gonna be lots and lots of  
data and we may start to see a slow down.


That's not even close to a large number of users, but it depends a  
lot on what else the servers you're hosting it on are being used for.


A client may have 1 user or 50 users. It's not the user-size I'm  
concerned about. This software is for doctor's offices. So, last week  
when we had our first import from another practice management system  
(aptly acronym'd, PMS), our patient records jumped from about 1,000 to  
65,000. That's just 1 client! Now, I still know that's not a whole  
lot, but multiply that by 100 clients in the next year: 64000 * 100 =  
6.4 million patient records. That's more of a significant number.


We're using a dedicated server that hosts the website and the  
database. I *know* we're going to need to expand... but that's beyond  
my control as a mere pawn. As of today, it's okay.


The way I approach this stuff is always with the knowledge that  
the database is the most expensive resource in the infrastructure,  
so anything I can do to avoid using it when it's not strictly  
necessary is something I consider well-worth the effort.


With the rise of frameworks and the lazy architectures it's pretty  
common to end up with this mass of DB access at the start of each  
request, but it won't sca

Re: [PHP] SESSIONS vs. MySQL

2008-09-19 Thread Philip Thompson

I have more questions/responses throughout...

On Sep 19, 2008, at 1:12 PM, Stut wrote:


On 19 Sep 2008, at 18:47, Philip Thompson wrote:

I've narrowed it down to 10 initial queries...

1. Grab system config data (that's used in lots of places)


Does it change often? No? Then cache it in a PHP script. Use  
var_export to create a file that you can include which will create  
the configuration array. Alternatively cache it in a Memcache  
instance which is where my system-wide config usually lives.


Good idea.


2. Grab session data (for SESSION array)


Meaning what? You say below that this is after the initial session  
load. What are you loading here and why is it being loaded on every  
page request if it's ending up in the $_SESSION array?


Because I'm using your class, Stut, (at least as a reference) to store  
my sessions in the database. Hence, I have to pull them from the  
database.



3. Grab page id


What does this do, how is it used, is it needed?


I was able to add this to the SESSION.


4. Grab user privs


IMHO you should only grab these when you need them.


I will need these on most pages anyway. Because of the architecture,  
the security class (which uses these a lot) is a separate part.



5. Grab user session (for application)


Again, why isn't this already in $_SESSION for every page request  
expect the first per visit?


This "user session" deals with merely keeping up with the time - how  
long has it been since this user accessed the site? Keep logged in?  
Logged in elsewhere? This uses the db and cookies. Note, this was  
designed into the app from the beginning... using the _SESSION var is  
new to the app as of this week. Yes, we can probably move this  
functionality into the new _SESSION stuff



6. Begin transaction
7. Lock user session row
8. Update user session
9. Commit transaction


If all you're doing is issuing an update command there is no need to  
do so in a transaction and definitely no need to lock the row. An  
update is atomic.


Maybe what you actually mean to do here is lock it before you get  
the session data, make changes to it and then unlock it once you're  
done changing it. Doing that would likely keep the row locked for  
the entire duration of a request which can start causing problems as  
traffic increases.


I'm starting the transaction because MySQL "SELECT... FOR UPDATE"  
requires a transaction to lock the row. But now that I think about  
it... the reason we use the lock is so that we don't have collisions  
in data - specifically here the user session. However, the user  
session row is only accessed by a single user (his/her own). And since  
they can only be logged in at one location, there's virtually no way  
for a collision. Right? I can remove queries 6, 7, and 9, right?


10. Add page tracking (an insert-only table that keeps track of  
pages you visit)


I handle this using files and then have an offline processor to push  
that data into the database. If all you're doing is adding a row to  
the table you probably don't need this, but we do a fair amount of  
work for each page view to record the data in a set of tables  
designed for meaningful and speedy retrieval.


Note that these are the 10 queries that happen after the initial  
SESSION load. I supposed I could reduce this by 1 or 2 queries - I  
could store the page id/information in the session. Now with that  
said, the queries are negligible (in elapsed time) and required.


However, I'm always open up to suggestions/improvements =D


You may think they're required, but I'm betting they're not if you  
really think about it. However, if your DB can handle it then why  
fix something that ain't broken.


It can handle it now. But I'm not worried about now. We have less than  
10 clients/offices using the app. This may grow up to 100 within the  
next year. That's when there's gonna be lots and lots of data and we  
may start to see a slow down.


The way I approach this stuff is always with the knowledge that the  
database is the most expensive resource in the infrastructure, so  
anything I can do to avoid using it when it's not strictly necessary  
is something I consider well-worth the effort.


With the rise of frameworks and the lazy architectures it's pretty  
common to end up with this mass of DB access at the start of each  
request, but it won't scale and it leads to assumptions that are  
extremely expensive to find and fix when you do need to scale. Trust  
me, I've been there many times and it's been painful every time!


Can you explain why it won't scale and may lead to assumptions?

Oh, and by scale I don't necessarily mean to tens of millions of  
page views a month. Scalability is as much about going from 10  
visitor a day to 1000 as it is from 1000 to several million.


-Stut


Thanks,
~Philip


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



Re: [PHP] SESSIONS vs. MySQL

2008-09-19 Thread Philip Thompson

On Sep 19, 2008, at 1:12 PM, Stut wrote:


On 19 Sep 2008, at 18:47, Philip Thompson wrote:

I've narrowed it down to 10 initial queries...

1. Grab system config data (that's used in lots of places)


Does it change often? No? Then cache it in a PHP script. Use  
var_export to create a file that you can include which will create  
the configuration array. Alternatively cache it in a Memcache  
instance which is where my system-wide config usually lives.



2. Grab session data (for SESSION array)


Meaning what? You say below that this is after the initial session  
load. What are you loading here and why is it being loaded on every  
page request if it's ending up in the $_SESSION array?



3. Grab page id


What does this do, how is it used, is it needed?


4. Grab user privs


IMHO you should only grab these when you need them.


5. Grab user session (for application)


Again, why isn't this already in $_SESSION for every page request  
expect the first per visit?



6. Begin transaction
7. Lock user session row
8. Update user session
9. Commit transaction


If all you're doing is issuing an update command there is no need to  
do so in a transaction and definitely no need to lock the row. An  
update is atomic.


Maybe what you actually mean to do here is lock it before you get  
the session data, make changes to it and then unlock it once you're  
done changing it. Doing that would likely keep the row locked for  
the entire duration of a request which can start causing problems as  
traffic increases.


10. Add page tracking (an insert-only table that keeps track of  
pages you visit)


I handle this using files and then have an offline processor to push  
that data into the database. If all you're doing is adding a row to  
the table you probably don't need this, but we do a fair amount of  
work for each page view to record the data in a set of tables  
designed for meaningful and speedy retrieval.


Note that these are the 10 queries that happen after the initial  
SESSION load. I supposed I could reduce this by 1 or 2 queries - I  
could store the page id/information in the session. Now with that  
said, the queries are negligible (in elapsed time) and required.


However, I'm always open up to suggestions/improvements =D


You may think they're required, but I'm betting they're not if you  
really think about it. However, if your DB can handle it then why  
fix something that ain't broken.


The way I approach this stuff is always with the knowledge that the  
database is the most expensive resource in the infrastructure, so  
anything I can do to avoid using it when it's not strictly necessary  
is something I consider well-worth the effort.


With the rise of frameworks and the lazy architectures it's pretty  
common to end up with this mass of DB access at the start of each  
request, but it won't scale and it leads to assumptions that are  
extremely expensive to find and fix when you do need to scale. Trust  
me, I've been there many times and it's been painful every time!


Oh, and by scale I don't necessarily mean to tens of millions of  
page views a month. Scalability is as much about going from 10  
visitor a day to 1000 as it is from 1000 to several million.


-Stut


Robert/Stut,

Thanks for your words of wisdom. ;) I will take what you've said back  
to my team for us to discuss. That's why I like this list - allows me  
to view the problem(s) from a different angle, or two. ;)


~Philip


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



Re: [PHP] SESSIONS vs. MySQL

2008-09-19 Thread Philip Thompson

On Sep 19, 2008, at 11:10 AM, Eric Butera wrote:


On Fri, Sep 19, 2008 at 12:05 PM, Philip Thompson
<[EMAIL PROTECTED]> wrote:

On Sep 19, 2008, at 10:54 AM, Wolf wrote:


 Philip Thompson <[EMAIL PROTECTED]> wrote:


Hi all.

Let me start out by saying, I have STFW and read through the list
archives. Now that that's out of the way.

To speed up our application, we want to implement using SESSIONs in
some locations. Beforehand, on every page, we would run  
approximately
30-40 queries just to get the page setup - user information and  
other
stuff. Now while we can't take away all of the setup queries, we  
would

like to reduce the startup number.

Ok, so I've implemented this in several places where information
basically does not change from page to page. Jumping to the point/
question... when does it become more inefficient to store lots of
information in SESSION variables than to run several more queries?
Note, we are actually storing sessions in the database - so a read/
write is required on each page load - it's not file sessions.

Now I know this can depend on the complexity of the queries and how
much data is actually stored inside the sessions... but initial
thoughts? To give you a number, the strlen of the _SESSION array is
325463 - which is equivalent to the number of bytes (I think).

Thanks,
~Philip


We carry a sh!tload of information in our session, without slowing
anything down.  In fact, it takes the servers longer to run a full  
query

then to use the session information.

But we use the $_SESSION information.  Our first query sets  
everything up
in the session and we take on from there, and use stuff from the  
$_SESSION

to actually make the rest of the pages faster.

30-40 queries just to set up a page?  That's an abomination that  
shouldn't

see the light of day.

Anything slower then 2 seconds without any interaction back to the  
users

will be short-lived

Wolf


Even with 30-40 queries upon setup, it's very fast - less than 1  
second...
for now. We starting having speed issues in other locations. Hence,  
we
decided to address every potential reason and possible slowndown in  
the

future.

Thanks for your input, Wolf. Any others storing sh!tloads in their  
SESSION

array? =D

~Philip


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




I used to store objects in the session.  I figured I used it a lot so
why not.  Then my app got really nasty and slow.  Now I only store
enough of the state to render the page.  So instead of storing a
complete user object I store the auth details to load a user object if
needed.  Only very simple parts of the state get loaded into my apps
now.  Now things are quite snappy again.

Why do you have so many queries?   Perhaps we can attack this issue
from another angle.


I've narrowed it down to 10 initial queries...

1. Grab system config data (that's used in lots of places)
2. Grab session data (for SESSION array)
3. Grab page id
4. Grab user privs
5. Grab user session (for application)
6. Begin transaction
7. Lock user session row
8. Update user session
9. Commit transaction
10. Add page tracking (an insert-only table that keeps track of pages  
you visit)


Note that these are the 10 queries that happen after the initial  
SESSION load. I supposed I could reduce this by 1 or 2 queries - I  
could store the page id/information in the session. Now with that  
said, the queries are negligible (in elapsed time) and required.


However, I'm always open up to suggestions/improvements =D

Thanks,
~Phil


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



Re: [PHP] SESSIONS vs. MySQL

2008-09-19 Thread Philip Thompson

On Sep 19, 2008, at 10:54 AM, Wolf wrote:


 Philip Thompson <[EMAIL PROTECTED]> wrote:

Hi all.

Let me start out by saying, I have STFW and read through the list
archives. Now that that's out of the way.

To speed up our application, we want to implement using SESSIONs in
some locations. Beforehand, on every page, we would run approximately
30-40 queries just to get the page setup - user information and other
stuff. Now while we can't take away all of the setup queries, we  
would

like to reduce the startup number.

Ok, so I've implemented this in several places where information
basically does not change from page to page. Jumping to the point/
question... when does it become more inefficient to store lots of
information in SESSION variables than to run several more queries?
Note, we are actually storing sessions in the database - so a read/
write is required on each page load - it's not file sessions.

Now I know this can depend on the complexity of the queries and how
much data is actually stored inside the sessions... but initial
thoughts? To give you a number, the strlen of the _SESSION array is
325463 - which is equivalent to the number of bytes (I think).

Thanks,
~Philip


We carry a sh!tload of information in our session, without slowing  
anything down.  In fact, it takes the servers longer to run a full  
query then to use the session information.


But we use the $_SESSION information.  Our first query sets  
everything up in the session and we take on from there, and use  
stuff from the $_SESSION to actually make the rest of the pages  
faster.


30-40 queries just to set up a page?  That's an abomination that  
shouldn't see the light of day.


Anything slower then 2 seconds without any interaction back to the  
users will be short-lived


Wolf


Even with 30-40 queries upon setup, it's very fast - less than 1  
second... for now. We starting having speed issues in other locations.  
Hence, we decided to address every potential reason and possible  
slowndown in the future.


Thanks for your input, Wolf. Any others storing sh!tloads in their  
SESSION array? =D


~Philip


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



Re: [PHP] Adding encryption to passwords

2008-09-19 Thread Philip Thompson

On Sep 19, 2008, at 9:00 AM, Nathan Rixham wrote:


Per Jessen wrote:

Thodoris wrote:

So  what do you think is  the best way to use crypt, mcrypt, hash or
perhaps md5 and what are really the differences because I am not  
sure

if I get it right.

We use md5 for that sort of thing. /Per Jessen, Zürich


sha 256 is my prefered encryption, no collision to speak of or  
decrytion tables; also returns back a 64char string; which can be  
stored in a mysql BINARY(64) column which is v fast with the  
appropriate index.


If you're using MySQL:

http://dev.mysql.com/doc/refman/5.0/en/encryption-functions.html

We use AES de/encryption. Works well. =D

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



  1   2   3   4   >