Re: [PHP] Replacing accented characters?

2010-01-28 Thread Paul M Foster
On Thu, Jan 28, 2010 at 02:38:52PM -0500, tedd wrote:

snip

 My point was more to the theme that we are an eclectic group of people 
 with a wide range of knowledge and skills. Individually we may have  
 trouble finding our ass, but together we can find the answer to many 
 things.

I just got this image of all of us at a table at the local Chili's
twirling around in place like dogs, trying to find our asses. giggle

Paul

-- 
Paul M. Foster

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



Re: [PHP] Creating an Entire .html page with PHP

2010-01-28 Thread Paul M Foster
On Fri, Jan 29, 2010 at 08:17:34AM +1100, clanc...@cybec.com.au wrote:

 On Thu, 28 Jan 2010 21:10:42 +0100, rene7...@gmail.com (Rene Veerman) wrote:
 
 On Thu, Jan 28, 2010 at 12:31 AM,  clanc...@cybec.com.au wrote:
  On Wed, 27 Jan 2010 10:21:00 -0800, deal...@gmail.com (dealtek) wrote:
 Opening tables, etc, wrongly generally messes the page up completely, but
  forgetting to close them again often has no affect no visible effect
 at all -- until you
  make some innocent change and everything goes haywire!
 
 whenever i write an opening tag, i immediately write the closing tag
 next, then cursor back to fill it in.
 
 Not so easy when you are using PHP to generate a complex layout!

Use heredocs to do it. Then you can generate the layout in PHP and still
do what deal...@gmail.com said.

Paul

-- 
Paul M. Foster

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



[PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Paul M Foster
... should be obvious - but are often overlooked - points within coding
practice that can cause the programmer to develop bad habits and bad
code. - Dan Brown

Tip #1:

Don't use count() in loops unless there are very few items to count and
performance doesn't matter, or the number will vary over the loop. That
is, don't do this:

for ($i = 0; $i  count($items); $i++)

Instead, do this:

$number = count($items);
for ($i = 0; $i  $number; $i++)

Reason: when you use the count() call at the top of the loop, it will
re-evaluate the number of items each time it's called, which usually
isn't necessary and adds time. Instead, work out the number of items
before going into the loop and simply refer to that for the number of
items in controlling the loop.

Paul

-- 
Paul M. Foster

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



Re: [PHP] DirectoryIterator

2010-01-26 Thread Paul M Foster
On Tue, Jan 26, 2010 at 10:01:12PM +0100, Kim Madsen wrote:

 Christoph Boget wrote on 26/01/2010 21:17:
 I've looked through the docs but was unable to find out if this is
 possible;
 I hope it is.  Is there a way that you get the size/length of the
 collection
 to be iterated (e.g. the total number of files) without having to iterate
 through at least once?

 On Linux with safe mode off you can call system(du -hcs THE_DIR) to
 get the size of all files, no iterations needed.

This assumes the du command is available on the host system. Check
first to make sure.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Speed of sending email .. can I put them in a queue rather than wait?

2010-01-26 Thread Paul M Foster
On Wed, Jan 27, 2010 at 10:07:13AM +0800, Eric Lee wrote:

 Hi, all
 
 I'am doubted about installing a local mail server for just low volume
 mailing.
 May I ask all yours professional what do you think about it ?
 

Every place I've ever hosted (all Linux servers) include a local MTA
which is up and running. In a large hosting operation, this local MTA
probably passes the mail for relay to a central MTA somewhere else in
the host's network. There are a variety of reasons for this. Among
others, it allows the hosting company to meter email and present a
single set of credentials to foreign (offsite) mail servers. And in
general, most hosting companies provide you with the location of the
local MTA, in case you need it for Perl, Python, cron or other scripts.
And PHP's mail() function will, by default, pass email to that local
MTA. And moreover, most (all?) Linux MTAs on boxes like this don't block
while they make connections. From the OP's description, it sounded like
his phpmailer() process was blocking while it made foreign connections.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Do you use a public framework or roll your own?

2010-01-26 Thread Paul M Foster
On Tue, Jan 26, 2010 at 04:17:26PM -0800, Daevid Vincent wrote:

snip

 And for those interested, here are the results of the last poll:
 
 To add the final ? in PHP or not...
 http://www.rapidpoll.net/show.aspx?id=arc1opy
 
 I'm relieved to know I'm in the majority (almost 2:1) who close their
 opening PHP tags. :)

Gosh, I can't believe so many people could be so *wrong*. ;-}

Paul

-- 
Paul M. Foster

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



Re: [PHP] Do you use a public framework or roll your own?

2010-01-26 Thread Paul M Foster
On Tue, Jan 26, 2010 at 04:17:26PM -0800, Daevid Vincent wrote:

 
 I'm not looking to start a holy war here or re-hash the tired debate.
 I just want some hard cold numbers to look at.
 
 Do you use a public framework or roll your own?
 http://www.rapidpoll.net/8opnt1e

I voted, but like others, my framework is more a collection of home
grown tools which seem to have generic applicability.

Some of this may be because I worked for many years in construction. You
get used to certain tools and the way they operate, and you prefer them.
For example, I won't use screwdrivers whose handles aren't covered with
rubber over the plastic of the handles (Stanley and Klein brands).

What I like about programming is that you get to build your own tools,
just the way you like them. ;-}

Paul

-- 
Paul M. Foster

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



[PHP] Magic Methods not working

2010-01-26 Thread Paul M Foster
I have a class which instantiates other classes, and has a magic method
like this:

function _get($classname)
{
return $this-instantiate($classname);
}

Obviously, the class also has an instantiate method which does what it
says.

Here's the problem: When I call the instantiate method, it works fine,
like this:

$db = $sc-instantiate('database');

But when I do the following, it *doesn't* work:

$db = $sc-database;

In fact it does not call the instantiate() method; I've placed a print
statement in the instantiate() method which fires at then end of the
routine. That statement doesn't fire with the above code.

The docs on magic methods are pretty slim, so I'm not sure what it is
I'm missing. Can someone enlighten me?

Paul


-- 
Paul M. Foster

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



Re: [PHP] Magic Methods not working

2010-01-26 Thread Paul M Foster
On Wed, Jan 27, 2010 at 11:19:34AM +0800, Eric Lee wrote:

 
 
 On Wed, Jan 27, 2010 at 11:04 AM, Paul M Foster pa...@quillandmouse.com
 wrote:
 
 I have a class which instantiates other classes, and has a magic method
 like this:
 
 function _get($classname)
 {
        return $this-instantiate($classname);
 }
 
 Obviously, the class also has an instantiate method which does what it
 says.
 
 Here's the problem: When I call the instantiate method, it works fine,
 like this:
 
 $db = $sc-instantiate('database');
 
 But when I do the following, it *doesn't* work:
 
 $db = $sc-database;
 
 In fact it does not call the instantiate() method; I've placed a print
 statement in the instantiate() method which fires at then end of the
 routine. That statement doesn't fire with the above code.
 
 The docs on magic methods are pretty slim, so I'm not sure what it is
 I'm missing. Can someone enlighten me?
 
 Paul
 
 
 
 Paul,
 
 I seem that you should missed the required underscore  _  
 It should the __get() but not _get().
 Shall this help ?

Great Caesar's Ghost! You're right! Thanks.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Reliable way to identify Ogg types?

2010-01-26 Thread Paul M Foster
On Tue, Jan 26, 2010 at 07:23:24PM -0800, Michael A. Peters wrote:

 When I use fileinfo on an uploaded Ogg file, the mime it returns is
 Application/Ogg which is almost useless.

 Is there a reliable php way, preferably without needing to execute shell
 commands, to positively identify a file as Ogg Theora or Ogg Vorbis?

Judging by the return, the OS is looking at the mime.types file, which
(on my box at least) doesn't know anything more than this.

In order to get what you want, I'm afraid you might have to open the
file and examine its first few bytes using the data from
/usr/share/file/magic, which has a more thoroughgoing understanding of
ogg files. Unless someone's built a class which does this for you.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Magic Methods not working

2010-01-26 Thread Paul M Foster
On Tue, Jan 26, 2010 at 07:21:34PM -0800, Daevid Vincent wrote:

  -Original Message-
  From: Paul M Foster [mailto:pa...@quillandmouse.com]
  Sent: Tuesday, January 26, 2010 7:05 PM
  To: php-general@lists.php.net
  Subject: [PHP] Magic Methods not working
 
  I have a class which instantiates other classes, and has a
  magic method
  like this:
 
  function _get($classname)
  {
  return $this-instantiate($classname);
  }
 
  Obviously, the class also has an instantiate method which does what it
  says.
 
  Here's the problem: When I call the instantiate method, it works fine,
  like this:
 
  $db = $sc-instantiate('database');
 
  But when I do the following, it *doesn't* work:
 
  $db = $sc-database;
 
  In fact it does not call the instantiate() method; I've placed a print
  statement in the instantiate() method which fires at then end of the
  routine. That statement doesn't fire with the above code.
 
  The docs on magic methods are pretty slim, so I'm not sure what it is
  I'm missing. Can someone enlighten me?
 
  Paul
 
 http://us2.php.net/manual/en/language.oop5.magic.php
 
 There are TWO underscores needed, not one.
 
 __get()
 
 Also, just to save you some time/grief, you might consider using my awesome
 routines:
 
 Put these in your base.class.php and extend it for all other classes.
 Magic.

Oh no. I can't use those. The braces are in all the wrong places! (All
praise be to KR...) ;-}

Paul

-- 
Paul M. Foster

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



Re: [PHP] If the first four characters are 0000, then do {}

2010-01-25 Thread Paul M Foster
On Mon, Jan 25, 2010 at 09:36:50PM -0500, John Taylor-Johnston wrote:

 I am reading the manual: http://ca.php.net/manual/en/ref.strings.php

 $mydata-restored = -00-00;

 How do I express this? If the first four characters are , then do {}

 What I am looking for is in strpos(), no?

 if ()
 {
 }

From what I understand, strpos() faster than a lot of other similar
string functions and much faster than regexps. You could do:

if (strpos($mydata-restored, '') === 0) {
do_stuff();
}

Paul

-- 
Paul M. Foster

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



Re: [PHP] In need of better __FILE__, __LINE__ and __FUNCTION__ magic variables

2010-01-25 Thread Paul M Foster
On Mon, Jan 25, 2010 at 10:59:43PM -0500, Robert Cummings wrote:

 Daevid Vincent wrote:
 Like you, I have many little functions that are useful for debugging in a
 page.

 The problem is that when you start to pepper them around, whilst debugging,
 you can often times forget where you left them. A search isn't always
 helpful since I sometimes leave them in the code, but commented out, so I
 end up finding dozens of matches.

 What I need are some variables that tell me the current calling file, line
 and function I'm in. Then when I see some debug info on the screen, I know
 exactly where it came from.

 Use debug_backtrace() to capture the information from within the
 print_debug() or other deeper function. Just grab the second (or
 further) stack item that corresponds to the location where print_debug()
 was called.

+1

Or you can use debug_print_backtrace(), which directly outputs the
backtrace. I do this when my error handler encounters E_USER_ERROR and
the like.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Speed of sending email .. can I put them in a queue rather than wait?

2010-01-25 Thread Paul M Foster
On Tue, Jan 26, 2010 at 02:02:18PM +1000, Angus Mann wrote:

 Hi all.
 
 I'm currently using the phpmailer class from phpmailer.worxware.com to send 
 datatbase -populated emails to clients.
 
 At the moment I'm runninng PHP on Windows and using the built-in sendmail 
 equivalent packaged with XAMPP. It uses a remote SMTP that authenticates by 
 prior logging into a POP account.
 
 The number of emails sent is very small. Each one is only sent after a user 
 fills out a form and presses send.
 
 But there is a noticable lag of about 5 or sometimes 10 seconds after 
 pressing send before the user sees the Mail sent page. I presume the 
 reason for the lag is the time spent logging on and off a remote POP, then 
 SMTP server, transferring the data etc.
 
 It would be better if this happened in the background - that is, the user 
 could get on with doing his next task while the emails sat in a queue in the 
 backgorund, being lined up and sent without PHP waiting for the process to 
 finish.
 
 Can anybody recommend a good way of doing this? Is Mercury Mail going to help 
 me here?
 

If this were me, I'd set up a mailserver on the web machine and send
mail to it instead of using phpmailer to connect directly to a distant
mailserver. The authentication between phpmailer and the local
mailserver should be near instantaneous, and you can let the local
mailserver deal with transferring mails in its own sweet time. I don't
know if there's a mailserver included in XAMPP installations, but if so,
I'd do that. In fact, if you're just sending simple emails, you could
use PHP's built-in mail() function, which will connect directly to the
local mailserver without further configuration.

Paul

-- 
Paul M. Foster

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



Re: [PHP] SQL question

2010-01-25 Thread Paul M Foster
On Mon, Jan 25, 2010 at 09:54:40PM -0600, Skip Evans wrote:

 Hey all,

 I have an SQL query that's stumping me.

 I have two date variables, $start and $end that are in
 mm/dd/ format and two database fields, start_date and
 no_donations. The start date is mm/dd/ format and
 no_donations is an integer that represents the number of
 months from start_date that donations will be made.

 So if start date is say 02/01/2010 and no_dations is 4 then
 donations will be made four times from the start date for four
 months.

 What I need to do is come up with a query that will determine
 if the start_date + no_donations falls within $start and $end.

 But I'm pretty stumped. How can I convert start_date +
 no_donations in the database to the date when the last
 donation will take place so I'll now if the donations fall
 between $start and $end?

 Any suggestions would be very help and appreciated,

If there's a way to do this in SQL itself, I don't know what it is. But
in my opinion, you need a date class which can do date comparisons.

(If you end up programming one yourself, save yourself some time and
convert all dates to Julian day numbers internally. This saves massive
amounts of computation in determining intervals and durations.
Typically, coders try to store dates in unix timestamps internally, and
then add 86400 seconds for every day to calculate intervals and such.
This is often inaccurate. Julian days are far more accurate.)

Paul

-- 
Paul M. Foster

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



Re: [PHP] If the first four characters are 0000, then do {}

2010-01-25 Thread Paul M Foster
On Mon, Jan 25, 2010 at 08:12:43PM -0800, Daevid Vincent wrote:

  -Original Message-
  From: Paul M Foster [mailto:pa...@quillandmouse.com]
  Sent: Monday, January 25, 2010 8:05 PM
  To: php-general@lists.php.net
  Subject: Re: [PHP] If the first four characters are , then do {}
 
  On Mon, Jan 25, 2010 at 09:36:50PM -0500, John Taylor-Johnston wrote:
 
   I am reading the manual: http://ca.php.net/manual/en/ref.strings.php
  
   $mydata-restored = -00-00;
  
   How do I express this? If the first four characters are
  , then do {}
  
   What I am looking for is in strpos(), no?
  
   if ()
   {
   }
 
  From what I understand, strpos() faster than a lot of other similar
  string functions and much faster than regexps. You could do:
 
  if (strpos($mydata-restored, '') === 0) {
  do_stuff();
  }
 
 Ah. Clever use of the == 0 (tripple equals not necessary).

No, the === was purposeful, since strpos can return false if there's no
match. If you simply use == 0, it will trigger on both false, and the
0 index. If you use !== false, you're only testing for no match.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Object Oriented Programming question

2010-01-20 Thread Paul M Foster
On Wed, Jan 20, 2010 at 06:47:04AM -0600, Jay Blanchard wrote:

 [snip]
  Another advantage of OOP that is difficult to
  provide via the procedural paradigm is polymorphism.
 
 Agreed. Though the advantages of polymorphism are questionable,
 depending on your viewpoint.
 [/snip]
 
 In a loosely typed language like PHP that advantages of polymorphism far
 outweigh any potential disadvantages, especially where virtual functions
 are concerned. 

My viewpoint may be jaundiced from having programmed in C++, but the
polymorphism of PHP seems a little crippled by comparison.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Object Oriented Programming question

2010-01-20 Thread Paul M Foster
On Wed, Jan 20, 2010 at 10:11:18AM -0500, tedd wrote:

snip


 While I teach OOP, I don't write any OOP for clients. My charge is to
 do things quickly and OOP requires a considerable amount of analysis
 before creating a solution. In most cases, I don't have the time.
 Besides, I'm more of an agile programmer and that doesn't lend itself
 well to OOP, IMO.

This is a fascinating viewpoint. It's almost a sideways condemnation of
OOP: It takes too long to write OOP for customers. (I know that's not
how you meant it.) But I have to agree, with one proviso. I tend to
write mostly procedural for clients because of time constraints. But I
believe part of the reason I do this is because I haven't built generic
OO components ahead of time which lend themselves to being used on
client sites. If I had spent the considerable time to build OO
components which were usable in this context, I'd be happy to use them.
OTOH, MVC (OOP on steroids) is just beyond reasonable in most cases for
client sites.

I will also echo that it takes a lot of time/work to correctly build OO
components, compared to straight functions or function libraries.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Open Source CMS

2010-01-20 Thread Paul M Foster
On Thu, Jan 21, 2010 at 11:29:54AM +0800, Hendry wrote:

 Hi,
 
 Anyone can share your favorite PHP open source CMS to work with and
 what's the reason? I'm looking for something that easily extensible.
 I've googled and found severals but I'm still confused, some from the
 lists:
 - Drupal
 - Tomato CMS
 - modx
 - xoops
 - Symphony

Add CodeIgniter to your list. Relatively easy to understand and extend.
Though I'm not sure I'd classify it as a content management system.
(Same for Symfony.)

Paul

-- 
Paul M. Foster

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



Re: [PHP] Open Source CMS

2010-01-20 Thread Paul M Foster
On Wed, Jan 20, 2010 at 08:15:55PM -0800, Allen McCabe wrote:

 For a work in progress, view http://www.mwclans.com/new_index.php
 
 The login fields are a 'component' I include in the header.
 The links are generated from the 'links' table; the primary_navigation links
 are a class by the same name, and the 'footer_navigation' are also a
 different category. All links on this page are generated from the Links
 table, and each row has 90% of the properties the HTML 'a' tag can have (eg.
 fields: id, link_text, href, target, onmouseover, onmouseout, onclick, name,
 class, etc.). The class is the same as the category.
 
 The content is pulled from an include file with the same ID number as this
 page (home page), which is 1, and the scripts.
 
 There are additional features, like a theme class which pulls a theme ID
 from the DB (a `site_settings` table).
 
 Here is an example of the source code for the above link:
 

You're free to do this as you like, and I've done it in the past just as
you did. But I think the general concensus is that you want to
intersperse as little complicated PHP inside your HTML as possible. For
example, you're doing a database call inside your HTML and then
displaying the results. The more acceptable practice is to make these
calls before you start outputting HTML, shove the values into variables
or an array, and then just loop through the *values* inside your HTML.
There are a couple of reasons for doing it this way. First, anyone
looking at the HTML later who isn't a programmer will have an easier
time of it if there aren't lines and lines of PHP code inside the HTML.
Second, it makes your code more modular. That is, it puts your main
body of PHP code all together. That aids in debugging, testing and the
like later. This approach means your code is dispersed among several
files instead of just one. But it aids in debugging. I find it painful
to have to scan through HTML for PHP code, so I can fix a problem.

You'll also find that if you have a variety of pages which are all laid
out the same way, it's better to put that HTML in a separate template
file. Insert some code in it to display values as needed. Then when you
want to paint a page, simply define the values you want to display, and

include('template.php');

This way, if you make a change to the design or look of the site, you
can make that change to one (template) file and it will echo all over
the site. This is particularly important if you're working with
designers who don't know HTML but do the work of designing pages.

This is just simple advice based on my experience. Feel free to ignore
it completely if you work better a different way.

Paul

-- 
Paul M. Foster

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



Re: [PHP] header(Location:...) fails

2010-01-13 Thread Paul M Foster
On Wed, Jan 13, 2010 at 11:39:18AM -0800, Richard S. Crawford wrote:

 Here is a snippet of code that is going to be the death of me:
 
 
 //  Create a new project
 $projectcode = strtoupper(addslashes($_POST['projectcode']));   //  project
 code
 
 //  Make sure the project code is unique
 if (!$existingproject = mysql_query(select * from pb_versions where
 projectcode like '.strtoupper($projectcode).')) {
 die (Could not check for existing project code!br /.mysql_error());
 }
 
 $numprojects = mysql_num_rows($existingproject);
 
 if ($numprojects  0) {
 $pid = mysql_result($existingproject,0,versionID);
 header(Location:managebudget.php?e=1pid=$pid);
 }
 
 
 Now, even if $numprojects is 1, 2, 3, etc., the header() command is not
 executed. Strangely, a header(Location) command later on in the script
 *is* executed. I've output the value of $numprojects, so I know that it's
 greater than 0, so the command
 header(Location:managebudget.php?e=1pid=$pid); *should* be executed...
 but it isn't. (Weirdly, if I put a die() command *after* this header()
 command, it works... but it seems pathologically inelegant to do so.)
 
 Obviously, I'm missing something incredibly basic. Can anyone help me figure
 this out?

For one thing, I'd put a space after Location: in the header() call.
But I've found that this call will sometimes fail (or *look* like it
fails) unless you put something like exit(); after it. This terminates
execution and forces the script to transfer control as it should. Just
make it a habit to always include and exit(); call after your final
header() call.

Paul

-- 
Paul M. Foster

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



Re: [PHP] php and XML BibTeX

2010-01-13 Thread Paul M Foster
On Wed, Jan 13, 2010 at 12:45:53PM -0800, Michael A. Peters wrote:

 Hi -

 Currently on my web site, book and article references are just stored in
 the database. While it works, I actually would like to move that out of
 the database and to an XML file, the reason being is that if/when I need
 to add fields etc. to the referenced sources, it's a lot easier to just
 edit a text file than modify database and recode my form interface for
 modifying the database. Also, there's an existing XML format for bibTeX
 and there already are tools to go from that to real bibTex, which I
 may need to do at some point.

 What I'm hoping is that already exists some php classes / functions for
 dealing with the XML bibTeX but I haven't found them. Anyone know of any?

I don't know, but the first place I look for things like that is
phpclasses.org.

Paul

-- 
Paul M. Foster

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



Re: [PHP] POLL: To add the final ? or not...

2010-01-12 Thread Paul M Foster
On Tue, Jan 12, 2010 at 05:24:06PM +, Ashley Sheridan wrote:

 On Tue, 2010-01-12 at 12:22 -0500, Robert Cummings wrote:
 
  Michael A. Peters wrote:
   LinuxManMikeC wrote:
   On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com
 wrote:
   I'm having a debate with a co-worker about adding the final ? on a PHP
   page...
  
   So everybody, when do we get to the real discussion?  Which end of an
   egg do we break?
  
  
   Depends upon how far away the Perl developer is when we throw it, and
   how much spin we put on it.
 
  You'll want to know initial release speed and drag on the egg while in
  flight to calculate time so you can correctly determine how many spins
  occur over the throw distance.
 
  Cheers,
  Rob.
  --
  http://www.interjinn.com
  Application and Templating Framework for PHP
 
 
 
 There's always a chance that if thrown, the egg won't contact end-on.
 Has anyone thought to factor this in?

Is that an African or European egg?

Paul

-- 
Paul M. Foster

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



Re: [PHP] POLL: To add the final ? or not...

2010-01-12 Thread Paul M Foster
On Tue, Jan 12, 2010 at 06:08:59PM +, Ashley Sheridan wrote:

 On Tue, 2010-01-12 at 13:10 -0500, Paul M Foster wrote:
 
 On Tue, Jan 12, 2010 at 05:24:06PM +, Ashley Sheridan wrote:
 

snip

 
 
  There's always a chance that if thrown, the egg won't contact end-on.
  Has anyone thought to factor this in?
 
 Is that an African or European egg?
 
 Paul
 
 --
 Paul M. Foster
 
 
 
 Hehe, a fan of Monty Python I see!

Heck yeah. I can even program in their language a little bit!

Paul

-- 
Paul M. Foster

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



Re: [PHP] Formatting Decimals

2010-01-11 Thread Paul M Foster
On Mon, Jan 11, 2010 at 02:55:33PM -0500, Rick Dwyer wrote:

 I have been asked to further modify the value to the nearest half cent.

 So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
 If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 it
 gets rounded up to full cents.

 Can this be done fairly easily?  Not knowing PHP well, I am not aware
 of the logic to configure this accordingly.

Yes, this can be done, but you'll need to write a function to do it
yourself. I'd also suggest you look into the BCMath functions, at:

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

Paul

-- 
Paul M. Foster

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



Re: [PHP] Formatting Decimals

2010-01-11 Thread Paul M Foster
On Mon, Jan 11, 2010 at 04:56:03PM -0500, tedd wrote:


 --Rick:

 The above described rounding algorithm introduces more bias than
 simply using PHP's round() function, which always rounds down. IMO,
 modifying rounding is not worth the effort.

 The best rounding algorithm is to look at the last digit and do this:

 0 -- no rounding needed.
 1-4 round down.
 6-9 round up.

 In the case of 5, then look to the number that precedes it -- if it
 is even, then round up and if it is odd, then round down -- or vise
 versa, it doesn't make any difference as long as you are consistent.

 Here are some examples:

 122.4  -- round down (122)
 122.6 -- round up (123)
 122.5 -- round up (123)

 123.4  -- round down (123)
 123.6 -- round up (124)
 123.5 -- round down (123)

 There are people who claim that there's no difference, or are at odds
 with this method, but they simply have not investigated the problem
 sufficiently to see the bias that rounding up/down causes. However,
 that difference is very insignificant and can only be seen after tens
 of thousands iterations.  PHP's rounding function is quite sufficient.

This is called (among other things) banker's rounding. But PHP's
round() function won't do banker's rounding, as far as I know.

Paul

-- 
Paul M. Foster

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



Re: [PHP] corect way to use mail() function

2010-01-11 Thread Paul M Foster
On Mon, Jan 11, 2010 at 04:17:30PM -0600, LAMP wrote:

 Hi,
 The company I work for, hosts online events registration applications.
 After a registered registered himself for an event he will get a
 confirmation email saying he registered successfully.
 Currently, in the header part of the mail(), in From it says e.g.
 ord...@computility.com - because the email comes from us not from our
 client (e.g. ABC Assoc.). Reply-to goes to us too.

 Now one of our clients (e.g. ABC Assoc.) asks us to put in the from
 field their email, to looks like the email comes from them. something
 like: From: ABC Assoc. eve...@abcaccos.org;

 I refused to do that concerned we are going to be blacklisted for
 sending spam. Because header shows one place and From field says other
 email address - spam way of sending emails.

 Am I right or it really doesn't matter who sent the email?

Since the mail() function doesn't have a parameter for the From:, how
do you force it to be a certain thing in the first place?

Paul

-- 
Paul M. Foster

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



Re: [PHP] POLL: To add the final ? or not...

2010-01-10 Thread Paul M Foster
On Sun, Jan 10, 2010 at 06:41:19AM -0800, Michael A. Peters wrote:

 Daevid Vincent wrote:


 What do you guys all do?


I leave it off. I don't want to have to worry about which editor I'm
using or whether I accidentally left some whitespace where it shouldn't
be.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Form validation and save the form

2010-01-10 Thread Paul M Foster
On Sun, Jan 10, 2010 at 11:37:06PM -0600, aditya shukla wrote:

 Hello Guys,
 
 I am trying to validate a form for user input , such that when something is
 missing load the form again by focusing on the  wrong field.Say i don not
 enter my address so when the form loads everything else is saved and the
 form points to address field.

Typically, you would direct the form back to itself. Then at the top of
the form, you'd put a test to determine if the form has been processed
before or if this is the first time through. Then you make your decision
about missed fields, etc. Like this:

== someform.php ==
?php

if (empty($_POST)) {
load_some_values_or_not();
}
else { // form has entered data
$okay = process_for_errors();
if ($okay) {
store_the_data();
header(Location: success.php);
exit();
}
}
?
HTML crap goes here...

== end of someform.php ==

You'll notice that if there are entry errors, execution falls through.
In that case, you'll need to do something like this for fields:

input type=text name=pizza value=?php echo $_POST['pizza']; ?/

so that the entered data shows up in the fields. First time through, the
value attribute will yield nothing.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Happy New Year All!

2009-12-31 Thread Paul Scott

Bipper Goes! wrote:
 return ThankYou;
 
 
 Oh god I think I blowed it up.

I prefer:

?php
while(date('Y')  2010) ;
exit (' Happy New Year');


-- 
-- Paul

http://www.paulscott.za.net
http://twitter.com/paulscott56
http://avoir.uwc.ac.za
All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal


Re: [PHP] Happy New Year All!

2009-12-31 Thread Paul Scott
--=neXtPaRt_1262280971
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit


Robert Cummings wrote:
 
 Oh dear... that's terribly inefficient... Here's a better stab:

True, but my design criteria included that it needed to fit into a 140
char tweet too...

-- 
-- Paul

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

--=neXtPaRt_1262280971
Content-Type: text/plain;

All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal


Re: [PHP] If design patterns are not supposed to produce reusable code then why use them?

2009-12-30 Thread Paul M Foster
On Wed, Dec 30, 2009 at 04:50:40PM -, Tony Marston wrote:

 I have recently been engaged in an argument via email with someone who
 criticises my low opinion of design patterns (refer to
 http://www.tonymarston.net/php-mysql/design-patterns.html ). He says that
 design patterns are merely a convention and not a reusable component. My
 argument is that something called a pattern is supposed to have a recurring
 theme, some element of reusability, so that all subsequent implementations
 of a pattern should require less effort than the first implementation. If
 design patterns do not provide any reusable code then what is the point of
 using them?
 

There's a weird terminology problem here. A design pattern is just an
idea. Once you implement it, it can become a source of reusable code.

 
 
 I do not use design patterns as I consider them to be the wrong level of
 abstraction. I am in the business of designing and developing entire
 applications which comprise of numerous application transactions, so I much
 prefer to use transaction patterns (refer to
 http://www.tonymarston.net/php-mysql/design-patterns-are-dead.html and
 http://www.tonymarston.net/php-mysql/transaction-patterns.html ) as these
 provide large amounts of reusable code and are therefore a significant aid
 to programmer productivity.
 
 
 
 What is your opinion? Are design patterns supposed to provide reusable code
 or not? If not, and each implementation of a pattern takes just as much time
 as the first, then where are the productivity gains from using design
 patterns?
 

It depends on how you implement it. You can prevent it from being
reusable by implementing it in such a way that there's just no way to
adapt it to different circumstances.

But for the most part, it's like any other code you expect to reuse,
whether it's just a function, a plain class or whatever. If you
implement it properly, it will be reusable elsewhere. 

Paul

-- 
Paul M. Foster

-- 
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-15 Thread Paul M Foster
On Tue, Dec 15, 2009 at 12:03:23PM +, Ashley Sheridan wrote:

snip

 
 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. 

PostgreSQL generally matches MySQL in performance, and maintains
referential integrity (foreign keys and such) without the need for
multiple backend storage engines.

Paul

-- 
Paul M. Foster

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



Re: [PHP] I have not seen any messages for a couple of days...

2009-12-10 Thread Paul M Foster
On Thu, Dec 10, 2009 at 08:01:51PM +0100, Jochem Maas wrote:

 Ashley Sheridan schreef:
  On Thu, 2009-12-10 at 11:26 -0500, Robert Cummings wrote:
 

snip

 
  Telepathic email servers? I've heard they're becoming more popular these
  days.
 
 no, your confused with that other list php-psychics. :-) (STA)

I thought that list was swallowed by a .Net black hole? ;-}

Paul

-- 
Paul M. Foster

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



Re: [PHP] can't retrieve more than 1 record at the time

2009-12-09 Thread Paul M Foster
On Wed, Dec 09, 2009 at 11:39:55AM -0800, Catherine Madsen wrote:

 Hi,

 I'm really in need of help.  I'm not a PHP programmer, but I've been
 given the privilege of customizing a script written by somebody else and
 can't get it to work right.  I have to query 2 different tables in 2
 different Oracle 10G DBs, one's mine (my_schema.my_table), the other
 (otherdb.other_table) belongs to another department.  In my_table, I
 have the doc_id and the app_id for a record.  In other_table there's the
 doc_id and pdf  to retrieve.  The goal is to make a PDF file from each
 BLOB in other_table and store them in the right directory under
 hash(app_id).  PDO has been installed and working, and I can connect to
 both DBs without a problem.  If my query limits the retrieval to one
 record, the script works, but if I try to run it for all records, one
 pdf  file is correctly created in the right directory then  I get the
 following error: PHP Fatal error:  Call to a member function fetch() on
 a non-object in /my_location/my_script.php on line 154.  It the while
 ($stmt-fetch(PDO::FETCH_BOUND)) line.  I've pasted my script below.  I
 thought my problem was that maybe I was in the wrong directory after
 creation of the first pdf, but  several tries changing the directory
 didn't make a difference.  Right now, I'm running the script at the
 command line.  Soon I'm going to have a few hundred records to deal with
 and cannot do it one by one!  Any help would be very much appreciated.
 Thank you!


snip


if (!(chdir($curdir)))
{
$_SESSION['msgs'][] = 'Could not change to '.$curdir;
continue;
}

$cnt = 0;

while ($stmt-fetch(PDO::FETCH_BOUND))
{
$filename = 'phs-'.$cnt.'.pdf';

   if (!file_exists($filename))
{ /* if file not already there, write file with BLOB contents */
$fh = fopen($filename, 'w');
fwrite($fh, stream_get_contents($PDF));
fclose($fh);

/* add to $_SESSION['PHPulled'] for each new file saved */
$_SESSION['PHPulled'] = $_SESSION['PHPulled'] + 1;
 }

Judging by your indentation you probably want a closing brace here. As
it is, your while statement won't end until the final closing brace,
which includes the $stmt = NULL; statement. Nulling this variable in
the middle of the while loop will cause it to execute once only and
cause the error message you're seeing.



/* increment stack counter */
$_SESSION['numberCand'] = $_SESSION['numberCand'] + 1;

$stmt = NULL; /* release the connection */

  /*if not done with stack, redirect to self to get next*/
if (!empty($_SESSION['DOCIDs']) and
$_SESSION['numberCand']  count($_SESSION['DOCIDs']))
{
exit;

}
}
 }

 /* once done, go back to display search page after clearing stack
 if(isset($_SESSION['DOCIDs']))
unset($_SESSION['DOCIDs'] );*/

 $res = null;
 $dbh1 = null;

Paul

-- 
Paul M. Foster

-- 
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 Paul M Foster
On Mon, Dec 07, 2009 at 02:39:28PM -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?

First, don't use multiple cookies; already covered elsewhere. Second,
you can serialize/unserialize array data and store it compactly in a
cookie. See the serialize() and unserialize() functions on php.net.

Paul

-- 
Paul M. Foster

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



Re: [PHP] dbase_get_record_with_names; Very slow search!!!

2009-11-24 Thread Paul M Foster
On Tue, Nov 24, 2009 at 08:40:09AM -0500, Rahul S. Johari wrote:

 Ave,

 I'm connecting to a foxpro database (dbase) and simply running a
 search to retrieve a record. It's a very simple code.
 The problem is, as the database is growing, the search is becoming
 ridiculously slow ... and I mean it's taking minutes. When the dbase
 had 10,000 records ... search was fast  efficient ... as if you were
 connecting to a mySQL Database. Now that the database has over 75,000
 records and still growing ... it's taking minutes to search.

 The database has about 35 fields; Search is based on a phone number.
 This is the code ...

 ?php
   #Open DBF
   $db = dbase_open(dbase.dbf, 0);

   #PULL UP RECORD
   if ($db) {
 $record_numbers = dbase_numrecords($db);
 for ($i = 1; $i = $record_numbers; $i++) {
$row = dbase_get_record_with_names($db, $i);
if ($row['PHONE'] == $_POST['PHONE']) {

   #Retrieve row  display fields
   echo $row['STUFF'];
   }
   }
 }
 ?

 It works ... but it's getting way too slow.

 One thing with FoxPro DBF's is that they use an Index file for
 searches within FoxPro. These are .CDX files which contain the Index.
 You can create an Index on, for example, PHONE field. However I don't
 think there's any way in PHP to reference this Index file for faster
 searches.

 Is there any possibility to improve search response time?


Check the PHP routines you use to access your xBase files. If none of
them mention indexes, I think you'll find that the PHP xBase drivers do
not *use* them. One problem is that dBase uses .ndx indexes, FoxPro uses 
.cdx indexes, and others use .ntx files. xBase drivers are written for
the file format itself, not for the multiple kinds of indexes. Moreover,
without selecting the specific index tag, your search won't go any
faster as a result of the index.

I suspect the bottleneck is in the way the drivers access the file.
xBase is a fixed length record format with a variable length header, so
it's pretty simple and fast to pull up successive records.

I wrote a C program many years ago to access xBase files:

http://sourceforge.net/projects/dbfsak

Unfortunately, it's not possible with this program to access individual
fields by name.

Paul

-- 
Paul M. Foster

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



Re: [PHP] processing html forms and keeping the values

2009-11-24 Thread Paul M Foster
On Tue, Nov 24, 2009 at 06:14:01PM +0100, Merlin Morgenstern wrote:

 Hi there,

 I am trying to redirect a user back to a html form if a validation
 failes. The form shoult then hold all entered values. So far I did this
 over $_GET, but there is a 100 Character limitation. How could I do this
 while keeping all characters?

 Thank you for any hint,

*Don't* use GET for this.

Here's the typical way this is done:

If the name of the file is myfile.php, then in the file do this:

form action=myfile.php action=post

This makes the form return to itself when the user hits the Submit
button. Above the actual HTML part of the form, put a check to determine
if the form has been filled in, like this:

if (!empty($_POST)) {
// Form was filled in
do_validation();
if (! $valid) {
$_SESSION['myform'] = $_POST;
}
}
else {
show_the_file_for_the_first_time();
}

In the do_validation() step, you validate the form. If there is a
problem and you want to re-show the form, you would typically do this
for each field:

input type=text name=first_field value=?php echo
$_SESSION['myform']['first_field']; ? ?

In other words, you store the form values in the $_SESSION array.

Paul

-- 
Paul M. Foster

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



Re: [PHP] dbase_get_record_with_names; Very slow search!!!

2009-11-24 Thread Paul M Foster
On Tue, Nov 24, 2009 at 12:59:35PM -0500, Rahul S. Johari wrote:

 Well I use mySQL on my Mac for all my other database work. This
 particular database is natively produced in FoxPro as that is what our
 Company uses. My website offers some of our clients this data (stored
 in FoxPro DBF's) using PHP which is running on an Apache Web Server on
 Mac OS X.

 I am looking into the option of importing the DBF records in my mySQL
 Server on my Mac. The one issue that's coming to my mind is ... the
 DBF is updated daily. An End-Of-Day program run at night updates the
 FoxPro DBF. I can write a program in PHP to import the DBF Records --
 mySQL ... however, I'm going to need to somehow Automate this
 procedure so that it runs automatically every nigh (or early
 morning) ... and also such that only NEWER records are imported from
 the DBF -- mySQL.

 Sounds a bit rough ... but seems to be a plausible solution.

The program I mentioned earlier:

http://sourceforge.net/projects/dbfsak

is designed to dump out the contents of a DBF into a form that can be
imported into MySQL or PostgreSQL. That's part of what I use it for.
(No, I don't make any money off the program. I wrote it for my own use
and put it up on sourceforge years ago in case someone could use it.)

Paul

-- 
Paul M. Foster

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



Re: [PHP] Noob question: Making search results clickable.

2009-11-19 Thread Paul M Foster
On Thu, Nov 19, 2009 at 03:53:55PM +0100, Nisse Engström wrote:

 On Wed, 18 Nov 2009 10:31:59 -0500, Paul M Foster wrote:
 
  Replace your query with:
 
  SELECT title, id FROM videos WHERE topid1 = '$topic'
 
  or whatever index you have to select a particular video from your table.
 
  Replace your echo statement above with:
 
  echo a href=video_display.php?video_id=$row[id]$row[title]/a;
 
 Without actually checking, I don't think $row[...]
 is going to work in double quoted strings. I'm pretty
 sure it needs to be in braces. You also need to escape
 the double quotes and put the array indexes in single
 quotes:
 
   echo a
 href=\video_display.php?video_id={$row['id']}\{$row['title']}/a;
 

Ahem. You are correct. I should have escaped the double quotes. I've
*never* made this kind of mistake before. ;-}

Paul

-- 
Paul M. Foster

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



Re: [PHP] Noob question: Making search results clickable.

2009-11-19 Thread Paul M Foster
On Thu, Nov 19, 2009 at 03:07:42PM +, Ashley Sheridan wrote:

 On Thu, 2009-11-19 at 10:09 -0500, Paul M Foster wrote:
 

snip

 
 Ahem. You are correct. I should have escaped the double quotes. I've
 *never* made this kind of mistake before. ;-}
 
 Paul
 
 --
 Paul M. Foster
 
 
 
 Gonna go to PHP hell for that faux pas!
 

PHP Hell Characteristics:

Endless pages of code *you* have to make work.

Tons of PHP code embedded in HTML. Not an MVC in sight.

Everything is full of misquoted variables.

All variables are *slightly* misspelled.

Every PHP page terminated with ? and then a couple more CRLF
combinations, just to make sure you can't figure out why your pages
won't display.

No security checking of any POST or GET variables. In fact, all input is
guaranteed to contain javascript fragments.

Parameters in all PHP function calls are out of order.

No access to php.net. And no XKCD.com.

No caffeine. No nicotine. No pizza.

The phone won't quit ringing, and you can't disconnect it. It's always
customers asking for senseless and nonsensical modifications.

If you're a vim user, you're forced to use emacs. If you're an emacs
user, you have to use vim. And if you use an IDE, you're stuck with
Microsoft Word.

Paul

-- 
Paul M. Foster

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



Re: [PHP] dynamic meta tag and title app?

2009-11-19 Thread Paul M Foster
On Thu, Nov 19, 2009 at 01:09:48PM -0500, tedd wrote:

 At 10:48 AM -0500 11/19/09, Jack S wrote:
 Hi Todd,

 This looks like a good starting point for me.
 I was going to use $_SERVER['PHP_SELF'];  but I think
 ($_SERVER['SCRIPT_NAME']); in your example will always return just the
 script info and not additionally passed information, which will save
 me trouble shooting later!

 Thanks!!!

 No problem -- and I can see that you might have problems keypunching
 considering that my name is tedd and not todd.  :-)

I think the real question is what did you do with todd? Are those his
feet sticking out from behind that cabinet over there?

Paul

-- 
Paul M. Foster

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



[PHP] Noob question: Making search results clickable.

2009-11-18 Thread Paul Jinks
Hi all

I'm building a fairly basic php/mySql site but I'm running into
problems due to my total lack of experience. I have a database of
videos - each has a title, transcript, description and one or more
topics. So far I can search the database by topic (using a drop-down
menu), like this:

?php
$result = mysql_query(SELECT title FROM videos WHERE topic1= '$topic');

while($row = mysql_fetch_array($result))
  {
  echo $row['title'];
  echo br /;
  }
?

Basic, but it works. What I'd like now is to make the search results
clickable so clicking them leads to a page showing all the details of
that video. I have a page video_display.php set up, ready to display
the details from the database, but how do I connect the two?

Thanks in advance

Paul

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



Re: [PHP] Noob question: Making search results clickable.

2009-11-18 Thread Paul M Foster
On Wed, Nov 18, 2009 at 03:04:13PM +, Paul Jinks wrote:

 Hi all
 
 I'm building a fairly basic php/mySql site but I'm running into
 problems due to my total lack of experience. I have a database of
 videos - each has a title, transcript, description and one or more
 topics. So far I can search the database by topic (using a drop-down
 menu), like this:
 
 ?php
 $result = mysql_query(SELECT title FROM videos WHERE topic1= '$topic');
 
 while($row = mysql_fetch_array($result))
   {
   echo $row['title'];
   echo br /;
   }
 ?
 
 Basic, but it works. What I'd like now is to make the search results
 clickable so clicking them leads to a page showing all the details of
 that video. I have a page video_display.php set up, ready to display
 the details from the database, but how do I connect the two?

Replace your query with:

SELECT title, id FROM videos WHERE topid1 = '$topic'

or whatever index you have to select a particular video from your table.

Replace your echo statement above with:

echo a href=video_display.php?video_id=$row[id]$row[title]/a;

Then ensure that video_display.php is set up to fetch the video whose ID
is passed to it via the GET parameter.

All this assumes I understood what you're getting at. Which is
questionable. ;-}

Paul

-- 
Paul M. Foster

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



Re: [PHP] Shoutbox suggestion needed

2009-11-16 Thread Paul M Foster
On Mon, Nov 16, 2009 at 02:46:45PM +, Ashley Sheridan wrote:

 
 I don't know of anything you can use like this, especially that runs
 purely on Ajax. Just take a look at Facebook chat. That's Ajax, and
 fails and falls over on a constant basis to the point where it is almost
 useless. Imho, Java seems to be pretty good at this sort of thing, and
 there are plenty of free options out there that you could use.

It's often been argued back and forth whether people have Javascript
turned off. I suspect the vast majority of people have Javascript turned
on. However, Java is another story. You may find that many more have it
turned off.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Convert deprecated POSIX functions into wrappers for equivalent PCRE functions

2009-11-09 Thread Paul Fierro
On 11/9/09 8:56 AM, Tony Marston t...@marston-home.demon.co.uk wrote:

 I have tried subscribing to the internals list, but none of my postings ever
 appears.

That's unfortunate as you missed this thread:

http://marc.info/?t=12553625831r=1w=2

Paul



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



Re: [PHP] Convert deprecated POSIX functions into wrappers for equivalent PCRE functions

2009-11-08 Thread Paul M Foster
On Sun, Nov 08, 2009 at 06:30:37PM -0500, Robert Cummings wrote:

 Also, why support
 two libraries for which one is obviously inferior in speed and
 functionality?


Because Tony's Radicore framework has a bunch of ereg* calls in it. ;-}

Paul

-- 
Paul M. Foster

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



Re: [PHP] Re: UrlRewrite htaccess confusion

2009-10-29 Thread Paul M Foster
On Thu, Oct 29, 2009 at 12:26:10PM -0500, Shawn McKenzie wrote:

 Rob Gould wrote:
  You are indeed correct!  Absolute URLs for everything, images, css,
  javascript, and links fixed the issue.  Took me forever to change every
  link in the whole site, but it's happy now.  Seems like there ought to
  be an easier way.
 
 
 There is an easier way.  The logic depends upon your app, but create a
 function that builds and optionally echos URLs for you.  It can work out
 the base url or you can do that when you initialize your app and define
 it as a constant.  It can be as simple or as complex as you need.
 
 a href=?php makelink($file, $arrayOfVars); ?Something/a
 
 -- or --
 
 echo 'a href=' . makelink($file, $arrayOfVars) . 'Something/a';

+1

I initialize a links class from the config, and then use it to serve
up link text and URLs depending on the parameters I give it.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Re: Create a screenshot of a website

2009-10-28 Thread Paul M Foster
On Wed, Oct 28, 2009 at 05:49:43PM -0200, Manuel Lemos wrote:

 Hello,
 
 on 10/28/2009 05:24 PM Robert Cummings said the following:
  I want to be able to get a screenshot of a given website on the fly.
  Can you give me any suggestions.
 
  If you are still looking at solutions for this problem, here you can
  find a solution that works on Windows:
 
  http://www.phpclasses.org/win-screenshot
 
  Here is another that works on Linux and any platform that supports
  PHP-Gtk:
 
  http://www.phpclasses.org/gtkmozembed-shot
 
  It hurts my eyes to go on the phpclasses website. It's like someone
  vomited tabs and links :|
 
 I have no clue why you felt the need to be so aggressive.
 
 Anyway, if you are that sensitive to design issues, why don't you
 participate in the contest to propose a better design instead of just
 complaining against the work that others do to help the PHP community?
 
 You can earn prizes and start helping instead of just putting down what
 others do.
 
 http://www.phpclasses.org/blog/post/104-Submit-your-site-redesign-proposal-for-the-contest.html

Here's a free suggestion. You don't even have to give me a prize. You
know those random words which are underlined on that page, and when you
mouse over them, you get the random advertisement on a completely
unrelated subject, which also emits a *sound* on my computer? Get rid of
them completely. They are beyond annoying. I get that you need to make
money with this site, but those obnoxious ads are the exact opposite
wrong way to do it.

Also, while I wouldn't have expressed it quite as crassly as Robert, I
have to agree on his evaluation of the site's look. I have a logon on
your site and have been to it many times. I just figured you liked it
like that. But in truth, it needs a serious and complete makeover. But
like Robert, I have no end of things to take care of, quite outside of
redisigning phpclasses.net. I'd suggest you scrap the contest and go
find a good free CSS template. But that's just me.

And just for the record, I'm really not ragging on you. PHPClasses.net
is the only site of its kind I know of. There is an endless variety of
code for almost anything you could want to do in PHP. That's why I
maintain a login there.

Paul

-- 
Paul M. Foster

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



Re: [PHP] What is the best practice for adding persistence to an MVC model?

2009-10-27 Thread Paul M Foster

On Tue, Oct 27, 2009 at 05:27:07PM +1100, Eric Bauman wrote:

 I'm in the process of implementing an ultra-light MVC framework in PHP.
 It seems to be a common opinion that the loading of data from a
 database, file etc. should be independent of the Model, and I agree.
 What I'm unsure of is the best way to link this data layer into MVC.

I disagree. There should be database class(es) which know how to deal
with the datastore(s). This may be as simple as a thin layer over the
PDO classes. The model talks to and uses the database class, and is the
only component which deals with the database class. The model serves up
whatever data the controller needs to feed to the view.

All are welcome to disagree.

Paul

-- 
Paul M. Foster

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



Re: [PHP] What is the best practice for adding persistence to an MVC model?

2009-10-27 Thread Paul M Foster
On Tue, Oct 27, 2009 at 04:11:32PM +, David Otton wrote:

 2009/10/27 Paul M Foster pa...@quillandmouse.com:
 
  On Tue, Oct 27, 2009 at 05:27:07PM +1100, Eric Bauman wrote:
 
  I'm in the process of implementing an ultra-light MVC framework in PHP.
  It seems to be a common opinion that the loading of data from a
  database, file etc. should be independent of the Model, and I agree.
  What I'm unsure of is the best way to link this data layer into MVC.
 
  I disagree. There should be database class(es) which know how to deal
 
 Paul, you already did this in one of Eric's threads a couple of weeks
 back, and the best you could come up with when pressed was Probably
 not a great example, but Is it really necessary to rehash this?

I don't track threads closely enough to know if it's the same OP on this
thread. Apologies if I'm repeating myself.

I don't recall anyone disputing my example, nor any effective rebuttal
at all. And by the time I finished writing that email, I thought it was
a better example than I originally believed.

Paul

-- 
Paul M. Foster

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



Re: [PHP] regex pattern for extracting URLs

2009-10-23 Thread Paul M Foster
On Fri, Oct 23, 2009 at 01:54:40PM -0400, Brad Fuller wrote:

 Thanks Ash you are awesome!

Brad, you're violating list rules. We never say that kind of thing to
Ash *where he can hear it*. Only behind his back. ;-}

Paul

-- 
Paul M. Foster

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



Re: [PHP] php mail() function

2009-10-23 Thread Paul M Foster
On Fri, Oct 23, 2009 at 09:11:25PM -0700, James Prentice wrote:

 I found the mail server for my ISP (shawmail.vc.shawcable.net) and
 edited main.cf in the following manner:
 
 myhostname = shawcable.net
 relayhost = [shawmail.vc.shawcable.net]
 
 I still don't receive the mail from the PHP script though. The error
 log from /var/log/mail.log is this:
 
 Oct 23 21:00:31 homemade postfix/pickup[7044]: 6CA44A70109: uid=33
 from=www-data
 Oct 23 21:00:31 homemade postfix/cleanup[7107]: 6CA44A70109:
 message-id=20091024040031.6ca44a70...@shawcable.net
 Oct 23 21:00:31 homemade postfix/qmgr[7045]: 6CA44A70109:
 from=www-d...@shawcable.net, size=527, nrcpt=1 (queue active)
 Oct 23 21:00:31 homemade postfix/error[7109]: 6CA44A70109:
 to=x...@gmail.com, relay=none, delay=0.04, delays=0.03/0/0/0.01,
 dsn=5.0.0, status=bounced ([shawmail.vc.shawcable.net])
 Oct 23 21:00:31 homemade postfix/cleanup[7107]: 75517A7010A:
 message-id=20091024040031.75517a70...@shawcable.net
 Oct 23 21:00:31 homemade postfix/bounce[7110]: 6CA44A70109: sender
 non-delivery notification: 75517A7010A
 Oct 23 21:00:31 homemade postfix/qmgr[7045]: 75517A7010A: from=,
 size=2219, nrcpt=1 (queue active)
 Oct 23 21:00:31 homemade postfix/qmgr[7045]: 6CA44A70109: removed
 Oct 23 21:00:31 homemade postfix/error[7109]: 75517A7010A:
 to=www-d...@shawcable.net, relay=none, delay=0.03,
 delays=0.02/0/0/0.01, dsn=5.0.0, status=bounced
 ([shawmail.vc.shawcable.net])
 Oct 23 21:00:31 homemade postfix/qmgr[7045]: 75517A7010A: removed
 
 Have I edited main.cf incorrectly, or are there other values that need
 to be edited?

1. Not sure why you have square brackets around the relayhost value.

2. You're getting a bounce from the ISP's mail server, one indicating it
still won't allow relay.

3. I suspect the relayhost name is wrong. This may be the name you find
in the mail headers on messages relayed to you, but I doubt it's the one
you should use to post to. I could be wrong, though.

4. All due respect to Kranthi, but I believe he's wrong about relaying
mail from your webserver to the ISP's mailserver. I believe the ISP's
mailserver doesn't care, as long as the mail comes from your pipe. You
could probably call yourself pi...@pepperoni.com and your ISP would
accept it. It's just the From:. Again, I could be wrong.

5. This would be a lot simpler if you just call Shaw and ask them for
the name of the mailserver, and ask them if it's a problem for you to
post mail from your internal webserver to their mailserver. Then ask
them why such posts might bounce with a 5XX error.

Paul

Paul

-- 
Paul M. Foster

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



Re: [PHP] php mail() function

2009-10-22 Thread Paul M Foster
On Thu, Oct 22, 2009 at 06:24:14PM -0700, James Prentice wrote:

 How would I determine my ISP's SMPT server ID? And do I need to edit
 main.cf in order to use that server?

What ID? There's no ID needed. You just configure postfix to relay any
non-local mail sent to it to the SMTP server at your ISP. Check the
headers in incoming mail sent to you for the name of that server. It's
likely the same for both incoming and outgoing mail. Something like
mail.myisp.com.

One other note. People look at me like I'm crazy when I mention this,
but I've seen it quite a bit at various internet mail servers.
Sometimes, in order to accept email from you, the internet mail server
must see you *receive* mail within a certain time period prior. That is,
you have to go fetch your mail at the ISP, which opens a window into
the SMTP server for a limited time. Then you can tender mail to the
internet mail server. I don't know that your internet mail server
operates this way, but it's something to consider. I've had to deal with
this before myself.

Configuring local SMTP servers, like postfix. Check and see if Ubuntu
has some sort of setup utility for this. Or try

dpkg-reconfigure postfix

Setting up mail servers is tedious and error prone, unless you've done
it a lot. Read The Fine Manual on postfix.

 
 Also, is there a way to test the script just sending an email locally?
 I tried sending the email to use...@localhost, but the email was still
 not received.
 

It will work, assuming three things:

1. You have an actual user set up on the system to receive mail. That
is, an actual user on the system, with an entry in the passwd file and a
home directory, etc.

2. Postfix is configured to deliver truly local mail to local addresses.
More postfix configuration fun.

3. Postfix is actually running and properly configured. If not
configured properly, it may refuse to run.

In any case, linuxmanmikec's comment about the internet mail server not
trusting you on a dynamic IP is spot on. The web of email trust is such
that internet mail servers only trust other internet mail servers. And
*your* internet mail server will trust *you*. So to get mail to that
other internet mail server over there, you'll have to give it to *your*
internet mail server, which is the only one that internet mail server
over there will trust. The bounce message you got indicates that
relaying from you is forbidden at the destination mail server.

Paul

-- 
Paul M. Foster

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



Re: [PHP] php mail() function

2009-10-22 Thread Paul M Foster
On Thu, Oct 22, 2009 at 11:40:34PM -0500, Shawn McKenzie wrote:

snip

 This is fairly accurate in premise but just to clarify.  Mailservers
 don't operate like this by default and there is really no trust.
 There are public blacklists that a mailserver can be configured to use
 that tell the mailserver not to accept mail from servers on the
 blacklist.  The blacklists may contain servers that allow anyone to
 relay email, compromised servers, servers known for spam, ip ranges
 known to be held by spammers and *ranges that ISPs designate as dynamic
 or used for subscribers (DSL, cable, dial-up customers, etc. because
 they shouldn't be relaying email).

Regarding the rejection of dynamic IPs by smarthosts, are you saying
that it's a blacklist of sorts that lets them know an IP is dynamic?
(Serious question. I don't know the mechanism by which they determine
what is and isn't a dynamic IP.)

Paul

-- 
Paul M. Foster

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



Re: [PHP] Spam opinions please

2009-10-20 Thread Paul M Foster
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?
 
 ?php
 $deny = array(111.111.111, 222.222.222, 333.333.333);
 if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
header(location: http://www.google.com/;);
exit();
 } ?Gary
 

Have you tried CAPTCHA?

Paul

-- 
Paul M. Foster

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



Re: [PHP] ip-to-country

2009-10-19 Thread Paul Halliday
You might find this useful:

http://sites.google.com/site/interrupt0x13h/code/ip2c

On Sun, Oct 18, 2009 at 4:03 PM, SED s...@sed.is wrote:
 Hi,

 How can I access an index for IP to a country (or a more detailed location)?
 I have not yet found a function for that in PHP nor a free to use website
 that offers a remote search.

 Perhaps, there is another solution - any ideas?

 Regards,
 Summi




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



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



Re: [PHP] PHP broadcast mailer

2009-10-17 Thread Paul M Foster
On Sat, Oct 17, 2009 at 01:41:03AM -0400, Brian Hazelton wrote:

 I am in charge of an email newsletter list and making sure it gets sent
 out in time. My problem is I have never done broadcast emailing and
 right now we have 400 subscribers but want to build a system that can
 scale well regardless of the number of subscribers. Right now I use
 mysql to store the email and use phpmailer in a loop to send an email to
 each of the emails in the db, it is already slow with just 400(takes
 around 10 min (i think that's slow isnt it?). Has anyone built a
 broadcast email script and willing to help me?


Use PHPList. It's free.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Native support to MS SQL Server

2009-10-09 Thread Paul M Foster
On Fri, Oct 09, 2009 at 09:06:53AM -0400, Bastien Koert wrote:

  Would this be a good time to troll about the virtues of MySQL over
  MSSQL? :p
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 
 
 It has virtues?

Of course not. He actually meant PostgreSQL, which *does* have virtues.

(No flames. I'm teasing.)

Paul

-- 
Paul M. Foster

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



[PHP] what is php4 popularity?

2009-10-08 Thread Paul M.
Hey guys, does anyone have a good link for an article where php4 
popularity trends are examined? The best way for me to know php4 % and 
php5 %. I appreciate any good suggestions.


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



[PHP] Re: what is php4 popularity?

2009-10-08 Thread Paul M.

Eric Bauman wrote:

On 8/10/2009 4:28 PM, Paul M. wrote:

Hey guys, does anyone have a good link for an article where php4
popularity trends are examined? The best way for me to know php4 % and
php5 %. I appreciate any good suggestions.


Here's a pretty graph comparing PHP version usage and time: 
http://www.nexen.net/images/stories/phpversion/200810/evolution.milieu.png


Source (French): http://www.nexen.net/chiffres_cles/phpversion/


This research is done on October 2008. Does anyone has newer research?
And thanks Eric!

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



Re: [PHP] Newb question about getting keys/values from a single array element

2009-10-08 Thread Paul M Foster
On Thu, Oct 08, 2009 at 06:08:48PM -0700, Daevid Vincent wrote:

 I feel like a total newb asking this, but I'm just having a brain fart or
 something...
 
 I'm writing a page where I can either get back a list of items:
 
   Array {
 [1233] = apple,
 [6342] = apricot,
 [2345] = banana,
 ...
   }
 
 where the user then refines it by choosing one single item and a single
 element array is returned like this:
 
   Array {
 [8575] = peach,
   }
 
 How can I get this $item so I can print it like so:
 
   echo The ID is $id and the name is $name;
 
 Normally with an array of items, I do a:
 
   foreach ($item as $id = $name) echo...
 
 But that seems overkill for this scenario.
 
 The rub is that I don't know the id, so I can't use $item[0], and I also
 don't have something like $item['name'] to use either.
 
 There's got to be an easy way to extract those.
 
   list($id, $name) = $operator;
 
 Felt like it would work for a minute (wishful thinking).

If you don't know the index, then you really have no choice but to
iterate through the POST array (if I understand you correctly). One
problem I see is that you're using an integer for your index. The way I
normally do things like this is to provide a prefix for the index. Like
this:

$items = array('fruit_1233' = 'apple',
'fruit_6342' = 'apricot',
'fruit_2345' = 'banana',
'fruit_8575' = 'peach');

Then, out of all the POST members returned, I can pick out the ones
pertaining to fruit by simply looking for ones which have the 'fruit_'
prefix as their index. It tends to be clunky, but it's the only way I've
found to make it work:

$fruits = get_fruits_from_table();
foreach ($fruits as $key = $value) {
$index = 'fruit_' . $key;
if (isset($_POST[$index])) {
echo The user wants fruit #$key, $value.;
}
}

Paul

-- 
Paul M. Foster

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



Re: [PHP] Insult my code!

2009-10-07 Thread Paul M Foster
On Wed, Oct 07, 2009 at 05:34:35PM +1100, Eric Bauman wrote:

 Hi there,

 I'm in the process of trying to wrap my head around MVC, and as part of
 that, I'm attempting to implement a super-tiny MVC framework.

 I've created some mockups of how the framework might be used based
 around a very simple 'bank', but I'm trying to get some feedback before
 I go and implement it, to make sure I'm actually on the right track.

 Any thoughts would be much appreciated!

 Model - http://www.pastebin.cz/23595
 Controller - http://www.pastebin.cz/23597
 View - http://www.pastebin.cz/23598
 Template - http://www.pastebin.cz/23599

Your code (what there is of it) is fine. Beware of people who criticize
your code on purely academic criteria. There are a lot of differing
opinions about MVC, much of it driven by people making academic points
versus people who actually code for a living. Even some people who
actually code for a living fall under the spell of academic rules about
this or that.

The real key is, does it work, and can it be maintained. If so, don't
worry about people who argue esoteric points about what should or
shouldn't be in models and controllers, etc.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Apache Rewrite Issues

2009-10-07 Thread Paul M Foster
On Wed, Oct 07, 2009 at 11:52:00AM +0100, Russell Seymour wrote:

 Morning,

 I am trying to make my URLs more search engine friendly and I have come
 up against a problem.

 I want the following URL:

 mysite.example.com/articles/Test Story

 to be proxied to

 mysite.example.com/index.php?m=articlest=Test%20Story


Aside from the solution to your problem (which I don't have), you might
want to double-check on the search engine friendliness of URLs which
contain query strings. I know at one time this was the case, but the
latest I've heard is that URLs like your second one above are completely
okay with search engines. If someone else knows different, please speak
up.

And oh by the way, don't *ever* store a filename with a space in it on
your computer. It's Evil(tm). I curse the idiot who first came up with
allowing this in filenames. I have a special voodoo doll just for that
person, when I find them. As you can see, it causes all manner of odd
problems, no matter what OS it's on. (My local LUG list is periodically
hit with messages from people trying to overcome the problems attendant
to this habit.)

Paul

-- 
Paul M. Foster

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



Re: [PHP] Insult my code!

2009-10-07 Thread Paul M Foster
On Wed, Oct 07, 2009 at 09:09:29PM +0100, David Otton wrote:

 2009/10/7 Eric Bauman baum...@livejournal.dk:
 
  On 7/10/2009 7:25 PM, David Otton wrote:
 
  2009/10/7 Eric Baumanbaum...@livejournal.dk:
 
  Any thoughts would be much appreciated!
 
  One observation. Model isn't a synonym for Database Table - models
  can be anything that encapsulates business logic. Requiring all your
  models to inherit from Model is probably a bad idea.
 
  Thank-you for responding.
 
  Out of curiosity, why is this a bad idea? Is it also bad for views 
  controllers?
 
 Well, the way MVC has traditionally been approached is that the VC bit
 is a thin interface skin, concerned with I/O, while the M is the bulk
 of the program - the bit that does the heavy lifting. (You'll often
 hear this called Fat Model, Skinny Controller). So you could have a
 lot of models, that do a lot of disparate stuff - not just database
 tables.
 
 To give you an example, imagine an application that texts people when
 a new book by their favourite author is coming out.
 
 It's going to have models to represent database tables, the Amazon API
 and an SMS API.
 
 If all your controllers assume that all your models inherit from
 Model, then your code is monolithic and none of it can be reused.
 
 http://c2.com/cgi/wiki?InheritanceBreaksEncapsulation

I think this is a bit extreme. It really depends on what's in your
parent model class. It could be something really simple, but something
you don't want to have to rewrite in every model you code. Thinking that
a model must stand on its own without inheriting from a parent model
class because of some ideal notion of encapsulation is silly. 

Actually, in all deference to the eggheads of OOP, I believe there are
really only four reasons to use classes:

1. It keeps me from having to rewrite the same code over and over
(inheritance).

2. It keeps the namespace cleaner, since methods are unknown outside the
context of their containing class.

3. It allows me to change details of function implementation without
breaking things. This is a weak claim, though, because I can do the same
thing with straight functions; just change the guts of the function,
while still providing the same inputs and outputs.

4. It keeps the stack cleaner. I don't have to pass the same crap to
every related function. I can keep the data inside my class and have all
the methods share it.

The notion that OOP was going to save the world billions of hours of
programming time because of re-use is bunk. It hasn't, doesn't and
won't.

/rant

Paul

-- 
Paul M. Foster

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



Re: [PHP] Insult my code!

2009-10-07 Thread Paul M Foster
On Wed, Oct 07, 2009 at 11:31:58PM +0100, David Otton wrote:

 2009/10/7 Paul M Foster pa...@quillandmouse.com:
 
  I think this is a bit extreme. It really depends on what's in your
  parent model class. It could be something really simple, but something
  you don't want to have to rewrite in every model you code. Thinking that
 
 Have you got an example of something that is needed by every model
 that interacts with a general-purpose framework?

Probably not a great example, but how about this: *Assuming* that the
models need variables held in the config (which database, if any, for
example), we put code in the constructor of the parent model which picks
up these variables and stores references to them, for use in inherited
models. The config could be a singleton class which holds a single
instance of all the config variables. I *could* include a call like

$this-config = get_config();

in each model's constructor. Or I could just do it once in the parent
model. Of course, if this is all the parent model provides, then 

$this-config = get_config();

in each model would be roughly equivalent to

parent::Model();

in each model. But if the parent provided more than that, then I would
be writing less code to simply build it into the parent. And of course,
if I ever wanted to *add* more to all the models, then having a parent
model would allow me to do so without having to rejigger the code in
each model.

Paul

-- 
Paul M. Foster

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



Re: [PHP] foreach insert error

2009-10-07 Thread Paul M Foster
On Wed, Oct 07, 2009 at 03:31:14PM -0700, Haig Davis wrote:

 Hello All,
 
 I have spent the entire day trying to get my calendar app to function
 correctly ---  I have no problem with the actual functioning of the
 calendar. What is giving me trouble is for each calendar day the user has
 the option to check a checkbox requesting the day off and additionally the
 user must select a weighting for the request i.e. 1-31 with 1 being 1st
 choice and 31 being their least desirable request. The request is then
 insered into a mysql database.
 
 I am relativly new to PHP so I may well be on the complete wrong track here.
 so far I have tried imploding the array  posting an associative array.

You don't actually saw what your real problem is, and I'm too lazy (and
tired) to try to figure it out from your code. Can you elaborate?

Paul

-- 
Paul M. Foster

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



Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Paul M Foster
On Tue, Oct 06, 2009 at 08:51:17AM -0400, Bob McConnell wrote:

 From: Joost [mailto:joost.t.h...@planet.nl] 
  Daevid Vincent wrote:
  From: Ben Dunlap [mailto:bdun...@agentintellect.com]
 
  $a = $a++;
 
 I just think this is an ambiguous line of code that wasn't thought
 through. The presence of the postfix operator makes the result
 undefined, no matter what language you are using. It will be an accident
 if you get the results you are expecting.

The behavior of the ++ operator is the invention of Kernighan and Ritchie.
I don't imagine they ever foresaw anyone doing something as silly as

a = a++;

except under the rarest of circumstances.

Paul

-- 
Paul M. Foster

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



Re: [PHP] POST without POSTing

2009-10-01 Thread Paul M Foster
On Wed, Sep 30, 2009 at 11:36:55PM -0400, Daniel Brown wrote:

 On Wed, Sep 30, 2009 at 23:29, Paul M Foster pa...@quillandmouse.com wrote:
 
  I'm not sure how to do this. Please no exotic external libraries my
  shared hosting provider doesn't include. RTFM will be fine; just tell me
  which Fine Manual to Read.
 
 Nothing too exotic at all, Paul.  Check out cURL:
 
 http://php.net/curl

Okay, I've figured out how to shove the data through cURL to the
receiving URL, but then it occurred to me that the client browser must
go there *as well*.

Will curl_exec() do that on its own, or is there a parameter I need to
feed it?

Paul

-- 
Paul M. Foster

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



Re: [PHP] POST without POSTing

2009-10-01 Thread Paul M Foster
On Thu, Oct 01, 2009 at 04:23:46PM -0400, Daniel Brown wrote:

 On Thu, Oct 1, 2009 at 16:14, Paul M Foster pa...@quillandmouse.com wrote:
 
  Okay, I've figured out how to shove the data through cURL to the
  receiving URL, but then it occurred to me that the client browser must
  go there *as well*.
 
  Will curl_exec() do that on its own, or is there a parameter I need to
  feed it?
 
 So you need to have the *client* post the information?  You may
 want to look into a JavaScript solution, like an
 onload/document.form.post action.

Javascript would be a bad solution. If the user has this turned off,
they can't use the site.

Let me be less opaque. This is a page where a user will fill in some
personal information, and then select an amount to donate to this cause.
The intent is to pass some information that the merchant service company
needs (like merchant number and item selected) to their secure URL. The
problem is that, before I just pass the information off to them, I want
to make sure the user has properly filled out this form. So I have to
validate it. That's done in the background on the server, naturally. But
once the validating is done, it's time to send the user off to the
secure site with a payload of POST variables. At that point, the user
will enter credit card info and such, and continue the transaction.

So I need to find a way to direct the user's browser to the secure site
with their payload of POST variables. The more I look at this, the more
it looks like cURL won't do it, and Javascript has the obvious down
side.

I'm afraid the only way to do this may be to validate everything, pass
the values off to a confirmation page, where the user has to hit
Proceed, and *that* page goes directly to the secure server with its
POST payload.

If anyone has a better idea, let me know. Hopefully I've explained it
adequately to make the problem clear.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Curl output

2009-10-01 Thread Paul M Foster
On Thu, Oct 01, 2009 at 04:37:14PM -0700, gbhumphrey wrote:

 
 Hi, I am doing a basical curl call and can get the webpage I want. However
 when it prints to the screen, it only prints the text, not css or any
 javascript calls that run on page load.
 Is there a way to make it do that?
 
 thanks
 using a basic curl call
 $curl_handle=curl_init();
 curl_setopt($curl_handle,CURLOPT_URL,'http://example.com');
 curl_setopt($ch, CURLOPT_RETURNTRANSFER,0); // return into a variable
 curl_exec($curl_handle);

I don't know about the javascript, but if the CSS is an external file,
then it wouldn't get dragged along with the original file, and thus
wouldn't be there to style anything on the HTML page. Just a guess.

Paul

-- 
Paul M. Foster

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



[PHP] POST without POSTing

2009-09-30 Thread Paul M Foster
I'm sure this has been covered before, but I'm not even sure how to
search in the archives for it.

I have a form that collects certain info via POST. It is re-entrant, so
when the user hits the submit button, it checks the input and does
whatever sanity checks it needs to. If all is okay, it must now pass
some of that info to another URL (offsite) via POST. Normally, the
information would be passed via a series of GET variables or SESSION
variables. But in this case the site the user is being directed to must
receive the information via POST.

I'm not sure how to do this. Please no exotic external libraries my
shared hosting provider doesn't include. RTFM will be fine; just tell me
which Fine Manual to Read.

Paul

-- 
Paul M. Foster

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



Re: [PHP] POST without POSTing

2009-09-30 Thread Paul M Foster
On Wed, Sep 30, 2009 at 11:36:55PM -0400, Daniel Brown wrote:

 On Wed, Sep 30, 2009 at 23:29, Paul M Foster pa...@quillandmouse.com wrote:
 
  I'm not sure how to do this. Please no exotic external libraries my
  shared hosting provider doesn't include. RTFM will be fine; just tell me
  which Fine Manual to Read.
 
 Nothing too exotic at all, Paul.  Check out cURL:
 
 http://php.net/curl

I was afraid you were going to say that, and I wasn't sure cURL was
supported on that server. But I just loaded phpinfo on that server, and
it is supported.

However, assuming it *wasn't*, I've found the following example from a
google search (thank goodness for google's hinting or I couldn't have
found it):

$fp = fsockopen(www.site.com, 80);
fputs($fp, POST /script.php HTTP/1.0
Host: www.site.com
Content-Length: 7

q=proxy);

I don't know much about doing things this way. It appears that when done
this way, the body must be separated by a newline, just like email.
And it appears that the content-length of 7 indicates the length of the
q=proxy string. Assuming I piled on a few other passed variables the
same way as q, separated by newlines (and adjusted the Content-Length
accordingly), would the above work? Are there liabilities to doing it
this way?

Paul

-- 
Paul M. Foster

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



Re: [PHP] POST without POSTing

2009-09-30 Thread Paul M Foster
On Thu, Oct 01, 2009 at 12:24:41AM -0400, Daniel Brown wrote:

 On Thu, Oct 1, 2009 at 00:16, Paul M Foster pa...@quillandmouse.com wrote:
 
  However, assuming it *wasn't*, I've found the following example from a
  google search (thank goodness for google's hinting or I couldn't have
  found it):
 
  $fp = fsockopen(www.site.com, 80);
  fputs($fp, POST /script.php HTTP/1.0
  Host: www.site.com
  Content-Length: 7
 
  q=proxy);
 
  I don't know much about doing things this way. It appears that when done
  this way, the body must be separated by a newline, just like email.
  And it appears that the content-length of 7 indicates the length of the
  q=proxy string. Assuming I piled on a few other passed variables the
  same way as q, separated by newlines (and adjusted the Content-Length
  accordingly), would the above work? Are there liabilities to doing it
  this way?
 
 Yes.  Hosts are more likely to have cURL installed and available
 than fsockopen() or URL-based fopen() calls, so portability is greater
 with cURL.  It's also a bit faster.  Still, as you know, there's
 always more than one way to skin a cute, furry, delicious little
 kitten.

fsockopen() appears to be part of the standard network functions in PHP,
like the header() function. Do you mean that many hosts support the
function (as part of PHP) but don't support its use with external hosts?
Is there a way to determine this support from looking at phpinfo()?

Paul

-- 
Paul M. Foster

-- 
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-21 Thread Paul M Foster
On Mon, Sep 21, 2009 at 12:52:12PM -0300, 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].
 

Use the preg_match() function (see
http://us2.php.net/manual/en/function.preg-match.php ) and a good
regular expression from a place like http://www.regexlib.com/ .

Paul

-- 
Paul M. Foster

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



Re: [PHP] Question: Correcting MySQL's ID colomn when removing an entry

2009-09-20 Thread Paul M Foster
On Sun, Sep 20, 2009 at 12:07:39PM +0430, Parham Doustdar wrote:

 Hello there,
 I'm guessing that when a row in a MySQL table is removed, the ID colomns of 
 the rows which come after that row are not changed. For example:
 1
 2
 3
 4
 
 Now, if I want to remove the third rows, the ID colomn would be something 
 like:
 1
 2
 4
 
 I was wondering if there was a way to fix it through a query, so I wouldn't 
 have to use a for statement in PHP to fix it?
 

There's nothing to fix here. I assume you're talking about an ID column
which is serialized or autoincrement. Such columns are not designed to
necessarily be continuously numbered. If you remove a row, there is
simply a gap in the sequence. Your application shouldn't care whether
the numbers are continuous or not, though it may care that they are in
order.

To process such a table, you'd do your query like:

SELECT * FROM mytable ORDER BY id

And then process the results with a foreach or for loop.

I will say, though, that if your application cares about the ordering of
the records, I'd use a different field to implement that, such as
date_added or last_name or something similar. It's best to assume,
when dealing with autoincrement fields, that the numbers placed in them
are random. They are only designed to be unique within that table, to
allow for easy fetching of a single unique record within the table.
Autoincrement fields are not designed to be used to order the records in
a table.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Ckeckbox list populated from database

2009-09-19 Thread Paul M Foster
On Sat, Sep 19, 2009 at 09:06:14PM -0700, Haig Davis wrote:

 Hello List,

 I'm relatively new to PHP although I do feel I've got a grasp of the
 basics. I have used php to draw up numerous selection lists populated
 from a mysql database and have had no trouble at all.

 However when it comes to the same concept yet using HTML check boxes I
 aM complety stumped. It seems easy but I've been staring at the same
 problem for hours.

 Any hints are greatly appreciated.

I don't know what type of field you're trying to use to populate the
checkbox, but it basically comes down to this:

input type=checkbox name=pizza ?php if ($fieldval == 'something')
echo 'checked=checked'; ?/

or

input type=checkbox name=pizza ?php echo ($fieldval == 'something)
? 'check=checked' : ''; ?/

You've got to decide what is checked and unchecked for your
checkbox, and then make that a condition which triggers a checked or
unchecked state for the box. If you like, you can also put a
value=something attribute in the input tag as well.

When your user is finished inputting the form and you go to process the
results, you can check for the existence of the checkbox name in the
$_POST variable, or check that the $_POST variable contains the value
you set in the value=something attribute.

Checkboxes and radio buttons are tricky in this way, because they don't
normally return values in the same way an input type=text ... field
does.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Does anyone here use TCPDF?

2009-09-18 Thread Paul M Foster
On Sat, Sep 19, 2009 at 02:58:52AM +0900, Dave M G wrote:

 PHP List,
 
 
 I posted this question on the TCPDF forum on SourceForge, but it's
 getting no response. I'm not even sure how active their list is.
 http://sourceforge.net/projects/tcpdf/forums/forum/435311/topic/3400663
 
 So I'm hoping someone here might be able to help if they are using
 TCPDF. I just need to get the key details to get started, and then I can
 probably start to roll on my own.
 
 This is the question:
 
 
 Forgive me for what I would assume is a very obvious question, but I can
 not locate any clear instructions on what I want to do.
 
 Simply, I want to take an existing PDF and write text on top of it.
 
 The PDF is a single page, and it is a form that people fill out. What I
 need to do is fill out some of the fields in the form before sending it
 to the recipient.
 
 So I need to do two simple tasks. One is to load an existing PDF file.
 The second is to place short lines of text into specific locations on
 the page (A4 size).
 
 I know these two functions must be dead simple, and yet I am lost in the
 documentation.
 
 If someone could tell me the right function calls or point me to the
 right place so that I can RTFM on my own, I would be very grateful.
 
 Thank you for any advice.

I don't use TCPDF; I use FPDF, but I imagine the drill is about the
same. When I have to do what you're doing, I first write the code (using
the FPDF API/methods) to build the form fresh. I test this to ensure
everything is where it needs to be. Then I add code to that form which
fills in whatever fields need filling in. Then I output that.

What you're asking sounds like you want to *edit* an existing PDF via a
PHP class, and I don't know of a tool that does this except for Adobe
Acrobat and a few other non-PHP tools. It's something that's very
difficult to get right.

Therefore, I'd suggest instead using your existing TCPDF methods to
actually *build* the PDF from scratch, with additional method calls to
put in your content. That is, build and populate each time you need the
form.

Paul

-- 
Paul M. Foster

-- 
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 Paul M Foster
On Thu, Sep 17, 2009 at 12:56:09PM -0500, Philip Thompson wrote:

 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.

I bought a Windows XP PC about three years ago with IE6 on it (I
normally do all my work in Linux). I haven't upgraded it, and I can't
imagine why the average user would. If it ain't broke (and most users
wouldn't consider IE6 broken), don't fix it.

I will say this, though. Since I normally browse with Firefox on Linux,
if a site gets pissy with me and insists I use IE or Mozilla on Windows,
I typically don't go there anymore. So if you're interested in driving
off people who are less technologically advanced than you'd like, I
think you'll probably succeed.

Paul

-- 
Paul M. Foster

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



Re: [PHP] PHP GURU NEEDED

2009-09-14 Thread Paul M Foster
On Mon, Sep 14, 2009 at 08:56:59PM +0200, Andrea Giammarchi wrote:

 
 You are looking for me than, cool!
 

I can vouch for the fact that Andrea believes he's all that.

Paul

-- 
Paul M. Foster

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



Re: [PHP] RE: [Formaldehyde] The Most Basic Ajax - PHP Error Debugger

2009-09-13 Thread Paul M Foster
On Sun, Sep 13, 2009 at 01:33:49PM +0200, Andrea Giammarchi wrote:

snip

 
 This ML is a bit different from what I was expecting, 

snip

 
 P.S. I am certified Zend Engineer with 10 years of experience with PHP and 
 dunno how many innovation awards  in phpclasses.org ... so it was not just to 
 waste my time guys, and it is open source, maybe next time I'll keep for me

Yeah, we people on this list just don't get it.

So, you're gonna leave the list now, right?

Paul

-- 
Paul M. Foster

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



Re: [PHP] Reading files in PHP 5.3.0

2009-09-12 Thread Paul M Foster
On Sat, Sep 12, 2009 at 10:22:10AM -0400, tedd wrote:

 At 6:02 PM -0400 9/11/09, Paul M Foster wrote:

 I typically use us2.php.net, which is hosted by Hurricane Electric.

 Paul

 Paul:

 I wouldn't use Hurricane Electric if their accounts were provided for free!

 The following is an experience I had with Hurricane Electric and
 support for my opinion as to their service.

 You see, many years ago Hurricane Electric hosted (IMO with
 complicity) a porn site that sent out over 2000 porn spams to AOL
 using MY email address as the person to contact. That incident caused
 me a great deal of trouble.

 In an attempt to understand and resolve the problem, I sent several
 emails to Hurricane Electric; I called them numerous times via
 telephone; and I even sent them letters via the US mail. But
 unfortunately they refused to answer ANY of my correspondence. Their
 lack of communication provided support for my opinion of their
 complicity with what had happened.

 A few years back they contacted me (again more spam) soliciting my
 interest in hosting with them. Normally, I would have just reported
 such spam to spamcop, but because of the incident I replied and told
 them what had happened.

 Later I was contacted by one of their technicians who looked thorough
 their records and confirmed/admitted the incident. However, he told
 me that they could not be held responsible for they clients they
 host. Furthermore, they have no intention of screening their clients.
 He said that they will provide hosting to whomever they want,
 including porn and spam sites. If their clients do anything wrong per
 their standards, then they will deal with it internally. Otherwise
 they don't care about any harm done to anyone by them hosting such
 sites. In short, they want the money but not the responsibility.

 Now, maybe Hurricane Electric has changed its ways, but they can't
 change their past.

 In my opinion, there are more than enough hosting companies who care
 about the damage they might cause and take steps to reduce the about
 spam and porn on the net. My advice, seek hosts other than Hurricane
 Electric.

I don't know much about HE, other than the fact that they run ads in
Linux Journal. But they're a real hosting company, like Rackspace or
1and1. Yahoo (who hosts www.php.net) isn't a company I think of as a
hosting company. And they're an internet behemoth, like Godaddy or
Microsoft. So I'd personally steer away from them. Just my bias.

It sounds like HE's real problem is their TOS. I've hosted with a lot of
companies who will drop accounts where they find porn, spam and warez;
it's part of their TOS. The other problem I can see is that they are
apparently unwilling to even mediate a problem between two of their
accounts. We just host 'em. Other than that, we don't care. Typical. I
expect the porn company paid them a *lot* more money than you did, so
they simply looked the other way. A shame.

The lesson, I suppose, is to look at the terms of service before you
sign up with a hosting company. You may still end up being a victim, but
at least you know what you're getting yourself into. If they don't
specifically disavow porn, spam and warez, then they allow (and in
effect, condone) it.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Reading files in PHP 5.3.0

2009-09-11 Thread Paul M Foster
On Fri, Sep 11, 2009 at 05:48:42AM -0700, Tommy Pham wrote:

 
 I just checked my 'Mail Options' again.  It's always been 'compose as text'.  
 But I can't guaranteed that Yahoo actually does it.  Been having problems 
 with Yahoo lately (both mail and Yahoo hosting of www.php.net).  Maybe I 
 should switch to gmail... 

I think I'm reading this wrong. Are you saying that php.net is hosted
with *Yahoo*? WTF?

Paul

-- 
Paul M. Foster

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



Re: [PHP] Reading files in PHP 5.3.0

2009-09-11 Thread Paul M Foster
On Fri, Sep 11, 2009 at 08:38:13AM -0700, Tommy Pham wrote:

 --- On Fri, 9/11/09, Paul M Foster pa...@quillandmouse.com wrote:
 
  From: Paul M Foster pa...@quillandmouse.com
  Subject: Re: [PHP] Reading files in PHP 5.3.0
  To: php-general@lists.php.net
  Date: Friday, September 11, 2009, 8:57 AM
  On Fri, Sep 11, 2009 at 05:48:42AM
  -0700, Tommy Pham wrote:
  
   
   I just checked my 'Mail Options' again.  It's
  always been 'compose as text'.  But I can't guaranteed
  that Yahoo actually does it.  Been having problems with
  Yahoo lately (both mail and Yahoo hosting of
  www.php.net).  Maybe I should switch to gmail... 
  
  I think I'm reading this wrong. Are you saying that php.net
  is hosted
  with *Yahoo*? WTF?
  
  Paul
 
 go to www.php.net.  scroll all way down to the bottom.
 
 This mirror generously provided by: Yahoo! Inc.
 Last updated: Fri Sep 11 14:51:27 2009 UTC
 

I typically use us2.php.net, which is hosted by Hurricane Electric.

Paul

-- 
Paul M. Foster

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



Re: [PHP] User Account Management

2009-09-11 Thread Paul M Foster
On Fri, Sep 11, 2009 at 02:43:15PM -0700, Waynn Lue wrote:

 Hello all,
 
 We're building out a system that allows for user account creation/password
 management, and we're hoping to use existing open source software so we
 don't have to reinvent the wheel.  I know of Drupal, and Zend Framework (and
 maybe CodeIgniter?), but do people have specific preferences for either, and
 recommendations for other products that I haven't heard of?  It should just
 support basic account creation, being able to login/authenticate, change
 your password, storing user information like names and email addresses, etc.
 
 I tried searching for account management php but ended up getting a lot of
 CMS suites.

It depends on how you want your security to be built. At phpclasses.org,
there are a bunch of classes which handle user verification and such.
(Of course, you have to build your own screens; these are just classes,
after all.) My problem with these classes is that they typically assign
users a number to indicate the user level, and then you decide what
level is necessary to access a given page. Now, most of what I do is
programming for internal use. And my philosophy is that a user has no
business accessing *any* page they haven't been trained on. So my access
scheme is based on a system where there is a record in a table which has
the user ID and the page they're allowed to access. With a couple of
hundred pages, that's potentially a couple of hundred records per user.
It could be a pain to maintain, but provides the finest grained
authorization I can come up with.

If you don't need something that complex or solid, then some of the
classes at phpclasses.org may suffice.

CodeIgniter (as mentioned earlier this week) has no provision for user
login or security. The others probably do, but they're a bit like using
a steamroller to pound in a nail. Moreover, any framework like these
(even the very simple CodeIgniter) requires significant investment in
learning how to do things under that framework.

Honestly, whipping up a security scheme the way I have done it is a
couple of days' work (including login and management screens). I'm not
sure why people seem to be averse to it. You just work up your screens,
create your tables, populate the tables, and you're away. The user's ID
and whatever other pertinent information rides along with them in the
session variables. Each page checks to see if the user ID in the session
variable is allowed to access this page, etc.

Paul

-- 
Paul M. Foster

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



Re: [PHP] RE: [Formaldehyde] The Most Basic Ajax - PHP Error Debugger

2009-09-11 Thread Paul M Foster
On Sat, Sep 12, 2009 at 12:23:44AM +0200, Andrea Giammarchi wrote:

 
 Exactly Ben, except when PHP fails, even with a Fatal Error, the page has 
 status 200, we need to understand which call failed between hundreds of 
 potential calls in the debugger, and errors could pass silently.
 
 With Formaldehyde, accordingly with your predefined error_reporting level, 
 above situation will never happen, and the entire process, without changing 
 anything, will be much simpler, as Ben already described.
 
 So yes Tedd, you did not even read what is Formaldehyde about ... please try 
 to understand it before other comments, maybe you'll discover it's extremely 
 simple, and hopefully useful.
 

I suspect your English is getting in the way. You're calling this an
AJAX debugger. Debugging in PHP is relatively straightforward, if you
set the error level properly and build your own error handler, etc. So
people on this list would probably think of a PHP debugger as an
unimportant piece of software. Debugging in Javascript is more complex
and difficult, and the responses you're getting on the list sound like
people think Formaldehyde is for debugging Javascript (which PHP
programmers often aren't very interested in). On the Google code page
for Formaldehyde, you only emphasize PHP debugging, as that's the only
type of error example you give.

If the point of Formaldehyde is to debug PHP code, then you should call
it a PHP code debugger, not an AJAX code debugger. Tedd's right--
basic AJAX transactions are incredibly simple, and once the code is
written (it can be copied from any number of books), it needs no further
work. General Javascript is a different matter-- it can be quite complex
and quite hard to debug. But AJAX is a very narrow application of
Javascript.

If Formaldehyde is really a debugger for AJAX code, then you should
change the examples and text of your Google code page.

If Formaldehyde is really a debugger for Javascript code, then you
should change the examples on your Google code page to show Javascript
errors, and call it a Javascript debugger.

If Formaldehyde is really a debugger for PHP code, then call it a PHP
code debugger. The examples on your Google code page fit this.

Paul

-- 
Paul M. Foster

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



Re: [PHP] get an object property

2009-09-11 Thread Paul M Foster
On Fri, Sep 11, 2009 at 07:31:01PM -0400, Tom Worster wrote:

 if i have an expression that evaluates to an object, the return value from a
 function, say, and i only want the value of one of the objects properties,
 is there a tidy way to get it without setting another variable?
 
 to illustrate, here's something that doesn't work, but it would be
 convenient if it did:
 
 $o = array( (object) array('a'=1), (object) array('a'=2) );
 
 if ( end($o)-a  1 ) {  // can't use - like this!
 ...
 }
 

You should use print_r() or var_dump() to investigate what happens when
you try to cast an array into an object. I myself don't know what would
happen. Also, what's allowed and what effects are produced could depend
heavily on the version of PHP you're running. Version 4 != 5 != 5.3 in
this respect.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Fixing the path

2009-09-11 Thread Paul M Foster
On Sat, Sep 12, 2009 at 06:18:50AM +0200, Rico Secada wrote:

 Hi.
 
 Some time ago I developed a small web application that a bunch of users
 has installed.
 
 I have always used the DOCUMENT_ROOT for my includes, but the other day
 I installed the application in a subdirectory, and as you've guessed a
 lot of the includes didn't work.
 
 I have been reading up on the subject of absolute vs. relative paths
 etc. And on the subject of defining your own document root.
 
 I need the application to be as user friendly as possible, and I would
 like to avoid having users enter path details in the configuration.
 
 What is the best way to solve this problem?

Don't move your files to a subdirectory if they're written to be in the
document root (and vice versa). ;-} Seriously.

There really isn't a way around this. All your files need to be in the
same places at all times relative to each other. You can use absolute
paths or relative paths; it doesn't matter. But the files themselves
can't be moved. The only alternative to this is to write a search
function which searches in fixed locations for files until it finds
them. And that's kind of silly.

Look at it this way: Major frameworks all specify their subsidiary files
to be in certain fixed locations. They'll have directories for
javascript files, directories for internal classes, directories for
configuration files, etc. They may or may not use relative pathing to
refer to those files, but the files themselves must be in a certain
location with respect to each other, always.

My convention is to set up fixed directories for each type of file (as
mentioned above) and then always put files of that type in those
directories. Then use relative or fixed pathing as desired from other
files that include() those files.

If you're using a front controller, then you can use PHP server
variables to get the path to that file, and use that as the reference
for the location of the other files.

(Or maybe I've completely misread what you're trying to do.)

Paul

-- 
Paul M. Foster

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



Re: [PHP] Hoping for a hand with a login script

2009-09-10 Thread Paul M Foster
On Thu, Sep 10, 2009 at 01:00:19PM -0400, Bob McConnell wrote:

 From: Ben Dunlap

snip

  
  http://codeigniter.com/
  http://framework.zend.com/
  http://www.solarphp.com/
 
 While I have not looked at the last two, there is one thing that bothers
 me about your recommendation of codeigniter. Authentication is a basic
 function that should be used for any web site with interactive features.
 There is such a universal need for this function that there should be
 several packages available to provide it. But I believe that telling
 someone to adopt a complete portal system like CI just to get basic
 authentication is gross overkill. There has to be a better way to
 provide this core functionality without installing a monster package
 that will be 95% superfluous to their needs.
 
 Yes, I have installed codeigniter. I am still trying to figure out why I
 would want to use it.

Moreover, I'm using CI right now, and as far as I know, it does *no*
user authentication. I had to write my own routines, using their session
class to save the user data.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Renaming a Directory

2009-09-09 Thread Paul M Foster
On Wed, Sep 09, 2009 at 12:11:14AM -0400, Eddie Drapkin wrote:

 On Wed, Sep 9, 2009 at 12:08 AM, Paul M Fosterpa...@quillandmouse.com wrote:
  On Tue, Sep 08, 2009 at 05:39:43PM -0400, Floyd Resler wrote:
 
  How can I rename a directory with files in it?  The rename function
  gives me a directory not empty error.  I know I could do it be
  creating the directory, moving the files, and then deleting the old
  one.  Is there an easier way?
 
  It sounds like, underneath, rename() is creating a new directory and
  then attempting to delete the old one, ignoring the files in the
  original directory. In which case, you'll have to do it the long way--
  create a new directory, move the files, then delete the old directory.
 
  Oddly enough, I can't find a *nix command which will actually rename a
  directory. The man pages for mv, rename and such all refer only to
  files, not directories.
 
 
 mv renames directories fine:
 $ mkdir bar
 $ touch bar/randomfile
 $ mv bar foo
 $ ls foo
 randomfile
 
 :)

I would have thought so, but the man pages didn't mention it. I haven't
use mv in ages. Makes sense that it would work, though. Moving/renaming
a file would just change the name, not the inode number, which is the
real key to *nix file systems.

Paul

-- 
Paul M. Foster

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



Re: [PHP] new php script and sqlite

2009-09-08 Thread Paul M Foster
On Tue, Sep 08, 2009 at 11:20:01AM +0800, Eric Boo wrote:

 Hi,
 
 I'm currently using a text file to store data which the php script
 will read and write back to. I've a few questions:
 
 1) I'm thinking of using sqlite, but not sure whether this will be
 widely available on most hosts, as I intend for the php script to be
 deployed without needing to much with much configuration. Is sqlite
 included with most php setups?

As I understand it, sqlite support is by default built into PHP. If so,
then it should be supported anywhere.

 
 2) Should I be using sqlite 2 or 3?

Don't use version 2. It's deprecated.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Renaming a Directory

2009-09-08 Thread Paul M Foster
On Tue, Sep 08, 2009 at 05:39:43PM -0400, Floyd Resler wrote:

 How can I rename a directory with files in it?  The rename function
 gives me a directory not empty error.  I know I could do it be
 creating the directory, moving the files, and then deleting the old
 one.  Is there an easier way?

It sounds like, underneath, rename() is creating a new directory and
then attempting to delete the old one, ignoring the files in the
original directory. In which case, you'll have to do it the long way--
create a new directory, move the files, then delete the old directory.

Oddly enough, I can't find a *nix command which will actually rename a
directory. The man pages for mv, rename and such all refer only to
files, not directories.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Converting URL's to hyperlinks.

2009-09-08 Thread Paul M Foster
On Wed, Sep 09, 2009 at 03:22:25AM +0200, Lupus Michaelis wrote:

   Sorry for the lag.

 Daevid Vincent a écrit :
OP ?

 Original Poster

   Thanks :)

 Blah blah blah.
 I've used this code for about 6 years now and have yet to find emails that
 it didn't work for. If someone has some funky (whacky) RFC extremity, then
 so be it. That's their problem. Most people have NORMAL emails that follow
 the above.
   I faced a professionnal issue because of a lazy programmer (a Delphi
 component that was not aware about Toto man@example.com). What you
 consider normal e'mail is a subset that is not interoperable. And I hate
 that.

 But you are correct, I have revised it to be a little more forgiving
 of some
 allowed characters...

 preg_replace(/([\w\.\-...@[\w\.\-_]+\.\w{2,6})/i,
   You can revised your regex to fit to the new kind of email. But it is
 smarter to use the right tool (like filter_vars).

   Yeah, I know, I feel like some spanish windmill hunter.

I'm not sure it's well known on this list, but one resource I use for
regexps is:

http://www.regexlib.com/

Paul

-- 
Paul M. Foster

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



Re: [PHP] Taking body of an email and storing it in MySQL database

2009-09-07 Thread Paul M Foster
On Mon, Sep 07, 2009 at 07:47:00PM +0900, Dave M G wrote:

 PHP List,
 
 I am working on a project now where I need to check a POP3 mail account,
 download any mails there, and store the body and headers of each
 individual mail as plain text in a MySQL database.
 
 I have downloaded the POP3 class which seems to be the standard class
 everyone uses for POP3 mail checking:
 http://www.phpclasses.org/browse/package/2.html
 
 I think I understand how to create an instance of the class and use it
 to check the email. The part where you log into the account isn't that
 complicated.
 
 But after that it becomes a little strange. It seems that emails are not
 mere text files, but have to be assembled line by line?
 
 I thought each email, and their headers, would be something I could just
 access, download, and pass along to MySQL. But it seems more complicated
 than that.
 
 Has anyone done something like this before?
 
 If someone could let me know how it is that I can create a body of text
 for each email (including the headers) so that I can then store it in
 the database, that would be awesome.

I don't know what your class is doing, but yes, emails are very simple
in structure. Everything above the first bare newline (nothing else on
that line) is header, and everything below it is body. Even mime-encoded
attachments are just part of the body and can be stored as plain text.
Your class may be parsing the emails and assigning various parts of them
to various class members. But emails are downloaded as a stream of bits,
sequentially, top to bottom. Somewhere in the class is a routine which
is sucking up that bit stream. At that point, you can capture it without
other parsing.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Taking body of an email and storing it in MySQL database

2009-09-07 Thread Paul M Foster
On Tue, Sep 08, 2009 at 03:27:05AM +0900, Dave M G wrote:

 Paul,
 
 Is there a decent tutorial anywhere on the net for the pop3.class.inc
 available on phpclasses.org?
 
 http://www.phpclasses.org/browse/package/1120.html
 
 Maybe I'm blind, but I just can't find anywhere a decent description or
 tutorial of what calls you can make to its functions. The documentation
 file has two sections in German and a terse section in English.
 
 I'm trying to figure out how to get each message and get their subject
 line, from address, and then based on those two pieces of information,
 I'll take the whole body and store them in the right place in a MySQL
 database.
 
 Just for reference, this is what I've built so far (I renamed
 pop3.class.inc to POP3.php):
 
 include('POP3.php');
 $pop3 = new POP3();
 
 // Connect to mail server
 $do = $pop3-connect ('xxx.x.com');
 if ($do == false)
 {
   $message = $pop3-error;
 }
 
 $do = $pop3-login ('uuu', 'ppp');
 
 if ($do == false)
 {
   $message = $pop3-error;
 }
 
 $status = $pop3-get_office_status();
 
 if ($status == false)
 {
   die($pop3-error);
 }
 
 $count = $status['count_mails'];
 
 
 for ($i = 1; $i = $count; $i++)
 {
   // Here's where I hit a wall.
   // 1. Get the from address
   // 2. Get the subject line
   // 3. Get the header+body as one text file
   // 4. Store it in the database.

I'm not sure why you're attempting to do the above. According to the
documentation, you should simply be able to do:

 for ($i = 1; $i = $count; $i++) {
$msg = $pop3-get_mail($i);
// parse the message as you like
$pop3-save2file($msg, 'myfilename.txt');
// or
$pop3-save2mysql(a bunch of parameters);
 }

The $msg is returned as an array of strings. You could use the PHP
implode() function to reconstruct the array as a single string. But the
POP3::save2file() function will do this and save it to a text file if
you like.

It appears the class doesn't provide any support for parsing the message
internally. So that part is up to you. However, you could set up a loop
like this:

for ($j = 0; $j  count($msg); $j++) {
if (strpos($msg[$i], 'Subject: ') == 0)
// got the subject line
if (strpos($msg[$i], 'From: ') == 0)
// got the From: address line
}

Parsing the subject line and From: address is up to you. But there are
plenty of PHP functions to search and parse strings.

Paul

-- 
Paul M. Foster

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



Re: [PHP] mail attachment

2009-09-06 Thread Paul M Foster
On Sat, Sep 05, 2009 at 06:52:53PM +0200, Grega Leskov??ek wrote:

 How do I attach a file in mail function or do I have to use PEAR (and if how
 ...). What are the advantages of PEAR? When do You suggest to use PEAR?

You *can* attach something to an email using the mail() function, but
the process is complicated, and the mail() function isn't really set up
to do this. I believe the usual suggestion for users who ask this
question is to use the phpmailer package. It does this more easily.
Google for phpmailer.

Paul

-- 
Paul M. Foster

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



Re: [PHP] PHP inserting carriage returns into POST values?

2009-09-04 Thread Paul M Foster
On Fri, Sep 04, 2009 at 12:16:47PM -0700, James Colannino wrote:

 Hey everyone.  I ran into a really weird issue that I was hoping I could
 find some clarification on.  In short, I have javascript functions that
 operate on hidden text values.  Those values may be posted, in which
 case PHP then prints them back to the page via what comes in on $_POST.
 
 The weird thing is, I was no longer able to match substrings inside
 those hidden text values after posting via Javascript.  I banged my head
 over this for a couple hours, until I realized that the string's length
 was being increased by one after posting (I found this out in
 javascript).  Upon further investigation, I found that all instances of
 substring\n were being replaced by substring(carriage return)\n
 after post.
 
 For now, I'm simply doing str_replace(chr(13), , $_POST['value'])
 before re-inserting it into the HTML, but I was wondering why PHP is
 inserting those extra characters.

I don't know that this will help, but maybe it will provide a clue.
A textarea field will insert CRLF in its posted contents. You might
expect this to be governed by the platform the browser is running on,
but no. It inserts CRLF anyway.

Like I said, just a clue.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Searching on AlphaNumeric Content Only

2009-09-04 Thread Paul M Foster
On Fri, Sep 04, 2009 at 04:22:18PM -0400, Eddie Drapkin wrote:

 On Fri, Sep 4, 2009 at 12:02 PM, Lupus
 Michaelismickael+...@lupusmic.org wrote:

 if you're on shared hosting (but then again I am of the opinion
 that those who choose to run with shared hosting dig their own graves
 in more ways than one).

Any time you or someone else would like to backstop me in setting up a
dedicated server on rackspace or somewhere else, for free or really
cheap, you let me know! Otherwise, those of us with less than complete
expertise in server setup are stuck with shared hosting. ;-}

Paul

-- 
Paul M. Foster

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



Re: [PHP] Searching on AlphaNumeric Content Only

2009-09-04 Thread Paul M Foster
On Fri, Sep 04, 2009 at 08:15:41PM -0400, Robert Cummings wrote:

 Paul M Foster wrote:
 On Fri, Sep 04, 2009 at 04:22:18PM -0400, Eddie Drapkin wrote:

 On Fri, Sep 4, 2009 at 12:02 PM, Lupus
 Michaelismickael+...@lupusmic.org wrote:

 if you're on shared hosting (but then again I am of the opinion
 that those who choose to run with shared hosting dig their own graves
 in more ways than one).

 Any time you or someone else would like to backstop me in setting up a
 dedicated server on rackspace or somewhere else, for free or really
 cheap, you let me know! Otherwise, those of us with less than complete
 expertise in server setup are stuck with shared hosting. ;-}

 For a few hundred bucks a year you can get a VPS (Virtual Private
 Server), which gives you root access. once you get a couple of clients
 on it, it will pay for itself year after year. If you have clients that
 don't use much resources, you can put a few on and even make a profit on
 the hosting alone.

Oh sure. Well aware of it. The problem is not finding a VPS or working
with root access or anything like that. The problem is expertise. POP3,
SMTP, SSH, HTTP, DNS, firewall security while still allowing access to
outward facing servers, etc. It's more expertise than most people have,
including me. The servers I run are internal and don't have to deal with
the rigors of the internet, and only serve a couple of people. Setting
up multiple domains under an Apache server is black magic to me, for
instance. And then there's backups, and
what-do-I-do-if-the-server-fails, etc. Sheesh.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Date Comparison

2009-09-03 Thread Paul M Foster
On Thu, Sep 03, 2009 at 10:20:49AM +0100, Stuart wrote:

 2009/9/3 J DeBord jasdeb...@gmail.com:
  Telling someone RTFM is just rude and mean. Manipulating dates and times can
  be confusing for beginners and experienced people alike. I would suggest
  that when a question asked here causes you to respond with RTFM, don't
  respond at all. Save yourself the time and trouble and save the person
  asking the question the grief of being insulted. And Tedd your condescending
  response caused me to lose respect for you. I'm sure the OP would have been
  more than thankful to receive the same response without the RTFM. I'll read
  any response to this, but I won't have anything more to say. This list has
  been polluted enough lately with nonsense. Incredible.
 
 You're entitled to your opinion as much as I am, and my opinion is
 that not making it clear to people that the answer to their question
 is plainly obvious in the manual is just as rude if not more so than
 suggesting they RTFM.
 
 I make a point to never just say RTFM but to also answer the question
 at the same time, but IMHO not telling people how fundamental their
 question was does not help them in the long run. At the end of the day
 it just encourages them to continue to rely on this list rather than
 learning how to find the answer themselves and to only use this list
 as a last resort.
 
 I make no apology for my attitude towards this type of question, and
 if you don't like it you can stick it where the sun don't shine.

+1

I can't argue with this approach. If you're going to point the poster to
the manual and *then* explain, that's the ideal way to do this. Now it
could be argued that you could say, Please refer to
http://php.net/manual/en/whatever.php for more info. Or you could say,
RTFM. The former is more polite, but the latter will suffice. Both
mean the same thing; one is simply more terse.

Also stipulated that one should research a question as much as possible
before posting to this list. We're not tutors; more like professional
side-checkers.

(Please don't take this the wrong way, newbies. You're welcome to ask
questions here. Just do whatever research you can first, and follow our
advice afterward, to RTFM.)

Paul

-- 
Paul M. Foster

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



<    1   2   3   4   5   6   7   8   9   10   >