RE: [PHP] Inspiration for a Tombstone.

2008-06-26 Thread Edward Kay
> 
> What would you like on your Tombstone? (<-- that's actually a 
> trademarked saying)
> 

I've always liked Spike Milligan's:

 "I told you I was ill"

:)

http://news.bbc.co.uk/1/hi/england/southern_counties/3742443.stm

Edward

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



RE: [PHP] Problem with IE 6.0

2008-06-25 Thread Edward Kay
> I have a problem with the cache in Internet Explorer version 6.0
>
> When I put these lines in the page
>
> header ("Expires: Mon, 1 Jan 1997 01:00:00 GMT");
> header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
> header ("Cache-Control: no-cache, must-revalidate");
> header ("Pragma: no-cache");
>
> Internet explorer stills make the cache to the page, is there any
> solution to these problem and how is it?

These are the headers I send when I want to prevent any caching:

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")."GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0");
header("Pragma: no-cache");

These work fine for me in all browsers.

HTH,
Edward


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



RE: [PHP] PDF inline viewer

2008-06-20 Thread Edward Kay

> Mário Gamito wrote:
> > Hi,
> > 
> > Does someone knows of a PHP software that is an inline PDF reader ?
> > You can view the idea here:
> > 
> http://www.scribd.com/doc/2025925/Clinical-chemistry-II-Biomedical
> -Science-practical-1
> > 
> > Any help would be appreciated.
> > 
> > Warm Regards,
> > Mário Gamito
> 
> What will happen if you open the PDF file in iframe? - then you will 
> have all controls from the Acrobat Reader plug-in. Or do you need 
> something more elaborate?
> 
> Iv
> 

The IFRAME method mentioned by Iv would work OK.

If you like Scribd though, why not use their platform?
http://www.scribd.com/platform/home

Edward


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



RE: [PHP] imap_open() error. (Can't open mailbox)

2008-06-09 Thread Edward Kay


> -Original Message-
> From: Thijs Lensselink [mailto:[EMAIL PROTECTED]
> Sent: 09 June 2008 13:43
> To: php-general@lists.php.net
> Subject: Re: [PHP] imap_open() error. (Can't open mailbox)
>
>
> Quoting Mathijs van Veluw <[EMAIL PROTECTED]>:
>
> > Thijs Lensselink wrote:
> >> Quoting Mathijs van Veluw <[EMAIL PROTECTED]>:
> >>
> >>> Hello there,
> >>>
> >>> i use imap to read incoming mail from the the SMTP server.
> >>> On the live server everythings works as it should.
> >>> I can use imap_open('/path/to/file', '', ''), to read just
> one raw-mail.
> >>> On my test env i can't get this to work.
> >>>
> >>> I get the error message: "Can't open mailbox".
> >>> While on the live server it works and i get the correct resource
> >>> "resource(42) of type (imap)".
> >>>
> >>> I realy don't know what the problem is.
> >>> Can someone help me with this?
> >>>
> >>> Thanks in advance.
> >>> Mathijs.
> >>>
> >>
> >> I didn't work with IMAP much. So one suggestion could be to check
> >> if your dev box is behind a proxy server. If you're using SSL check
> >>  if it's enabled on your dev box.
> >>
> >>
> > the imap_open() only gets a file location.
> > This file containts a raw-mail, so no need for ssl or proxy stuff etc..
> >
>

Have you checked the permissions on the mail file? Are your dev and live
boxes both running PHP in the same manner (Apache module vs CGI)? Can you
open the same file with fopen?

Edward


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



RE: [PHP] Escaping JavaScript strings

2008-05-29 Thread Edward Kay

> 
> This is a PHP function that escapes strings so you can output them as a 
> JS string. IIRC it assumes you're using single quotes to enclose your 
> strings.
> 
>  /**
>  * Function to appropriately escape a string so it can be output
>  * into javascript code.
>  *
>  * @param  string $string Input string to escape
>  * @return string Escaped string
>  */
>  function escapeString($string)
>  {
>  $js_escape = array("\r" => '\r',
> "\n" => '\n',
> "\t" => '\t',
> "'"  => "\\'",
> '\\' => '');
> 
>  return strtr($string, $js_escape);
>  }


Just what was needed - thanks Richard.

Edward

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



[PHP] Escaping JavaScript strings

2008-05-29 Thread Edward Kay
Hello,

I'm adding functionality to allow a user to copy data on a page to the
clipboard using JS. This can be done simply with:

  window.clipboardData.setData('Text','String to copy to clipboard');

The string from PHP needs to contain line breaks when copied into the
clipboard. This works when I use \n, e.g. 'This string\nspans
multiple\nlines' but how do I escape this string when outputting it from
PHP?

addslashes() seems the obvious choice, but as it escapes backslashes, the \n
chars end up in the clipboard!



Using hard new lines in the argument passed to the JS function doesn't work
as this causes JS errors:

DOESN'T WORK:


var sCopy = 'String to copy
to clipboard';







Any ideas?

Thanks,
Edward


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



RE: [PHP] PHP debugger

2008-04-29 Thread Edward Kay
> -Original Message-
> From: Jason Pruim [mailto:[EMAIL PROTECTED]

> Morning,
>
> So looking at those scripts I realized that perl is nothing like php ;)
>
> Is there other info that the different places need? or is it just a
> different URL?
>
> I'm wondering why you could do something like:
>
> 
> switch(strtolower($ext)) {
> case 'es';
> case 'com.es';
> case 'org.es';
> case 'edu.es';
> case 'gob.es';
>   $cmd = HTTP://www.myCool.es/?query="$nom.$ext";
>   break;
> case 'eu';
>   $cmd = HTTP://www.myCool.eu/?query="$nom.ext";
>   break;
> default;
>   $cmd = HTTP://www.whois.com/?query="$nom.ext";
> break;
> }
> ?>
>
> instead of calling out to a different script?
>
> Also, I noticed that in your script where you have "default:" in your
> switch, you have a : instead of a ;
>

Actually, the colon is correct: http://uk.php.net/switch

You also need to enclose your string declarations correctly and add the $
before ext, e.g.
$cmd = "http://www.whois.com/?query=$nom.$ext";;
or
$cmd = 'http://www.whois.com/?query='.$nom.'.'.$ext;

Edward


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



RE: [PHP] Checking how many letters are in a string.

2008-03-20 Thread Edward Kay
> -Original Message-
> From: tedd

> Chapter 4 is all about l16n, L10n, and Unicode. Makes a good read.

What's l16n?

Did you mean i18n (internationasation)?

(I'm not being a pedant; just wondered if I was missing something) :)

Edward

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



RE: [PHP] algorithm of pages beaking

2008-03-19 Thread Edward Kay

> Hi,
> 
> I am working in page breaking (dividing the result of
> a select query in multiple pages).
> 
> Now my problem is not with the php code, but with the
> algorithm that organize the links to the pages. I want
> to do something like google, the pages numbers at the
> bottom of the page must not exceed a maximum number,
> the actual page must be in the center of the links to
> other pages and there are a lot of other conditions
> that arise.
> 
> Do you know about a site that describe these
> conditions or may be propose the whole algorithm for
> that?
> 
> Thank you
> 
> 

http://www.google.co.uk/search?q=pagination+php

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



RE: [PHP] Double click problem

2008-03-19 Thread Edward Kay
> Hi gang:
>
> I have a situation where users can purchase stuff online.
>
> In the last step in the process, the user clicks a "confirm purchase"
> button and their credit card is checked and if it's valid, they are
> awarded the product. Everything works, but it takes a little time to
> check the credit card.
>
> During the time it takes to send the credit card information to the
> clearing house and get back an "Ok" with a transaction ID, the user
> can click the "confirm purchase" button more than once. As such, more
> than one order can be made during the process.
>
> I was thinking of using the database to prohibit multiple "confirm
> purchase" clicks made by the user, but I wanted to ask this group if
> anyone has a simpler idea/solution?
>
> Thanks,
>
> tedd

Oh, I'd also add a bit of text near the button saying:

"Please click this button ONCE only. Clicking again may result in your
credit card being billed twice."

I'm always much more precise with my clicking when such warnings are
displayed :)

Edward


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



RE: [PHP] Double click problem

2008-03-19 Thread Edward Kay
> Hi gang:
>
> I have a situation where users can purchase stuff online.
>
> In the last step in the process, the user clicks a "confirm purchase"
> button and their credit card is checked and if it's valid, they are
> awarded the product. Everything works, but it takes a little time to
> check the credit card.
>
> During the time it takes to send the credit card information to the
> clearing house and get back an "Ok" with a transaction ID, the user
> can click the "confirm purchase" button more than once. As such, more
> than one order can be made during the process.
>
> I was thinking of using the database to prohibit multiple "confirm
> purchase" clicks made by the user, but I wanted to ask this group if
> anyone has a simpler idea/solution?
>
> Thanks,
>
> tedd

How about a bit of JavaScript that disabled the button when the form was
submitted? This is used by eBay and Google for their login processes.

Sure, if JS was disabled this could be circumvented but it would be a good
start and work with the majority of users.

Edward


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



RE: [PHP] Fastest way to get table records' number

2008-03-19 Thread Edward Kay
> > > At 10:35 AM -0400 3/19/08, Nathan Nobbe wrote:
> > > >On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard <[EMAIL PROTECTED]>
> > wrote:
> > > >
> > > >>  That works; I'm just wondering why you went with a count
> on an 'ID'
> > column
> > > >>  rather than COUNT(*).
> > > >
> > > >
> > > >ouch, it looks like im horribly wrong :O
> > > >mysql> select count(*) from table;
> > > >+--+
> > > >| count(*) |
> > > >+--+
> > > >|   361724 |
> > > >+--+
> > > >1 row in set (0.90 sec)
> > > >
> > > >mysql> select count(id) from table;
> > > >++
> > > >| count(did) |
> > > >++
> > > >| 361724 |
> > > >++
> > > >1 row in set (4.56 sec)
> > > >
> > > >-nathan
> > >
> > > That surprised me as well.
> > >
> > > I thought that (*) meant "look up everything" and would have figured
> > > that (id) would have been quicker.
> > >
> > >
> >
> > You generally want to explicitly specify column names rather than
> > using SELECT *, because it returns everything even if you don't need
> > it. But for aggregate COUNT, I'm not surprised by the results Nathan
> > got.
> >

> what about SELECT MAX(id) FROM table :)

But that's not the same thing. If any rows have been deleted, then this
would give the wrong answer.

Edward


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



RE: [PHP] Comparing files

2008-03-12 Thread Edward Kay


> -Original Message-
> From: Andrés Robinet [mailto:[EMAIL PROTECTED]
> Sent: 12 March 2008 12:33
> To: 'Edward Kay'; 'mathieu leddet'; php-general@lists.php.net
> Subject: RE: [PHP] Comparing files
>
>
> > -Original Message-
> > From: Edward Kay [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, March 12, 2008 7:13 AM
> > To: mathieu leddet; php-general@lists.php.net
> > Subject: RE: [PHP] Comparing files
> >
> >
> >
> > > -Original Message-
> > > From: mathieu leddet [mailto:[EMAIL PROTECTED]
> > > Sent: 12 March 2008 11:04
> > > To: php-general@lists.php.net
> > > Subject: [PHP] Comparing files
> > >
> > >
> > > Hi all,
> > >
> > > I have a simple question : how can I ensure that 2 files are
> identical ?
> > >
> > > How about this ?
> > >
> > > 8<--
> > >
> > > function files_identical($path1, $path2) {
> > >
> > >   return (file_get_contents($path1) == file_get_contents($path2));
> > >
> > > }
> > >
> > > 8<--
> > >
> > > Note that I would like to compare any type of files (text and binary).
> > >
> > > Thanks for any help,
> > >
> >
> > Depending upon the size of the files, I would expect it would
> be quicker to
> > compare a hash of each file.
> >
> > Edward
> >
>
> I don't understand how comparing hashes can be faster than
> comparing contents,
> except for big files for which you will likely hit the memory
> limit first and
> for files who only differ from each other at the very end of them, so the
> comparison will only be halted then. If the file sizes vary too
> much, however, a
> mixed strategy would be the winner; and certainly, you will want
> to store path
> names and calculated hashes in a database of some kind to save
> yourself from
> hogging the server each time (yeah, CPU and RAM are cheap, but
> not unlimited
> resources).
>
> Comparing hashes means that a hash must be calculated for files A
> and B and the
> related overhead will increase according to the file size (right
> or wrong?).
> Comparing the file contents will have an associated overhead for
> buffering and
> moving the file contents into memory, and it's also a linear
> operation (strings
> are compared byte to byte till there's a difference). So... why
> not doing the
> following?
>
> 1 - Compare file sizes (this is just a property stored in the file system
> structures, right?). If sizes are different, the files are
> different. Otherwise
> move to step 2.
> 2 - If the file sizes are smaller than certain size (up to you to find the
> optimal file size), just compare contents through, say, file_get_contents.
> Otherwise move to step 3.
> 3 - Grab some random bytes at the beginning, at the middle and at
> the end of
> both files and compare them. If they are different, the files are
> different.
> Otherwise move to step 4.
> 4 - If you reach this point, you are doomed. You have 2 big files
> that you must
> compare and they are apparently equal so far. Comparing contents
> will be over
> killing if at all possible, so you will want to generate hashes
> and compare
> them. Run md5_file on both files (it would be great if you have,
> say, file A's
> hash already calculated and stored in a DB or data file) and
> compare results.
>
> It is always up to what kind of files you are dealing with, if
> the files are
> often different only at the end of the stream, you may want to
> skip step 2. But
> this is what I would generally do.
>
> By the way, md5 is a great hashing function, but it is not bullet-proof,
> collisions may happen (though it's much better than crc32, for
> example). So, you
> may also think of how critical is to you to have some false
> positives (some
> files that are considered equal by md5_file and they are not) and
> probably use
> some diff-like solution instead of md5_file. Anyway, having
> compared sizes and
> random bytes (steps 1 through 3), it's very likely that md5_file
> will catch it
> if two files are different in just a few bytes.
>

Agreed. In by first reply, I meant that hashes would likely be quicker/more
memory friendly when handling larger files, but this is just a hunch - I
haven't benchmarked anything. It was really meant to give the OP other
possibilities to look into.

Edward


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



RE: [PHP] Comparing files

2008-03-12 Thread Edward Kay


> -Original Message-
> From: mathieu leddet [mailto:[EMAIL PROTECTED]
> Sent: 12 March 2008 11:04
> To: php-general@lists.php.net
> Subject: [PHP] Comparing files
>
>
> Hi all,
>
> I have a simple question : how can I ensure that 2 files are identical ?
>
> How about this ?
>
> 8<--
>
> function files_identical($path1, $path2) {
>
>   return (file_get_contents($path1) == file_get_contents($path2));
>
> }
>
> 8<--
>
> Note that I would like to compare any type of files (text and binary).
>
> Thanks for any help,
>

Depending upon the size of the files, I would expect it would be quicker to
compare a hash of each file.

Edward


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



RE: [PHP] Anyone jump from Studio 5.5.x -> Zend Eclipse?

2008-03-03 Thread Edward Kay
>... for me one of the most useful 
> thing in Zend is (CTRL+D X,C or Apple+D , X, C) which 
> duplicates copies and paste lines in Studio , switching to 
> Eclipse I just miss those shortcuts so I am always finding 
> myself going back to Z. Studio

To duplicate the current line in Eclipse, just use Ctrl+Alt+Up Arrow.

To see a list of Eclipse short-cuts, use Ctrl+Alt+L

HTH,
Edward

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



RE: [PHP] How do you send stylized email?

2008-02-26 Thread Edward Kay
> > Ex's are the experience you need to get it to work.
> >
> > I've always said that everyone should go through at least one divorce
> > before getting married.
>
> Marriage?? That's for backwards people stuck in ancient pointless
> traditions >:) And moreso in today's culture... it's just a commercial
> suckfest when your money could better go to student loans and raising a
> family.

Possibly. Or as I prefer to see it, it's the one time in your life when you
surround yourself with all your friends and family to celebrate your
relationship.

> I've been happily living in sin with my common-law wife for 9 years.
> Besides, isn't marriage primarily a religious thing?

Not necessarily. My wife and I have no religion so had a civil ceremony -
held in the Assembly Rooms, Bath which was an 18th Century gambling venue ;)

> In the old
> testament marriage was often implied by the simple act of laying with a
> woman... or two... or three... Polygamy, how did that fall out of
> religious favour? :)

Not in the UK. In UK law there is no such thing as a common-law
wife/husband. If you're unmarried, you have as many rights to the other
person as the day you first met - practically none.

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



RE: [PHP] Converting tab delimited file to CSV

2008-02-18 Thread Edward Kay

> On Mon, February 18, 2008 10:36 am, Jay Blanchard wrote:
> > [snip]
> > That's funny... MS defaults to tabs for a file whose extension is .csv
> > which is an acronym for (C)omma (S)eparated (V)alues.
> > [/snip]
> >
> > Welcome to Microsoftwhere do we want you to go today?
>
> I think it defaults to whatever you last used, not to a specific choice.
>

That would seem to be a possibility. I can quite happliy double-click a .csv
file and have it open correctly in Excel.

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



RE: [PHP] Converting tab delimited file to CSV

2008-02-18 Thread Edward Kay

> Now, I can replace the tabs with commas and opening the resulting
> files in a basic text editor all looks fine.

When you do this, ensure you escape any commas that may exist in the data.

IIRC, Excel handles this be enclosing the whole field in "double quotes".
Can remember how it handles escaping these though...

Edward

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



RE: [PHP] Recommended ORM for PHP

2008-02-06 Thread Edward Kay

> When creating a LAMP app, I always start by writing ORM myself.
> It's fun but it usually takes a  long time.
> Besides, that always results in a toy-system,
> I mean, that has not so many features, not so efficient non-bug-free.
>
> I started to think that now is the time  to throw away my rubbish
> and use more effective Open source ORM.
>
> So my  question is what ORM are you using?
> What ORM do you recommend?
> There're lots of Web app frameworks out there
> but I could't find simple ORM in PHP.
>
> Thanks in advance.
>

Have a look at Qcodo. http://www.qcodo.com.

It uses code generation to create your ORM for you direct from the DB
tables. As it's code generation as opposed to run time analysis (which is
what ActiveRecord and the like use), there is no performance hit - it
literally just creates your PHP class files for you.

There is a framework aspect to Qcodo called QForms but this is decoupled
from the generated ORM so you don't have to use it if you don't want it.

HTH,
Edward

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



RE: [PHP] Re: how dod you get to do multiple mysql queries concurrently?

2008-01-25 Thread Edward Kay
> Per Jessen wrote:
> > Colin Guthrie wrote:
> > 
> >> Per Jessen wrote:
> >>> I know how to do multiple queries - the key issue in my question was
> >>> how to do them concurrently (i.e. in parallel).
> >> So you want to make PHP multithreaded???
> > 
> > No, just the mysql queries.  
> 

If you're selecting data, could you not reduce the number of queries using 
joins?

If you're inserting data, look into MySQL's INSERT DELAYED syntax.

HTH,
Edward

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



RE: [PHP] export data to a ms excel file using php

2007-12-18 Thread Edward Kay

> can you help me to export data to a ms excel file using php. i tried to
> export them to an html format and change the extension to .xls that's work
> but i have lost the formatting

Save the data from PHP in comma separated value (CSV) format.

Edward

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



RE: [PHP] Convertig xml into array

2007-11-27 Thread Edward Kay

> -Original Message-
> From: Dave Goodchild [mailto:[EMAIL PROTECTED]
> Sent: 27 November 2007 08:36
> To: PHP General list
> Subject: [PHP] Convertig xml into array
>
>
> Hi guys. I have the following XML file which I want to convert into a
> multidimensional array. I am using PHP5 so don't want to use
> SimpleXML as apparently there are issues with sessions and after
> conversion I want to pass this array into the session. Any ideas on
> the best and cleanest way to do this?
>
> 

Hi Dave,

The issue with sessions is simply that SimpleXML objects do not persist in
sessions. To workaround this, just use the asXML() function so your XML is
stored as a string in the session. You can then recreate the SimpleXML
object from this string as and when you need it.

Edward

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



RE: [PHP] recommendation for a article manager

2007-11-15 Thread Edward Kay
>
> Hi,
> I'm looking for a recommendation for a small easy to use "free" article
> manager.It must be able to fit in with existing site and be able
> to include
> a picture.It does not need an all singing editor a simple form
> system will
> do I can control the look by css.
>

I'm currently doing the same thing to add press releases/news archive in our
existing site. Using Wordpress with a custom theme is working well at the
moment.

HTH,
Edward

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



RE: [PHP] Help securing a server : Owned by W4n73d H4ck3r

2007-11-09 Thread Edward Kay

> 
> I'd be interested in reading this thread. OK with me to keep it 
> on the list.
> 

Ditto.

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



RE: [PHP] Fatal error when calling nested function

2007-10-26 Thread Edward Kay
>
>  function salestax($price,$tax) {
> function convert_pound($dollars, $conversion=1.6) {
> return $dollars * $conversion;
> }
> $total = $price + ($price * $tax);
> echo "Total cost in dollars: $total. Cost in British pounds: "
> .convert_pound($total);
> }
> salestax(15.00,.075);
> echo "" . convert_pound(15);
> ?>
>

That's still pretty nasty though:



salestax(15.00,.075);
salestax(15.00,.075);
?>

gives:

Total cost in dollars: 16.125. Cost in British pounds: 25.8
24
Fatal error: Cannot redeclare convert_pound() ...


What's wrong with non-nested functions? i.e.:

function convert_pound($dollars, $conversion=1.6) {
return $dollars * $conversion;
}

function salestax($price,$tax) {
$total = $price + ($price * $tax);
echo "Total cost in dollars: $total. Cost in British pounds: "
.convert_pound($total);
}

E

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



RE: [PHP] Fatal error when calling nested function

2007-10-26 Thread Edward Kay

> Here's the list :
>
>  function salestax($price,$tax) {
> function convert_pound($dollars, $conversion=1.6) {
> return $dollars * $conversion;
> }
> $total = $price + ($price * $tax);
> echo "Total cost in dollars: $total. Cost in British pounds: "
> .convert_pound($total);
> }
> echo convert_pound(15);
> ?>
>
> I get the following error :
>
> *Fatal error*: Call to undefined function convert_pound() in
> ...*Untitled-1.php* on line *18
>
> *line 18 is this one : echo convert_pound(15);
>

From
http://www.daaq.net/old/php/index.php?page=php+adv+functions&parent=php+flow
+control:

"When you define a function within another function it does not exist until
the parent function is executed. Once the parent function has been executed,
the nested function is defined and as with any function, accessible from
anywhere within the current document. If you have nested functions in your
code, you can only execute the outer function once. Repeated calls will try
to redeclare the inner functions, which will generate an error."

So, as you're not calling salestax() anywhere, the convert_pound function
isn't defined.

I wasn't aware of nested functions before your question, but reading the
above on how the declaring function can only be called once, I feel they are
best avoided. Does anyone have anyone have any examples where using them
would be beneficial?

E

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



RE: [PHP] window.open() and search engines

2007-10-23 Thread Edward Kay
>
> Can anyone say for sure whether window.open() links get spidered by
> search engines?
>

>From my experience they don't, but I use a custom Javascript function to
open pop-ups.

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



RE: [PHP] Newbie: special characters in regex?

2007-09-25 Thread Edward Kay

> 
> I'm trying to modify a string so that it can be used as a Distinguished
> Name in an LDAP operation. Distinguished Names must have special
> characters, such as (, ), / and \ escaped with a backslash. For
> instance, 'Kevin (Kev) Zembower, III" becomes 'Kevin \(Kev\) Zembower\,
> III'.
> 
> I tried to do this in this statement:
> $entry['FirstName'] = preg_replace('/(\)|\(|\,|\/)/',`\\$1',
> $entry['FirstName'];
> 
Two things I can see straight off that will give you a parse error:

1. You've used a back tick instead of a single quote before \\$1

2. There's no closing parenthesis to the preg_replace function.

Edward

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



RE: [PHP] Merging PDF Documents

2007-09-24 Thread Edward Kay
>
> Please can someone tell me if this is easy to do or whether I should
> use a package already available...
>
> I want to upload a pdf file to a folder then for each subsequent
> upload, I want it to be appended to the original file. Each pdf is a
> timesheet, so I want to end up with one file for all timesheets
> instead of different files every week.
>
> What I'd like to know is which function I can use on PHP4?
> Is it PDF_begin_page_ext?
> Any help appreciated.
>
> Thanks,
>
> Tom

I haven't used the PDF functions in PHP, but I think they're primarily
designed for creating new PDF files.

I think http://www.linux.com/articles/36815 will be helpful to you though.

Edward

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



RE: [PHP] Very Large text file parsing

2007-09-20 Thread Edward Kay

> Paul Scott wrote:
> > I have a very large text file that gets dumped into a directoory every
> > now and then. It is typically around 750MB long, at least, and my
> > question is:
> >
> > What is the best method to parse this thing and insert the data into a
> > postgres db?
> >
> > I have tried using file(), fget*() and some others, all with limited
> > success. It goes through OK (I am sending it to a background process on
> > the server and using a callback function to email me when done) but it
> > is really knocking the machine hard, besides taking a real long time to
> > finish.
> >
> > Is there a better way of approaching this? Any help would be greatly
> > appreciated.
>
> First, which is your approach? I suspect that you are doing this with a
> cron job through php-cli.
>
> Now, to avoid using to many resources, try with fopen() and fgets().
> Also work with persistent connections, so you don't have that overhead.
>
> The problem with file() is that it will load all the file to memory, and
> you don't want 700+MB in memory.

In addition to Martin's good suggestions (and also assuming you're running
php-cli via cron), you could use nice to stop it consuming too many
resources:

http://en.wikipedia.org/wiki/Nice_%28Unix%29

Edward

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



RE: [PHP] highlighting searchterms as bold text

2007-09-20 Thread Edward Kay

> > Hi everyone,
> >
> > I want to highlight (bold) searchterms in text.
> > For example, for all words starting with "ethyl":
> > a) replace "ethyl" by "ethyl"
> > b) replace "Ethyl" by "Ethyl"
> > c) replace "ethylene" by "ethylene"
> > d) but not "methyl" by "methyl"
> >
> > Now I use:
> > $patterns[0] = "/ethyl/";
> > $replacements[0] = "ethyl";
> > $text = preg_replace($patterns, $replacements, $text);
> >
> > This works for a) and c), but not for b) and d).
> > Any idea how to do this ?
> >
> > TIA, Cor
> >
>
> Thanks Deniz,
>
> I tried pattern /^ethyl/i but this does not highlight anything.
> I also tried pattern /ethyl/i and this highlights all, but also methyl ...
> Any suggestion ?
>

Yes, the i pattern modifier makes the search case-insensitive, which is what
you want.

The carat ^ means start of string, so would only word if the pattern was at
the beginning of the line - not what you want.

Try something like this:

/(\s|>)ethyl(\s|<)/i

The \s means whitespace so (\s|>) means only match if ethyl is preceded by
whitespace or >, i.e. a closing tag.

Alternatively, have a look at http://suda.co.uk/projects/SEHL/.

Edward


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



RE: [PHP] dynamic

2007-09-18 Thread Edward Kay

> >> thumb.php
> >>  >> header("Content-type: image/jpg");
> >> $file = "data/original/filename.jpg";
> >> readfile($file);
> >> ?>


Change
  header("Content-type: image/jpg");
to
  header("Content-type: image/jpeg");

Apparently IE doesn't like image/jpg [1].

[1] http://pear.php.net/bugs/bug.php?id=4586

Edward

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



RE: [PHP] Try to find a solution, when restart Apache with PHP Script

2007-09-17 Thread Edward Kay
> I'm facing a serious problem with my application. I have a script write
> in PHP that starts in Internet Explorer, this script keep on running
> until a varible value change on my MySQL database.
> The problem is that when i restart Apache, the process child initalized
> isn't kill... then the apache can't be start because the script is use
> the port 80.
>
> To solve my problem, without change anything, the best would be that
> when i execute the script, it run on other port than the default 80...
> so this way apache could start...
> The is a way to redirect through php, so the script run on a diferent
> port?? Like change some line, or add on php.ini files?? or even in
> programming??
>
The TCP port used is configured by Apache. You can't change this in PHP. In
any case, I very much doubt it would solve your problem since it will still
be blocking on whatever port you use.

To resolve this issue, you need to work on why IE is holding the connection
open. Perhaps a better solution is to simply have the client poll a PHP
script to determine when desired condtion occurs.

Edward

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



RE: [PHP] PHP 5.2.3 - Segmentation fault (core dumped)

2007-09-12 Thread Edward Kay

> Dear all,
> 
> I hope you can help me. I am running FreeBSD 6.2 and I decided to
> upgrade from php 4.4.7_1 to php5-5.2.3_1. However, after removing php4
> and installing php5 and php5-extensions I am unable to start apache.

What do the Apache error logs say?

Edward

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



RE: [PHP] html to xml?

2007-09-12 Thread Edward Kay

> Slith wrote:
> 
> > i need to parse an html page for tabular data which i can then import
> > into mysql so i thought converting the html to xml might be a feasible
> > thing to do, however, other than using tidy from the command line i
> > can't find a way to do this from php.
> > 
> > does anyone know of any class (or other) that would allow me to do
> > this? or maybe i just need a different approach.
> 
> Is this a one-off or will you be doing this often?
> 
> For a one-off I would just use sed/grep/awk/cut/tr etc. - HTML pages are
> rarely syntactically correct, so trying to parse them or even turn them
> into XML is tiresome at best. 

For one-off, I'd simply copy/paste the data from the browser into Excel/OO Calc 
and save as CSV.

Edward

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



Re: [PHP] Loosing session data between requests

2007-09-06 Thread Edward Kay



robert mena wrote:

I've checked both /tmp and the session file sess_x in one server is
empty and in another has the data.  Both $_SESSION are ok (I've checked with
a var_dump).

  

Check the permissions on /var/lib/php/session

Edward

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



Re: [PHP] IE Not Following Header("Location: /path/to/file.php");

2007-09-06 Thread Edward Kay

Scott Wilcox wrote:

hey folks.

I have a strange problem with IE sometimes. It doesn't seem to accept
and follow a header sent to the browser. The action occurs when a user
logs in, then is sent this header.

Any hints/ideas appreciated.

Scott.
  
Get Microsoft's (free) Fiddler Tool and look at the exact info been sent 
and received:

http://www.fiddlertool.com/fiddler/

Edward

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



RE: [PHP] Generating foldout menus in php

2007-09-06 Thread Edward Kay


> -Original Message-
> From: Ken Kixmoeller -- reply to [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: 06 September 2007 16:48
> To: tedd; php-general@lists.php.net
> Subject: Re: [PHP] Generating foldout menus in php
> 
> 
> 
> On Sep 3, 2007, at 12:42 PM, tedd wrote:
> 
> 
> > that would be more complicated than just using css with js, like so:
> >
> > http://sperling.com/examples/menuh/
> >
> > http://sperling.com/examples/menuv/
> >
> > Why complicate your life?
> >
> 
> Hey, tedd - - - -
> 
> I like this tool, and am playing with it -- --
> 
> Just wondering, though, if you have ever created PHP code to generate  
> these menus on-the-fly? I am working on an intranet application in  
> which I take values from rights-and-responsibilities tables and use  
> it to generate navigation options. Got a start on it, but if you  
> already had some code I'd appreciate getting a gander at it.
> 

Hi Ken,

You may want to take a look at Yahoo's YUI menu:
http://developer.yahoo.com/yui/menu/

These can be defined using standard XHTML markup.

Edward

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



RE: [PHP] Heredocs

2007-08-29 Thread Edward Kay
> Are heredocs supported by PP 5.2.3 running in WinXP/Apache2.2.4 ?
> I prrint via heredocs and its not working. Print with single quotes and
> double quotes work.
>
>   
>   string init method 3: heredocs
>  print <<< END
>   Test
>   END;
>   ?>
>   
>

This won't work because you've indented the closing identifier. Read the big
Warning box at
http://uk2.php.net/manual/en/language.types.string.php#language.types.string
.syntax.heredoc

Edward

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



RE: [PHP] Good php-news newsletter?

2007-08-24 Thread Edward Kay

> Well, I'm already subscribed to this one :)
>
> Too much noise, newbie questions and stuff that I already know about.
> There's lots of valuable info but it needs to be plowed through. Also
> too many individual emails, I was looking for a daily / weekly digest.
>
> But thanx for the answer anyway.

Yes, but I quickly see the threads to ignore. I also subscribe to a few RSS
feeds, but find I don't have the time to read them as much as I like. If
you're interested, they are:

http://www.planet-php.org/rss/
http://www.php-mag.net/magphpde/psecom,id,26,noeid,26,.html
http://www.phpdeveloper.org/phpdev.rss

Edward

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



RE: [PHP] Good php-news newsletter?

2007-08-24 Thread Edward Kay
>I was wandering if anyone knows a good php newsletter, one where you
> would get a digest of interesting news & libraries etc in your mailbox.
> You know, to keep you up-to-date and spark a few ideas without actively
> searching the net for it.

This list is the best resource I've found for this kind of info. Not only do
I see the issues people come up against thus getting an idea of their
projects, there are usually a number of solutions and view points presented.

Edward

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



RE: [PHP] mail() issue

2007-08-22 Thread Edward Kay

> -Original Message-
> From: Dan Shirah [mailto:[EMAIL PROTECTED]
> Sent: 22 August 2007 13:28
> To: Jay Blanchard
> Cc: php-general
> Subject: Re: [PHP] mail() issue
>
>
> The "." (period) is simply the end of my sentance in the email.
>
> The "From" address is specified in the php.ini and is fully qualified.
>
> If I hard code the value of $to into the mail function it works fine.
>
> $user_email = [EMAIL PROTECTED]
> $to = [EMAIL PROTECTED]
>
> mail($to, $subject, $message); = PHP Warning: mail() [function.mail]: SMTP
> server response: 504 : Recipient address rejected: need
> fully-qualified address

Is the mail server configured correctly? Can you manually connect to it and
successfully send a message? See http://www.yuki-onna.co.uk/email/smtp.html

Edward

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



RE: [PHP] a DOM object in $_SESSION ?

2007-08-17 Thread Edward Kay
> Does anyone know if this works?  I've been trying out a few things, and
> it doesn't seem to work.  I.e. the object is there, but the contents
> aren't.

I don't think it is possible due to the way PHP handles the XML data [1].

This is from 2002 / PHP 4.3 but a comment [2] in the PHP manual for
SimpleXML seems to suggest it is still the case. You could probably get
around it by using a string representation in the session variable.

[1] http://bugs.php.net/bug.php?id=20899&edit=1
[2] http://uk2.php.net/manual/en/ref.simplexml.php#74192

Edward

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



RE: [PHP] pecl in php5?

2007-08-16 Thread Edward Kay
> -Original Message-
> From: Per Jessen [mailto:[EMAIL PROTECTED]
> Sent: 16 August 2007 10:25
> To: php-general@lists.php.net
> Subject: [PHP] pecl in php5?
> 
> 
> I'm trying to install the pecl mailparse extension, but I'm not getting
> very far: 
> 
> pecl install mailparse
> pecl/mailparse requires PHP extension "mbstring"
> No valid packages found
> install failed
> 
> "mbstring" does not seem to be a php extension, and in any case I built
> php with "--enable-mbstring".  
> Can anyone help me get mailparse installed or at least figure out what's
> going on?  I'm using php-5.2.3.
> 
> 
> thanks
> Per Jessen
> 

Does mbstring show up in phpinfo()?

Edward

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



RE: [PHP] Access parent property from child

2007-08-09 Thread Edward Kay


> -Original Message-
> From: Suprie [mailto:[EMAIL PROTECTED]
> Sent: 09 August 2007 11:13
> To: php-general@lists.php.net
> Subject: [PHP] Access parent property from child
>
>
> dear all ...
>
> i have question, i've tried look at google but still can't figured out
> how to do it...
> i want access parent property from child object the code was like
>
> 
> class DAO
> {
> private $db;
> private $id;
>
> protected function getId()
> {
> return $this->id;
> }
> protected function setId($id)
> {
> $this->id   = $id;
> }
>
> function getDB()
> {
> return $this->$db;
> }
> function setDB($db)
> {
> $this->db   = $db;
> }
>
> public function load($id)
> {
> $query  = "SELECT * FROM ".
> constant(get_class($this)."::tableName").
> " WHERE ".
> constant(get_class($this)."::pkFields").
> "='".$id."'";
> $rs = $this->db->Execute($query);
> $cObj   = $rs->FetchObject(true);
>
> return $cObj;
> }
>
> public function save($rowData)
> {
> $this->db->debug = true;
> $query  ="Select * FROM
> ".constant(get_class($this)."::tableName")."\n";
> $res=$this->db->Execute($query);
> $insertSQL  = $this->db->GetInsertSQL($res,$rowData);
> $res=$this->db->Execute($insertSQL);
> if($res)
> return true;
>
> return false;
> }
>
> public function update($row, $id)
> {
> $query  =   "SELECT * FROM
> ".constant(get_class($this)."::tableName")."\n"
> .   "WHERE
> ".constant(get_class($this)."::pkFields")."='".$id."'";
> $res= $this->db->Execute($query);
> $updateSQL  = $this->db->GetUpdateSQL($res,$row);
> $db->Execute($updateSQL);
> }
>
> public function getAll($criteria='', $order='')
> {
> if(empty($order))
> $order  = constant(get_class($this)."::pkFields");
>
> $query  = "SELECT * FROM
> ".constant(get_class($this)."::tableName")."\n"
> . $criteria
> . "ORDER BY ".$order;
> $row=   $this->db->Execute($query);
> if(!$row)
> {
> $this->error= $this->db->ErrorMsg();
> return  false;
> }
> return $row->getArray();
> }
>
> }
>
> and i have this child
> 
> include 'BaseDAO.class.php';
> class TaskCLDAO extends DAO
> {
> const tableName = 'task';
> const pkFields  = 'task_id';
>
> function findWithRelation($id)
> {
>   $query = "select * from task LEFT JOIN log ON
> task.id=log.task_id";
>   $db  =  parent::getDB();
>   $res =  $db->Execute($query);
>   return $res->getArray();
> }
> }
>
>
> ?>
>
> and this is the class that called it
>
> 
> $obj   = new TaskCLDAO();
> $obj->setDB($db); //  i have another file called config that
> initialized the db;
> $res   = $obj->findWithRelation(1);
>
> ?>
>
> but the php's said
>
> Fatal error: Cannot access empty property...
>
> what does it mean ?? is there another way to access "$db" that
> parent have ?
>
> TIA


In function getDb()

  return $this->$db;

should be:

  return $this->db;

Also, although not strictly required, I suggest you add the public keyword
to your methods that don't specifiy their visibility.

Edward

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



RE: [PHP] ORM framework suggestion

2007-08-09 Thread Edward Kay

> -Original Message-
> From: Matt Arnilo S. Baluyos (Mailing Lists)
> [mailto:[EMAIL PROTECTED]
> Sent: 09 August 2007 00:35
> To: PHP-General
> Subject: [PHP] ORM framework suggestion
>
>
> Hello All,
>
> I'm thinking of using an ORM framework for a new project. From my
> research, I've found Propel and Doctrine (of course, there might be
> others).
>
> Would anyone suggest what ORM framework they're using right now? I am
> experienced with OOP and am just looking for a framework to speed
> things up.
>
> I can perhaps test-drive both frameworks above and see what works
> better for me but maybe there are users here who's have had experience
> with either one (or better, both).
>
> Regards,
> Matt
>

Have a look at Qcodo: http://www.qcodo.com

If you're not after a full framework, just use the code generator to build
your ORM. I've been using it for about a year now and found it excellent.

Edward

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



RE: [PHP] compose html body with variables

2007-08-06 Thread Edward Kay
> -Original Message-
> From: Matt [mailto:[EMAIL PROTECTED]
> Sent: 06 August 2007 15:38
> To: php-general@lists.php.net
> Subject: [PHP] compose html body with variables
>
>
> Hello,
>
> I'm trying to compose the body of an html email to use with the mail()
> function.  I'm running into problem because I'm not sure how to quote
> the multi-line body.  Here is what I have:
>
> $body = "
>echo "Hello, here is your quote from Freight Services. />";
>echo "Shipping from:  $origin to $destination";
> echo "";
> echo "Shipping subtotal $" . number_format($subtotal,2);
> echo "";
> echo "";
> echo "Freight charges $" .
> number_format($freightCharges,2);
> echo "";
> echo "Fuel surcharge $" . number_format($fuelSurcharge,2);
> echo "";
> echo "Pickup and delivery $" .
> number_format($pickupDelivery,2);
> echo "";
> echo "";
> echo "Miscellaneus costs (e.g. liftgates, etc.) below $"
> . number_format($miscCost,2);
> echo "";
> echo "";
> if ($liftgatePickup == "50"){
> echo "Adding liftgate on pickup $50.00";
> echo "";
> }
> if ($liftgateDelivery == "50"){
> echo "Adding liftgate on delivery $50.00";
> echo "";
> }
> if ($spectimeDelivery == "35"){
> echo "Adding cost of specific-time
> delivery $35.00";
> echo "";
> }
> if ($conventionDelivery == "35"){
> echo "Adding cost of convention delivery $35.00";
> echo "";
> }
> if ($dreyageWait != 0){
> echo "Adding cost for wait $" . $dreyageWait;
> echo "";
> }
> if ($insideDelivery == "25"){
> echo "Adding cost for inside delivery $25.00";
> echo "";
> }
> if ($notifyClient == "10"){
> echo "Adding cost for client notification $10.00";
> echo "";
> }
> echo "Total cost is $" . number_format($totalcost,2);
> echo "";
>
> echo "foo Services";
>
>
>$subject = "Online Freight Quote";
>
>mail($email, $subject, $body, "From:
> [EMAIL PROTECTED]: [EMAIL PROTECTED]:
> [EMAIL PROTECTED]: PHP 4.x\r\nMIME-Version: 1.0\r\nContent-Type:
> text/html; charset=iso-8859-1\r\n");
>
> If anyone could assist me I'd appreciate it very much,
>
> Matt
>

Hi Matt,

The problem here is that you're using echo statements, which output
directly. Instead you need to build a string containing this output, for
example:

$body = "Hello, here is your quote from Freight Services.";
$body .= "Shipping from:  $origin to $destination";

etc.

Note the use of the .= operator. This is the same as saying $body =
$body.'whatever';

At the end, $body will then contain the HTML body of your email which you
pass to the mail function.

Hope this helps,
Edward

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



RE: [PHP] php SHOW

2007-08-03 Thread Edward Kay
> -Original Message-
> From: Hulf [mailto:[EMAIL PROTECTED]
> Sent: 03 August 2007 11:56
> To: php-general@lists.php.net
> Subject: [PHP] php SHOW
> 
> 
> Is there a way to output my data and tables using a php version of SHOW? 
> Doesn't have to be pretty HTML just output to screen
> 
> Ta,
> 
> 
> R. 
> 

Look up print_r() and var_dump()

Edward

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



Re: [PHP] Validating Email Conditional

2007-08-01 Thread Edward Kay



CK wrote:

Hi,

My script is working, but valid returns true even if the user is 
bogus. What needs changing so both conditions have to match, the 
following attempt returned "unexpected logical"


 if (getmxrr($domaintld,$mxrecords)) && 
if(fsockopen($domaintld,25,$errno,$errstr,30)) {

 $valid = true;
 }


You don't need to write the second 'if', just wrap the two conditionals 
in parentheses:


if ( getmxrr($domaintld,$mxrecords) && 
fsockopen($domaintld,25,$errno,$errstr,30) )

   $valid = true;

You could equally use nested conditionals:

if (getmxrr($domaintld,$mxrecords)) {
  if (fsockopen($domaintld,25,$errno,$errstr,30))
 $valid = true;
}

There is no need for the second $valid = false in your code below, since 
you define that at the start.


Edward



The following works, but needs the conditional mentioned...

   $regexp = 
"^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"; 



   // Presume that the email is invalid
   $valid = false;

   // Validate the syntax
   if (eregi($regexp, $email))
   {
  list($username,$domaintld) = split("@",$email);
  // Validate the domain
  if (getmxrr($domaintld,$mxrecords))
 $valid = true;
 }
// attempts a socket connection to mail server
  if(fsockopen($domaintld,25,$errno,$errstr,30)) {
$valid = true;
   } else {
  $valid = false;
  }
 return $valid;
}

if (validate_email($email))
   echo "Email is valid!";
else
   echo "Email is invalid!";

?>

--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] Parent Object

2007-08-01 Thread Edward Kay


> -Original Message-
> From: Ralph Kutschera [mailto:[EMAIL PROTECTED]
> Sent: 01 August 2007 13:19
> To: php-general@lists.php.net
> Subject: [PHP] Parent Object
>
>
> Hallo!
>
> class A {
>   ...
> }
>
> class B extends A {
>   ...
>   $name = get_parent_class($this); // would be "A"
>   ...
> }
>
> This is *not* what I want!
>
> class B {
>   ...
>   $name = get_parent_class2($this); // should give "A"
>   ...
> }
>
> class A {
>   ...
>   $b = new B();
>   ...
> }
>
> This *is* what I want!
>
> How can i resolve this issue? I don't want to know which class is being
> inherited, but I'd like to know which class has created the
> current object.
>
> TIA, Ralph

The concept of a parent class only exists with inheritance. In terms of
finding where an instance is created from this is non-sensical. Who's to say
the instance is even created by another class? It could be in a function.

If you want to be able to access an object that created another object, pass
it in via the constructor, e.g.

class A {
   ...
   $b = new B($this);
   ...
}

class B {
   private $a;

   public function __construct($a) {
  $this->a = $a;
   }
}

Edward

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



RE: [PHP] if inside an echo.

2007-07-31 Thread Edward Kay


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of
> Alan Milnes
> Sent: 31 July 2007 12:41
> To: php-general@lists.php.net
> Subject: Re: [PHP] if inside an echo.
>
>
> On 31/07/07, Hulf <[EMAIL PROTECTED]> wrote:
> > I am outputting a selectbox and want to do the follwoing. How
> can I add the
> > IF statement inside the the echo?
>
> Something like this:-
>
> for ($value = 0; $value <= 2000; $value += 100) {
>
>  echo "  if ($min_rent==$value) {
>  echo "selected=\"selected\"";
>   }
>  echo "> $value";
>
> Alan
>

Snap :) One small point though; you're missing a required space before
selected. It should be:

echo " selected=

otherwise you won't output valid HTML.

E

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



RE: [PHP] if inside an echo.

2007-07-31 Thread Edward Kay


> -Original Message-
> From: Hulf [mailto:[EMAIL PROTECTED]
> Sent: 31 July 2007 12:11
> To: php-general@lists.php.net
> Subject: [PHP] if inside an echo.
> 
> 
> I am outputting a selectbox and want to do the follwoing. How can 
> I add the 
> IF statement inside the the echo?
> 
> 
> for ($value = 0; $value <= 2000; $value += 100) {
> 
>  echo " selected="selected" }> $value";
> 
>   }
> 

Just split it into multiple echo statments:

for ($value = 0; $value <= 2000; $value += 100) {

   echo " $value";

}

Edward

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



RE: [PHP] No is_date() function?

2007-07-25 Thread Edward Kay

> Thanks Lars
>
> I saw that one already but unfortunately, it doesn't help as it
> requires 3 inputs . What I'm shooting for is an 'is_date' function
> that returns true or false with no prior knowledge of what a variable
> might contain.
>
> Ken
>
> On Jul 25, 2007, at 10:08 AM, Lars Haßler wrote:
>
> > Hi,
> >
> > there is a function to check a valid date: http://de3.php.net/
> > manual/de/function.checkdate.php
> >
> > may help
> >> Hi
> >>
> >> I wrote a serialization function to turn arbitrary PHP variables
> >> into Macintosh plist compatible XML but see that there is no
> >> "is_date" tester as there is for bool, object, array etc. Is there
> >> a relatively simple (and robust) way to detect if a variable is a
> >> date? For example:
> >>
> >> $person = array('name'=>'bob', 'sex'=>'male', 'date_of_birth'=>
> >> $someDateHere);
> >>
> >> Thanks for any help
> >>
> >> Ken
> >>

You won't find one. This is because PHP does not have a native type for
dates..

If you have a string e.g. 23-Mar-1985, you can use regexp to match or
extract the various parts. You could then use the checkdate function to
ensure it is a valid date (e.g. not 31st Feb or similar).

Edward

PS: Please don't top post on mailing lists.

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



RE: [PHP] multiple random items

2007-07-16 Thread Edward Kay
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: 16 July 2007 15:40
> To: php-general@lists.php.net
> Subject: [PHP] multiple random items
> 
> 
> Hi I have this script which pulls 1 random item from a txt file.
> How would I modify it to pull 10 random items.
> 
>  $delim = "\n"; 
> $quotefile = "names.txt"; 
> $fp = fopen($quotefile, "r"); 
> $contents = fread($fp, filesize($quotefile)); 
> $quote_arr = explode($delim,$contents); 
> fclose($fp); 

$random_keys = array_rand($quote_arr, min(count($quote_arr), 10));

foreach ($random_keys as $quote_index) {
   // get quote at $quote_index and return it 
   $herequote = $quote_arr[$quote_index]; 
   echo "$herequote";
}

?>

This won't produce any duplicates and will cope with any number of items.

Edward
 

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



RE: [PHP] RE: Address book - LDAP or MySQL?

2007-06-29 Thread Edward Kay
> On 6/29/07, Jay Blanchard <[EMAIL PROTECTED]> wrote:
> >
> > [snip]
> > As I understand it, LDAP and MySQL offer two different ways
> > of setting up a networked address book.
> > So I take it they can be compared as far as that is concerned.
> >
> > Actually, I normally run Linux, so Active Directory
> > would not be a priority for me.
> >
> > I didn't say LDAP was a database.
> > However, the principal usage of LDAP, as far as I can see
> > (by googling for LDAP) is in fact
> > to set up a network address book of some kind.
> > It may be used for other purposes,
> > but they are not really relevant to my enquiry.
> > [/snip]

PHP/MySQL/LDAP integration is something I've been thinking about for a
little while too.

I've built a CRM system in PHP with a MySQL database and would like the
contact info to be available to our users in their email programs. LDAP
seems a good (the only?) option for this due to support in Outlook etc.

>From my understanding, LDAP is just a defined protocol for accessing
directory data. The data must be stored somewhere else, in my case the MySQL
database.

In order to access the data using a LDAP, you need to set-up an LDAP server
(e.g. OpenLDAP). What I haven't looked into much yet is how to interface the
LDAP server to the MySQL database...

I know this isn't too helpful to the OP's question - just wanted to register
my interest in the topic and (hopefully) stimulate conversation.

Edward

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



RE: [PHP] Database administration framework

2007-06-26 Thread Edward Kay
> Hi,
>
> I just need a framework for administrating tables in a database. These are
> simple add/edit/remove operations from tables.
>
> Can you suggest a framework for this kind of job? Cause there are a lot of
> tables and I hope I can find a nice tool to work with.
>

Look at Qcodo (http://www.qcodo.com).

Edward

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



RE: [PHP] open a file in a folder without knowing the filename

2007-06-21 Thread Edward Kay
> -Original Message-
> From: Graham Shaw [mailto:[EMAIL PROTECTED]
>
> I'm probably missing something really obvious here but how would
> I go about
> opening a file or multiple files in a folder without knowing the filename
> ahead of time?

Read the files in the directory and place the names of the ones you want
into an array using the directory functions:
http://uk.php.net/manual/en/ref.dir.php

Edward

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



RE: [PHP] Edinburgh, Scotland: PHP Developer Position

2007-06-18 Thread Edward Kay
> -Original Message-
> From: Tijnema [mailto:[EMAIL PROTECTED]
> Sent: 18 June 2007 14:25
> To: Colin Guthrie
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Edinburgh, Scotland: PHP Developer Position
>
>
> On 6/18/07, Colin Guthrie <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > Don't want to spam the list, but figured after the London Salaries topic
> > recently, that I'd post this!
> >
> > We're needing a PHP/MySQL developer, preferably with experience of
> > general server admin too.
> >
> > The details can be found here if anyone is interested:
> >
> http://www.tribalogic.net/tribalogic/jobs/graduate-php-developer-n
eeded.html
>
> Col
>
>
> Well, I have a lot experience with PHP, HTML and MySQL. Also some
> experience with Unix system administration.  I'm 15 years old, so
> could I apply for the job? :)
>
> Tijnema

But the advert is for a GRADUATE developer ;) Whilst your messages to this
list show you know a lot about PHP, I doubt you've managed to fit a degree
in yet :)

Edward

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



RE: [PHP] generating an html intro text ...

2007-06-18 Thread Edward Kay


> -Original Message-
> From: Jochem Maas [mailto:[EMAIL PROTECTED]
> Sent: 18 June 2007 13:18
> To: tedd
> Cc: [php] PHP General List
> Subject: Re: [PHP] generating an html intro text ...
>
>
> tedd wrote:
> > At 11:39 AM +0200 6/14/07, Jochem Maas wrote:
> >> original string:
> >>
>
> ...
> >
> > The problem as I see it is covering all the possibilities that may occur
> > even if the text is well formed. Like what if someone introduces a span
> > that sets a color for a paragraph, such as:
> >
> > Dolore magna aliquam erat volutpat ut wisi enim
> > ad minim veniam quis nostrud. Consectetuer adipiscing elit sed diam
> > nonummy nibh euismod tincidunt ut laoreet exerci tation ullamcorper
> > suscipit lobortis! Decima eodem modo typi qui nunc nobis videntur
> > parum clari fiant sollemnes in.
> >
> > And the  tag as well as the  tag is outside the 256 limit?
> >
> > You would have to search out and pull in all closing tags.
> >
> > So, I guess an algorithm could be:
>
> roughly speaking yes this is what is would do, except:
>
> >
> > First, grab 256 characters -- The string. If The string is shorter, then
> > quit.
>
> the algo should only be counting 'content characters', i.e.
> anything that is
> html markup should not go towards the string length count,
> additionally html entities
> such as '&' should be considered as a single character.
>
> >
> > Second, determine what tags are not closed.
> >
> > Third, create closing tags and add them to the end of The string (in
> > proper order).
> >
> > Fourth, then remove the same number of non-html characters from the end
> > of The string.
>
> what the code should do (mmore or less) is quite clear - writing something
> flexible & robust to actually do it (and do it fast) is quite
> another matter.
>
> I have been looking at Edward Vermillon's code but I suspect that
> what he sent
> me is not quite what I'm looking for for a number of reasons:
>
> 1. it deals primarily with custom bbcode like markup
> 2. I have a couple of doubts about the handling of html entities
> 3. performance
>
> that said I still have to look at it in depth before making any real
> conclusions as to it's viability (and or the possiblity to rework the
> code to fit my needs).
>
> I'm also looking at an alternative where by I go through the
> string and truncate it at the character (or characters that
> represent an html entity) that reresents the Nth 'content character'
> and then feeding the truncated string to the Tidy extension and let it
> figure out the html cleaning part ... does anyone have experience
> using tidy
> to clean (make valid) html snippets using Tidy, that they would
> like to share?
>

A few thoughts I've had on this problem:

Assuming it is well formed HTML, you could use a stack. Parse the string
putting all opening tags on the stack and then removing them when the close
tag is found. This will leave you with all the un-closed tags and in the
correct order.

Remember that some tags can be self closing ( etc).

Could you use one of the XML extensions to build a DOM of the snippet? I've
not used them much myself, but I'm guessing they could handle most of the
tag stripping and matching...

HTH,
Edward

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



RE: [PHP] Checking Phone Numbers

2007-06-14 Thread Edward Kay
> -Original Message-
> From: Kevin Murphy [mailto:[EMAIL PROTECTED]
> Sent: 14 June 2007 16:38
> To: php
> Subject: [PHP] Checking Phone Numbers
>
>
> I collect phone numbers via a web form that breaks the phone number
> up into 3 parts (3-digit area, 3-digit prefix, etc). Occasionally, I
> am having people put in a phone number such as 999-999- or
> 000-000- or other numbers that are all the same. How would I go
> about comparing those three fields to see if they are all the same
> numbers. I can't just exclude it anytime that the numbers all match,
> for example 444 is a valid area code. It should only fail if all the
> numbers are exactly the same.
>
> All the processes I've come up with seem to be rather convoluted. Is
> there a simple way to test for this?
>
> --
> Kevin Murphy
> Webmaster: Information and Marketing Services
> Western Nevada College
> www.wnc.edu
> 775-445-3326

Whilst there are several ways to do this, it's not going to make someone
entering dummy data give you their real phone number. They'll just enter
another one that bypasses your check, e.g. 111-222- or 321-321-4321.

I'd also caution about forcing any specific format on telephone numbers. I'm
in the UK and our phone numbers are in the format -xxx-,
xxx-- or x-xx. This would not work with your form. If people
are happy to give you their number, let them type it how it is. It could
even include other characters, e.g. +44 (0)1234 567890 ex 324

Edward

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



RE: [PHP] Question on Connecting to Microsoft SQL Server from PHP

2007-06-12 Thread Edward Kay

> All:
>
> I can't seem to connect to a SQL Server database with PHP. I have read the
> php.net documentation and so many other forums on the Internet that my
> eyes were literally blood shot. Today I thought I would try this route.
>
> I have PHP and Apache installed on my local machine. They work fine as I
> created another application with them (and MySQL) that worked as
> expected/designed. I want to connect to MS SQL Server 2000 that rests on
> another machine here at work. I can reach the tables and do whatever I
> want with them from my machine through SQL Query Analyzer. (The other
> machine runs a Windows Server. So I am trying to connect from one Windows
> box to another Windows box.) So I know that I can connect to the tables
> (and the machine that they rest on) from my machine. It is just that I get
> the following error when I load my PHP page: "Warning: mssql_connect() [[
> http://localhost/development_files/ordertrackno/where_is_it.php/fu
> nction.mssql-connect
> ]function.mssql-connect]: Unable to connect to server: . . . "
>
> In my PHP page I have the following:
> $sql = mssql_connect ("xx.xx.xx.xx:", "xx", "xx");
> $conn=mssql_select_db("xx", $sql);
> etc
>
> I have tried replacing the semicolon with a comma as some have said. I get
> the same error. I have tried replacing the quotation marks with an
> apostrophe and I get the same error.
>
> I have the Client tools installed on my machine. (I should mention that
> they are not installed on the Apache on my machine as I could not get them
> to install from the SQL Server disk to that location--only to the
> hardrive.). Again, they connect to the database. I can query the database
> from my machine. I have the latest ntwdblib.dllinstalled in the php,
> php\extension, apache\bin, and system 32 directories.
>
> What else . . .
>
> I have tried setting the msssql.secure_connection to both off and on and I
> still get the same error.
>
> I have ensured that TCP/IP and Named Pipes are enabled in the SQL
> Configuration tool.
>
> I have asked the network guy to help out but no luck there.
>
> Again, I am at a loss and need to get this up and running. Any suggestions
> would be appreciated.
> > Thanks.
>
> Tommy
>

Do you have any firewall software running on your local PC? (e.g. ZoneAlarm)
This could be blocking the connection from Apache but allowing it for your
other SQL client tools...

Edward

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



RE: [PHP] Anyone scripted Crossover?

2007-06-06 Thread Edward Kay


> -Original Message-
> From: George Pitcher [mailto:[EMAIL PROTECTED]
> Sent: 06 June 2007 14:34
> To: php-general@lists.php.net
> Subject: RE: [PHP] Anyone scripted Crossover?
>
>
> Tijnema,
>
> > > Nothing found in the archive, so asking the question: has
> > anyone done any
> > > scripting of Crossover to control MS Office applications on Linux?
> > >
> > > I would love to move to Linux, but have some apps that create
> > MS Word docs
> > > and some doing Excel parsing.
> > >
> > > Cheers
> > >
> > > George in Edinburgh/Oxford
> >
> > Can't you use some OpenOffice.org tools for that? OOo can open all
> > kind of MS Word and Excel documents.
>
> So, can I create a '*.doc' file on a Linux box? And can I read
> the data from
> an Excel spreadsheet to parse into a MySQL db?
>
> If so, can anyone point me in the right direction for examples etc?
>
> Cheers
>
> George in Edinburgh/Oxford
> ==

If you want to parse .doc and .xls files with a script under Linux, look at
catdoc and xls2csv:
http://www.45.free.net/~vitus/software/catdoc/

Edward

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



RE: [PHP] checking the aspect ratio of an images

2007-06-06 Thread Edward Kay


> -Original Message-
> From: blueboy [mailto:[EMAIL PROTECTED]
> Sent: 06 June 2007 11:41
> To: php-general@lists.php.net
> Subject: [PHP] checking the aspect ratio of an images
>
>
> I want to force users to insert landscape rather portrait images. I don't
> want to be too pedantic about it but they do need to have an
> approximate 4x3
> aspect ratio.
>
> This is my code so far.
>
> $max_height = "500"; // This is in pixels
> $max_width = "500"; // This is in pixels
>
> list($width, $height, $type, $w) =
> getimagesize($_FILES['userfile']['tmp_name']);
>
> if($width > $max_width || $height > $max_height)
> {
>
> }
>

This is basic maths. 4:3 means and aspect ratio of 1:0.75 or the height is
0.75 times the width.

Therefore, just check that:

if ($height/$width != 0.75) // Image not 4:3 landscape

You seem to imply this is an approx restriction, so just increase your
acceptable range of values, e.g.

$ratio = $height/$width;
if ($ratio < 0.7 || $ratio > 0.8) // Ratio not acceptable.

Edward

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



RE: [PHP] Best way to convert Little-Endian DWORD to string

2007-05-30 Thread Edward Kay


> -Original Message-
> From: Tijnema [mailto:[EMAIL PROTECTED]
> Sent: 30 May 2007 15:20
> To: php
> Subject: [PHP] Best way to convert Little-Endian DWORD to string
> 
> 
> Hi,
> 
> Maybe quite strange question and quite off topic, but there's PHP 
> involved :)
> 
> I want to read out files, and then I come across 4byte DWORD values,
> they are stored in little endian values, but how do I get in a PHP
> string (as the values are too large for integer)
> 
> My code is currently this:
> $data = fread($fp,4);
> $value = 
> (ord(substr($data,3,1))*256*256*256)+(ord(substr($data,2,1))*256*2
> 56)+(ord(substr($data,1,1))*256)+(ord(substr($data,0,1)));
> 
> and now $value contains the value of the DWORD, it works fine, but it
> seems that it could be done a lot easier :)
> Anyone experience with it?

Could you not use the << bitwise operator?

Edward

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



RE: [PHP] Return or not to return, that is the question

2007-05-30 Thread Edward Kay


> Just a quick straw-poll really:
> 
> What is your take on using 'return' when you end a function, if you
> don't actually need to return a value?
> 
> If you have to return say a true/false as the result of an operation,
> then it's an obvious choice. But what if all the function does is
> perform an action and then quit? Do you like to use 'return' at the
> end of it anyway, or do you just let it run into the closing } ?
> 
> Or do you perhaps do a 'return true' at the end, regardless, even if
> the rest of your code never checks that value (on the basis that it
> may do in the future)
> 

I like to have all my functions return something so use return true.

Edward

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



RE: [PHP] Include file questions

2007-05-25 Thread Edward Kay

> -Original Message-
> From: Tijnema [mailto:[EMAIL PROTECTED]
> > >
> > > It's just the way you write script, my included files contain only
> > > functions & variables, no executing code. 99% I have a class around
> > > it.
> > > If you write it like that, than there's no problem with execution the
> > > included file directly, as it loads the class but doesn't do anything
> > > with it :)
> > >
> > > Tijnema
> > >
> >
> > Why are your include files in your web root in the first place?
> Move them
> > elsewhere on your filesystem and then it's not even possible to
> access them
> > via the web.
> >
> > Edward
> >
> Oh, I don't want my web files all over the filesystem, I want to keep
> all files for a single project inside a single folder on my webserver.
> So, that if i move them around, I have all files there.
>
> Tijnema

This is exactly what I do - one folder per project. You just have you
web-root as a sub folder in this, eg:

/project
  /includes <- nicely protected
  /public_html <- web root
 /images
  index.php
 ...
  ...

Edward

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



RE: [PHP] Include file questions

2007-05-25 Thread Edward Kay


> -Original Message-
> From: Tijnema [mailto:[EMAIL PROTECTED]
> Sent: 25 May 2007 15:00
> To: tedd
> Cc: Kevin Murphy; Stephen; php
> Subject: Re: [PHP] Include file questions
>
>
> On 5/25/07, tedd <[EMAIL PROTECTED]> wrote:
> > At 1:55 PM -0700 5/23/07, Kevin Murphy wrote:
> > >.inc files have a disadvantage in that if you view the file:
> > >
> > >http://www.yoursite.com/file.inc
> > >
> > >you can see the php code. I prefer not to use those just on the off
> > >chance that someone can see my code and use that as the basis for
> > >figuring out a way to exploit it (especially true of password files,
> > >etc).
> > >
> > >--
> > >Kevin Murphy
> >
> > And the other side of that coin is if you have your files ending with
> > .php, then they can be called/run directly and do things you may not
> > want done.
> >
> > That's a good reason to use some sort of token protection in your
> > include php files so that they cannot be run directly.
> >
> > Cheers,
> >
> > tedd
>
> It's just the way you write script, my included files contain only
> functions & variables, no executing code. 99% I have a class around
> it.
> If you write it like that, than there's no problem with execution the
> included file directly, as it loads the class but doesn't do anything
> with it :)
>
> Tijnema
>

Why are your include files in your web root in the first place? Move them
elsewhere on your filesystem and then it's not even possible to access them
via the web.

Edward

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



RE: [PHP] two php scripts with same $_SESSION variables

2007-05-24 Thread Edward Kay
> Stut..
> I've only been here one day, and I think I'm right in saying that your
> the one around here that gets annoyed really easy ;)

I don't think Stut gets annoyed more than any of the others on this list.
Please remember though that

a) Stut's answers tend to be very high quality and
b) Top posting is damn annoying. (Maybe this should be point (a)...)

Edward

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



RE: [PHP] [CSS] help with a orizzotal menu

2007-05-24 Thread Edward Kay


> -Original Message-
> From: Marco Sottana [mailto:[EMAIL PROTECTED]
> Sent: 24 May 2007 11:32
> To: php-general@lists.php.net
> Subject: [PHP] [CSS] help with a orizzotal menu
>
>
> hi i have this
>
> Menu item
> 1Menu item
> 1.1Menu item
> 1.2Menu item
> 1.2.1Menu item 1.2.2 href="/item1.2.2.1.php">Menu item 1.2.2.1 href="/item1.2.2.2.php">Menu item
> 1.2.2.2Menu item
> 1.2.3Menu item
> 1.3Menu item
> 2Menu item 3 href="/item4.php">Menu item 4
>
> i would like to add a css and/or a javascript to skin this menu
> as a orizzontal menu with submenu orizzontal under menu.. and
> subsubmenu orizzontal and under submenu..
>
> thanks a lot
>

This is a PHP list. Your question has nothing to do with PHP. STFW.

Edward

PS: I think you mean 'horizontal' not 'orizzontal'. This is not a criticism,
but it may help you use better search terms.

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



RE: [PHP] Project Management

2007-05-24 Thread Edward Kay


> -Original Message-
> From: Christian Haensel [mailto:[EMAIL PROTECTED]
> Sent: 24 May 2007 10:27
> To: php-general@lists.php.net
> Subject: [PHP] Project Management
>
>
> Morning guys,
>
> this is not exactly a PHP question, but as I am sure that I am talking to
> more or less professional developers, I thought I might ask you.
>
> As I am working on some... well, for my standards... huge
> project, I thought
> that some kind of project management software would / could be helpful to
> keep track of my ideas, tasks and so on. Right now I am using a
> huge chunk
> of papers to keep track (as good as I can).
>
> Has any of you any experience with good project management software? Best
> would be OpenSource, of course :o) My boss doesn't want to spend a lot of
> money ;o)
>
> Cheers guys,
>
> Chris from sunny germany


If you're working on your own, I would think realistically about how much
you would use such software. I've used Basecamp, Trac, MS Project and others
in the past and find them a waste of time. My favourite tool is simply an A4
lab book. (I know this doesn't scale, but it fits the bill perfectly for
now).

For initial brainstorming/idea tracking, I do use FreeMind though.
http://freemind.sf.net

HTH, Edward

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



RE: [PHP] How to eject cd-rom with php code?

2007-05-23 Thread Edward Kay


> -Original Message-
> From: Chetan Graham [mailto:[EMAIL PROTECTED]
> Sent: 23 May 2007 12:23
> To: php-general@lists.php.net
> Subject: [PHP] How to eject cd-rom with php code?
> 
> 
> Hi all,
> I am writing a script and need to eject the cd-rom drive at some point.
> Does anyone have an idea how to do this?
> This is a simple command isn't it?
> I greatly appreciate your help
> Blessings,
> Chetanji
> 

Pass the appropriate system (i.e. command prompt) command to exec():

http://uk.php.net/exec

Edward

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



RE: [PHP] IE7 => end tag?

2007-05-18 Thread Edward Kay

> > The extra comma at the end of the array definition is still
> > valid syntax in
> > PHP. Try for yourself:
> >
> >  php -r '$a = array("a" => "foo", "b" => "bar",); print_r($a);'
>
> Interesting.  Do you mean 'Valid Syntax' in that it 'works without error',
> or 'Valid Syntax' in that 'it was designed to work that way'?  If the
> former, then I would argue as to whether it is valid syntax,
> since depending
> on it would be dangerous.  If the latter, then I have learned
> something new,
> and I'd like to know more about why it is designed to work that
> way, and how
> I could use it to my advantage.


I believe it is the latter, i.e. designed to work that way. I read something
about it a few months ago but annoyingly can't find the reference. The
reasoning was to make it easier for developers to manage files that define
large arrays, such as config files. (You can add extra values to the end,
copy/paste lines etc without having to worry too much about the trailing
commas).

It may only be acceptable in newer versions of PHP though.

> >
> > NULL is a special type that means just that:
> > http://uk.php.net/manual/en/language.types.null.php
> >
> > Enclosing it in quotes will define it as a string, something entirely
> > different.
>
> I am aware of what a NULL is.  I suggested the quotes as a troubleshooting
> step, since code prior to the NULL was not being displayed.  A 'knee jerk'
> suggestion, I concede. (Feel free to substitite your own
> descriptive phrase
> for 'knee jerk' if you must) :-)

No need - I'm just as guilty as anyone for 'knee-jerk' posting :)

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



RE: [PHP] stay logged in for session

2007-05-18 Thread Edward Kay

> > HTTP Location headers require the full hostname, i.e.
> > 
> > header("Location: http://www.example.com/page_to/redirect/to.php";);
> 
> that is true, but usually it works with relative url-s also
> 
> greets
> Zoltán Németh
> 

Just because some user agents handle non-standard data doesn't make it correct. 
The HTTP spec says it has to be an absolute URI [1] so until that changes, I'll 
keep using and recommending absolute URIs.

E

[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30

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



RE: [PHP] stay logged in for session

2007-05-18 Thread Edward Kay


> -Original Message-
> From: Joshua [mailto:[EMAIL PROTECTED]
> Sent: 18 May 2007 12:09
> To: Edward Kay
> Subject: RE: [PHP] stay logged in for session
>
>
> On Fri, 2007-05-18 at 11:53 +0100, Edward Kay wrote:
> >
> > > -Original Message-
> > > From: Joshua [mailto:[EMAIL PROTECTED]
> > > Sent: 18 May 2007 11:43
> > > To: PHP.net
> > > Subject: [PHP] stay logged in for session
> > >
> > >
> > > hey guys, i am trying to set up a session so that when a user logs in,
> > > they will stay logged in until they close their browser.  i have the
> > > session set up, however i keep getting an error saying:
> > >
> > > The page isn't redirecting properly
> > >
> > > Firefox has detected that the server is redirecting the
> request for this
> > > address in a way that will never complete.
> > >
> > > --
> > > this is my code, any help plz.
> > > --
> > > checklogin.php:
> > >
> > >  > > session_start();
> > > //set session variables
> > > $_SESSION['txtSurname'] = $_REQUEST['txtSurname'];
> > > $_SESSION['txtPassword'] = $_REQUEST['txtPassword'];
> > > session_write_close();
> > >
> > > include('includes/dbconnect.php');
> > >
> > > $nextpage = $_REQUEST['np'];
> > > $profile = $_REQUEST['ob'];
> > >
> > > //Matching usernames and passwords
> > > $uname = $_REQUEST['txtSurname'];
> > > $pword = $_REQUEST['txtPassword'];
> > > $user = "SELECT * FROM oldboys WHERE OBSURNAME='" . $uname . "' AND
> > > PWORD='" . $pword . "'";
> > > $ResSql = mysql_query($user) ;
> > > //If any errors then print `em out
> > > if (!$ResSql)  {
> > >   echo("Error performing query: " . mysql_error() . "");
> > >   exit();
> > >   }
> > > //if user does not exist
> > > if (mysql_num_rows($ResSql)==0)  {
> > >   echo 'Incorrect username or password have been specified.';
> > >   echo 'Click here to Log In';
> > >   exit;
> > >   }
> > > else  {
> > >   header("Location:" . $nextpage . "?ob=" . $_REQUEST['ob'] .
> > > "&uname=" . $_REQUEST['txtSurname'] . "&pword=" .
> > > $_REQUEST['txtPassword']);
> > > }
> > > ?>
> > >
> > > verify.php:
> > >
> > >  > > session_start();
> > > if(!isset($_SESSION['txtSurname']) &&
> !isset($_SESSION['txtPassword']))
> > > {
> > >   header("location:updlogin.php?np=" . $_REQUEST['np'] . "&ob=" .
> > > $_REQUEST['ob']);
> > > }
> > > else  {
> > >   header("location:" . $nextpage . "?np=" . $_REQUEST['np'] . "&ob=" .
> > > $_REQUEST['ob']);
> > > }
> > > ?>
> > >
> ---
> >
> > HTTP Location headers require the full hostname, i.e.
> >
> > header("Location: http://www.example.com/page_to/redirect/to.php";);
> >
> > As others on this list will say however, you don't have to use a full
> > redirect. Just use different PHP includes.
> >
> > E
> >
> thx so much, it works now.
>

Excellent. Please include the list on replies so that it all gets archived
and others can see your responses.

By the way, I suggest you have a read up on PHP security, especially SQL
injection attacks. Looking at the code above, what would happen if the
username I supplied was the following:

   foo'; DELETE FROM oldboys; #

E

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



RE: [PHP] stay logged in for session

2007-05-18 Thread Edward Kay


> -Original Message-
> From: Joshua [mailto:[EMAIL PROTECTED]
> Sent: 18 May 2007 11:43
> To: PHP.net
> Subject: [PHP] stay logged in for session
>
>
> hey guys, i am trying to set up a session so that when a user logs in,
> they will stay logged in until they close their browser.  i have the
> session set up, however i keep getting an error saying:
>
> The page isn't redirecting properly
>
> Firefox has detected that the server is redirecting the request for this
> address in a way that will never complete.
>
> --
> this is my code, any help plz.
> --
> checklogin.php:
>
>  session_start();
> //set session variables
> $_SESSION['txtSurname'] = $_REQUEST['txtSurname'];
> $_SESSION['txtPassword'] = $_REQUEST['txtPassword'];
> session_write_close();
>
> include('includes/dbconnect.php');
>
> $nextpage = $_REQUEST['np'];
> $profile = $_REQUEST['ob'];
>
> //Matching usernames and passwords
> $uname = $_REQUEST['txtSurname'];
> $pword = $_REQUEST['txtPassword'];
> $user = "SELECT * FROM oldboys WHERE OBSURNAME='" . $uname . "' AND
> PWORD='" . $pword . "'";
> $ResSql = mysql_query($user) ;
> //If any errors then print `em out
> if (!$ResSql)  {
>   echo("Error performing query: " . mysql_error() . "");
>   exit();
>   }
> //if user does not exist
> if (mysql_num_rows($ResSql)==0)  {
>   echo 'Incorrect username or password have been specified.';
>   echo 'Click here to Log In';
>   exit;
>   }
> else  {
>   header("Location:" . $nextpage . "?ob=" . $_REQUEST['ob'] .
> "&uname=" . $_REQUEST['txtSurname'] . "&pword=" .
> $_REQUEST['txtPassword']);
> }
> ?>
>
> verify.php:
>
>  session_start();
> if(!isset($_SESSION['txtSurname']) && !isset($_SESSION['txtPassword']))
> {
>   header("location:updlogin.php?np=" . $_REQUEST['np'] . "&ob=" .
> $_REQUEST['ob']);
> }
> else  {
>   header("location:" . $nextpage . "?np=" . $_REQUEST['np'] . "&ob=" .
> $_REQUEST['ob']);
> }
> ?>
> ---

HTTP Location headers require the full hostname, i.e.

header("Location: http://www.example.com/page_to/redirect/to.php";);

As others on this list will say however, you don't have to use a full
redirect. Just use different PHP includes.

E

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



RE: [PHP] Setting Up A Simple Shopping Cart

2007-05-18 Thread Edward Kay


> -Original Message-
> From: revDAVE [mailto:[EMAIL PROTECTED]
> Sent: 18 May 2007 01:33
> To: php php
> Subject: Re: [PHP] Setting Up A Simple Shopping Cart
>
>
> On 5/17/2007 7:05 AM, "revDAVE" <[EMAIL PROTECTED]> wrote:
>
> > Hello folks,
> >
> > I am a PHP NEWBIE.
> >
> > - I have the following three choices for shopping carts on my server:
> >
> > CubeCart
> > OS Commerce
> > Zen Cart
> >
> > Q: Does anybody have any preferences for creating a simple store?
>
> Both OS Commerce & Zen Cart look pretty cool so far   Does anyone have
> any preferences?
>

Again, try some at http://opensourcecms.com/. DYOR people.

Edward

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



RE: [PHP] IE7 => end tag?

2007-05-18 Thread Edward Kay


> -Original Message-
> From: Jim Moseby [mailto:[EMAIL PROTECTED]
> Sent: 17 May 2007 21:29
> To: 'rauhspund'; php-general@lists.php.net
> Subject: RE: [PHP] IE7 => end tag?
>
>
> >
> > #-- .meta info
> > include("../plugins/lib/pluginmetadata.php");
> > $_cached = !empty($_POST);
> > ewiki_pmd($_cached);
> > #-- defaults for the separately handled database settings in $db[]
> > if (!($db = $_REQUEST["db"])) {
> > $db = array("type" => NULL,
> > "server" => "localhost",
> > "dbname" => "test",
> > "table" => "ewiki",
> > "dir" => "/tmp",
> > "dba" => "/tmp/wiki.dbm",
> > );
> > }
>
> I don't know if this will fix your problem, but you have an
> extraneous comma
> after'"dba" => "/tmp/wiki.dbm",'.  Also try enclosing NULL in
> quotes and see
> if your problem goes away.
>
> JM
>

The extra comma at the end of the array definition is still valid syntax in
PHP. Try for yourself:

 php -r '$a = array("a" => "foo", "b" => "bar",); print_r($a);'

NULL is a special type that means just that:
http://uk.php.net/manual/en/language.types.null.php

Enclosing it in quotes will define it as a string, something entirely
different.

The problem described is not to do with the PHP code supplied, but the setup
of the webserver. As Stut correctly said, if PHP code is getting to the
browser then webserver is not configured correctly.

rauhspund, you are actually using a webserver with PHP aren't you and not
just opening the PHP file directly with IE?

Edward

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



RE: [PHP] Tipos about which CMS use

2007-05-18 Thread Edward Kay
> Hi there,
> 
> I'd like to replace my 'intranet' site with a CMS system to speed up
> the edit process.  Some of my requirements are :
> 
> - written in PHP  :)
> - mysql based
> - documented/'well structured' - to allow development of customizations
> - ability to define which pages or sections are public and which are
> private (and in this case which users can access)
> - use AJAX (not mandatory) but since some access to the page will come
> from dial-up to reduce the need to transfer entire html just to update
> a search or list contents..
> 
> thanks
> 

http://opensourcecms.com/

Edward

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



RE: [PHP] PHP 5.2 array() == null

2007-05-15 Thread Edward Kay

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: 15 May 2007 16:48
> To: php-general@lists.php.net
> Subject: [PHP] PHP 5.2 array() == null
>
>
> Hi people
>
> i was just curios to ask whether
>
> array() == null should always return true. and then why
>
> i'm testing this with php 5.2.2
>
> greetings
>
> dominic letz
>

According to Table Q.2 at
http://www.php.net/manual/en/types.comparisons.php, array() == NULL will
always return TRUE.

Remember == is a loose comparison. I think this is a result of the
following:

  array() == FALSE  is TRUE (because it's empty?)
FALSE == NULL   is TRUE
thus  array() == NULL   is TRUE

Edward

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



Re: [PHP] Need a new shared host with php

2007-05-10 Thread Edward Kay

Al wrote:
I'm looking for a shared host with an up-to-date php5, and one who at 
least tries to keep it relatively current.


Needs are modest.  Just need good ftp access, cgi-bin, shell, etc.

Any suggestions. I'm looking at Host Monster, anyone have experience 
with them?


Thanks...

Check out http://www.webhostingtalk.com for both discussions and 
searching on any possible hosts before signing up.


If you can stretch your budget a bit more, go for a VPS. Shared hosting 
is a real pain when other users write poor code that hog the server. I 
use ServInt and would recommend them.


Edward

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



RE: [PHP] Ajax Developer

2007-05-09 Thread Edward Kay


> -Original Message-
> From: Robert Cummings [mailto:[EMAIL PROTECTED]
> On Wed, 2007-05-09 at 10:23 -0500, Edward Vermillion wrote:
> > On May 9, 2007, at 10:12 AM, Stut wrote:
> >
> > > Efrain Sarmiento wrote:
> > >> AJAX Developer  (Web Designer / Developer).  MUST HAVE:  1 year AJAX
> > >> Experience, HTML, CSS, DHTML, OOJS, XML, JAVASCRIRPT, J2EE, and at
> > >> lease
> > >> an IDE like Photoshop, Dreamweaver, Eclipse or similar.  Jersey City,
> > >> NJ, 6 months ongoing.  $560/day C2C.
> > >
> > > Hands up everyone who uses the Photoshop IDE...
> > >
> >
> > Ohh! That's in CS3 right?!? Cool! I've gotta get me one of those!
>
> I'm much more partial to the Gimp IDE :)
>

Ah, but can you code JAVASCRIRPT in the Gimp IDE? ;)

I'm not sure why the job requires you to lease the IDE though - Photoshop is
a bit pricey, but it's not that bad!

E

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



RE: [PHP] Ajax?

2007-05-09 Thread Edward Kay


> -Original Message-
> From: Emil Edeholt [mailto:[EMAIL PROTECTED]
> Sent: 09 May 2007 16:05
> To: php-general@lists.php.net
> Subject: [PHP] Ajax?
>
>
> Hi!
>
> What do you guys use to develop ajax applications and do you have any
> good articles on the subject?
>
> I've just about finished an ajaxish site but it wasn't fun. A lot of
> nesting javascript inside php calls, having to write the logic both in
> javascript and php and so on. The source looks ugly and was time
> consuming to debug.
>
> Thanks!
>
> Kind regards Emil
>

Have a look at the various frameworks available since these handle much of
the nasty details:
http://en.wikipedia.org/wiki/List_of_web_application_frameworks#PHP

I've been using Qcodo (http://www.qcodo.com) for a recent web app and am
impressed at how quickly I've been able to develop with it. For
JavaScript/CSS, I've also been using Yahoo User Interface (YUI) components
which I'm also really impressed with: http://developer.yahoo.com/yui/

The thing with frameworks and libraries is that everyone will have their
favourite for one reason or another. You just have to find the one you feel
most comfortable with.

Hope that helps,
Edward

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



RE: [PHP] Isset Errors

2007-05-09 Thread Edward Kay


> -Original Message-
> From: Davide Bernard [mailto:[EMAIL PROTECTED]
> Sent: 09 May 2007 15:18
> To: php-general@lists.php.net
> Subject: [PHP] Isset Errors
> 
> 
> Anyone got any suggestions on getting rid of these errors below?
> 
> 
> [Wed May 09 08:59:05 2007] [error] [client 192.168.225.246] PHP 
> Notice:  Undefined index:  userstate in 
> /srv/www/htdocs/resetpw.php on line 31, referer: 
> https://ams.unt.edu/resetpw.php 
> [Wed May 09 08:59:05 2007] [error] [client 192.168.225.246] PHP 
> Notice:  Undefined index:  userstate in 
> /srv/www/htdocs/resetpw.php on line 36, referer: 
> https://ams.unt.edu/resetpw.php 
> 
>  
> Here's the lines of code I am getting the errors in PHP 5...Where 
> can I insert some code to define 'userstate' ?
> 
> 
> 24. if (identifyUser()) {
> 25.   if ((isset($_SESSION['clientinfo']['ssn'][0]) && 
> strcmp('9', $_SESSION['clientinfo']['ssn'][0]))
> 26.   || isset($_SESSION['clientsinfo'])) {
> 27.   $_SESSION['userstate'] = 'confirmssn';
> 28.  } else {
> 29.   $_SESSION['userstate'] = 'ssnverified';
> 30.  }
> 31. } elseif ($_SESSION['userstate'] == 'confirmssn' && confirmSSN()) {
> 32.  $_SESSION['userstate'] = 'ssnverified';
> 33. }
> 34. initMenu();
> 35. if (isset($_SESSION['userstate'])) return 0;
> 36. if ($_SESSION['userstate'] == 'confirmssn') {
> 37.   themeHeader();
> 

If identifyUser() returns false, $_SESSION['userstate'] is not defined.

Edward

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



RE: [PHP] Selecting a special row from the database

2007-05-04 Thread Edward Kay


> -Original Message-
> From: Fredrik Thunberg [mailto:[EMAIL PROTECTED]
> Sent: 04 May 2007 15:31
> To: Edward Kay
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Selecting a special row from the database
>
> Edward Kay skrev:
> >
> >> -Original Message-
> >> From: Marcelo Wolfgang [mailto:[EMAIL PROTECTED]
> >> Sent: 04 May 2007 14:37
> >> To: php-general@lists.php.net
> >> Subject: [PHP] Selecting a special row from the database
> >>
> >>
> >> Hi all,
> >>
> >> I'm building a news display page for a website, and since the
> user has 2
> >> ways to arrive there, I want to know if this is possible:
> >>
> >> 1) the user arrive at news.php
> >>
> >> I will run a query at the db, and get the latest news to be
> the main one
> >>   (full display) and display the others news in a list
> >>
> >> 2) the user arrived from a link to a specific news to news.php?id=10
> >>
> >> It should display the news with id = 10 as the main news and get the
> >> latest ones to display in a list of other news
> >>
> >> I've so far was able to add a dinamic WHERE to my query ( if I have or
> >> not the id GET parameter ) and if I don't have it, I'm able to display
> >> the latest result as the main news, but when I have an id as a GET
> >> parameter, I have a where clause in my query and it will
> return only the
> >> main news and not build up the news list
> >>
> >> what I want is to separate the news that the user want to see ( the
> >> id=XX one ) from the others rows, can someone advice me ?
> >>
> >> Here is the code I have so far, I hope it serve as a better explanation
> >> than mine!
> >>
> >>  >> $newsId = $_GET['id'];
> >> if (isset($newsID)){
> >>$whereClause = 'WHERE auto_id ='.$newsId;
> >> } else {
> >>$whereClause = '';
> >> }
> >> mysql_connect("localhost",$user,$pass) or die (mysql_error());
> >> mysql_select_db ($db_table);
> >> $SQL = "SELECT * FROM tb_noticias $whereClause ORDER BY auto_id DESC";
> >> $news_Query = mysql_query($SQL);
> >> $recordCount = mysql_numrows($news_Query);
> >> mysql_close();
> >> ?>
> >>
> >> TIA
> >> Marcelo Wolfgang
> >>
> >
> > If id is set, query the DB for this news article and put as the first
> > element in an array. Then perform a second query WHERE ID != id
> and append
> > the results to the array. If id isn't set, just perform the one query
> > without any where clause.
> >
> > If you want to do it all in one query, if id is provided use
> SELECT... WHERE
> > ID = id UNION (SELECT...WHERE ID != id ORDER BY id DESC) to get
> the ordering
> > you want. If id isn't set just use SELECT ... ORDER BY id DESC.
> >
> > I'm not sure if there would be much difference in performance as I still
> > think the database would perform two queries internally.
> >
> > Edward
> >
>
> Maybe
> SELECT ..., if (id = my_id,1,0) as foo
> ...
> ORDER BY foo DESC;
>

Good idea! Just tried it out and it works really well.

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



RE: [PHP] Selecting a special row from the database

2007-05-04 Thread Edward Kay
> -Original Message-
> From: Alister Bulman [mailto:[EMAIL PROTECTED]
> Sent: 04 May 2007 15:07
> To: php-general@lists.php.net
> Subject: Re: [PHP] Selecting a special row from the database
>
>
> On 04/05/07, Marcelo Wolfgang <[EMAIL PROTECTED]> wrote:
>
> > I'm building a news display page for a website, and since the user has 2
> > ways to arrive there, I want to know if this is possible:
> >
> > 1) the user arrive at news.php
> >
> > I will run a query at the db, and get the latest news to be the main one
> >   (full display) and display the others news in a list
> >
> > 2) the user arrived from a link to a specific news to news.php?id=10
> >
> > It should display the news with id = 10 as the main news and get the
> > latest ones to display in a list of other news
>
> > Here is the code I have so far, I hope it serve as a better explanation
> > than mine!
>
> >  > $newsId = $_GET['id'];
> > if (isset($newsID)){
> > $whereClause = 'WHERE auto_id ='.$newsId;
> > } else {
> > $whereClause = '';
> > }
> > mysql_connect("localhost",$user,$pass) or die (mysql_error());
> > mysql_select_db ($db_table);
> > $SQL = "SELECT * FROM tb_noticias $whereClause ORDER BY auto_id DESC";
>
> Yep, thats pretty classic.
> One thing I would do - assuming $newsId should always be an integer
>
> $whereClause = '';
> if (isset($_GET['id']) {
>   $newsId = intval($_GET['id']);
>   if ($newsId)  // if not 0
> $whereClause = 'WHERE auto_id ='.$newsId;
> }
> .
>
>
> Alister
>

This doesn't solve the problem. If ID is set, you'll only get one result.
Several results are always required, just with a different ordering. See my
other reply.

Edward

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



RE: [PHP] Selecting a special row from the database

2007-05-04 Thread Edward Kay


> -Original Message-
> From: Marcelo Wolfgang [mailto:[EMAIL PROTECTED]
> Sent: 04 May 2007 14:37
> To: php-general@lists.php.net
> Subject: [PHP] Selecting a special row from the database
>
>
> Hi all,
>
> I'm building a news display page for a website, and since the user has 2
> ways to arrive there, I want to know if this is possible:
>
> 1) the user arrive at news.php
>
> I will run a query at the db, and get the latest news to be the main one
>   (full display) and display the others news in a list
>
> 2) the user arrived from a link to a specific news to news.php?id=10
>
> It should display the news with id = 10 as the main news and get the
> latest ones to display in a list of other news
>
> I've so far was able to add a dinamic WHERE to my query ( if I have or
> not the id GET parameter ) and if I don't have it, I'm able to display
> the latest result as the main news, but when I have an id as a GET
> parameter, I have a where clause in my query and it will return only the
> main news and not build up the news list
>
> what I want is to separate the news that the user want to see ( the
> id=XX one ) from the others rows, can someone advice me ?
>
> Here is the code I have so far, I hope it serve as a better explanation
> than mine!
>
>  $newsId = $_GET['id'];
> if (isset($newsID)){
>   $whereClause = 'WHERE auto_id ='.$newsId;
> } else {
>   $whereClause = '';
> }
> mysql_connect("localhost",$user,$pass) or die (mysql_error());
> mysql_select_db ($db_table);
> $SQL = "SELECT * FROM tb_noticias $whereClause ORDER BY auto_id DESC";
> $news_Query = mysql_query($SQL);
> $recordCount = mysql_numrows($news_Query);
> mysql_close();
> ?>
>
> TIA
> Marcelo Wolfgang
>

If id is set, query the DB for this news article and put as the first
element in an array. Then perform a second query WHERE ID != id and append
the results to the array. If id isn't set, just perform the one query
without any where clause.

If you want to do it all in one query, if id is provided use SELECT... WHERE
ID = id UNION (SELECT...WHERE ID != id ORDER BY id DESC) to get the ordering
you want. If id isn't set just use SELECT ... ORDER BY id DESC.

I'm not sure if there would be much difference in performance as I still
think the database would perform two queries internally.

Edward

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



RE: [PHP] passing GET via include

2007-05-04 Thread Edward Kay
> -Original Message-
> From: Mark Smith [mailto:[EMAIL PROTECTED]
> Sent: 04 May 2007 08:23

> Hello all,
> Is there a way to allow the passing of variables to included scripts
> using the GET method, for example include"file.php?name=person"; or is
> there another method of including files that allow you to do this. I
> have attempted to do this without success, I just get a message saying
> the file cannot be found.
>

Hi Mark,

No, this isn't possible as it makes no sense. When you include a file, you
are not performing a request that generates a response - you are simply
including the contents of one file in another. When you call include, think
of it as just copy/pasting the contents of the included file at that point.

Any variables already defined (and in scope) will therefore be be available
to the code included file, for example:

--- main.php ---

$strTitle = 'The title';
$intTitleLength = strlen($strTitle);

include('display.php');


--- display.php ---

echo 'Title is '.$strTitle.' and is '.$intTitleLength.' characters long';


I hope this makes sense but feel free to reply to the list if you have any
questions.

Edward

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



RE: [PHP] Re: What does "<<<" mean?

2007-05-01 Thread Edward Kay
 <<< END
  some code
 END
>> Bash redirection... :)

> Syntax error ;) 

Key stuck on keyboardd :)

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



RE: [PHP] Parsing CSV files

2007-04-27 Thread Edward Kay

> When I searched for "csv" against on php.net I got redirected to
> http://us2.php.net/manual/en/function.gzeof.php.  That isn't exactly
> obvious is it?
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

OK, sorry for being critical. As Tijnema showed, the different mirrors seem to 
be giving different search results. Searching for 'csv' on http://uk.php.net 
goes to http://uk.php.net/manual-lookup.php?pattern=csv which clearly lists the 
suitable functions.

It looks as if some of the mirrors are a bit dirty :)

Edward

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



RE: [PHP] Recursive function for array task?

2007-04-27 Thread Edward Kay


> -Original Message-
> From: Stewart Macdonald [mailto:[EMAIL PROTECTED]
> Sent: 27 April 2007 10:13
> To: php-general@lists.php.net
> Subject: [PHP] Recursive function for array task?
>
>
> Hi all,
>
> I've got a bit of a logic problem that I can't figure out.
>
> I've got an array:
>
> Array
> (
>  [B] => X
>  [C] => Q,K
>  [D] => M
>  [F] => V
>  [G] => N
>  [I] => X,M
>  [K] => C
>  [M] => I,V
>  [Q] => C
>  [R] => U
>  [V] => M
>  [X] => I
> )
>
> This array shows groupings of objects:
>   B is paired with X
>   X is also paired with I
>   I is also paired with M
>   M is paired with V and D
>   V is paired with F
> F and D aren't paired with anything else, so that's the end of one
> group.
> There are a few other pairs in the array. So this array contains the
> following groups:
>   B,X,I,M,V,F,D
>   C,Q,K
>   G,N
>   R,U
>
> The general structure of each element in the array is:
> [key] -> code1, code2, code3, . codeN
>
> N is theoretically unlimited (but practically limited to about 50).
> The key can be a value in the array multiple times, but each key
> should be unique.
>
> It's easy to look at the array and manually work out these groups,
> but I can't find a way to programatically work out groups.
>
> I've tried to write a recursive function to do it. The function works
> most times, but it's stalling on the above array.
>
> Does PHP have an array function that would let me 'collapse' all
> these together somehow? If it makes it easier (i.e., there's a way of
> doing this if the original array is formatted differently) I can re-
> write the code that generates the original array.
>
> I'm sure I'm overlooking something simple. Can anyone offer any help?
> I don't want to manually work out groups from thousands of arrays!
>
>
> Thanks!
>
> Stewart
>

Interesting problem. I've got a few ideas but please could you clarify what
you want as the output? Is it just an array of the groups, i.e.

Array
(
[0] => 'B,X,I,M,V,F,D'
[1] => 'C,Q,K'
[2] => 'G,N'
[3] => 'R,U'
)

Edward

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



RE: [PHP] Find a what class a variable is

2007-04-27 Thread Edward Kay
> -Original Message-
> From: John Comerford [mailto:[EMAIL PROTECTED]
> Sent: 27 April 2007 08:41
> To: php-general@lists.php.net
> Subject: [PHP] Find a what class a variable is
>
>
> Hi Folks,
>
> Is is possible to detect what class a variable is eg.
>
> $JC1 = new Button();
> $JC2 = new TickBox();
>
>
> Is it possible to find out what class $JC1 is ?
>
> TIA,
>   JC

If you want check it is of a certain type, use the instanceof operator, e.g.

if ($JC2 instanceof TickBox)
echo '$JC2 is a TickBox';
else
echo '$JC2 is not a TickBox';

E

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



Re: [PHP] Parsing CSV files

2007-04-26 Thread Edward Kay

Todd Cary wrote:

Is there a function that can parse a comma delimited file into an array?

Todd


fgetcsv - http://uk.php.net/fgetcsv

Did you even try looking in the manual?

Edward

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



RE: [PHP] a little math

2007-04-20 Thread Edward Kay
>
> maybe someone can figure why sometimes i get negative values for seconds..
>
> $job['finished'] and $job['finished'] are both unix timestamp.
> i subtract both to get how many seconds some thing took.. well you
> should be able to read the rest. sometimes it works fine but other times
> i get negative seconds.
>
>
> $job['run_time']  = ($job['finished'] - $job['started']);
>
> $minutes = number_format($job['run_time'] / 60, 0, '', '');
>
> // seconds left after calculating minutes
> $seconds = (($job['run_time']- 60) * $minutes);
>
> $job['runtime'] = $minutes . ' mins ' . $seconds . ' secs';
>

If $job['run_time'] < 60 then clearly $seconds will be negative.

Why don't you use:

$minutes = floor($job['run_time'] / 60);
$seconds = $job['run_time'] % 60;

Edward

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



[PHP] Decoding from unknown charsets (inc. ks_c_5601-1987)

2007-04-10 Thread Edward Kay
I have an app that stores email messages in a database. The app and DB are
UTF-8 but obviously the emails can be in a variety of character sets. Most
can be converted easily using mb_convert_encoding or iconv but I have some
emails encoded as ks_c_5601-1987, which neither of these two functions
handle.

Googling for ks_c_5601-1987 doesn't help. Most people just say it is an
invalid charset and can be ignored as spam, but we have genuine emails that
need to be stored in the DB.

If I don't convert the messages, they get truncated when inserted into the
database.

Any ideas?

Edward

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



RE: [PHP] tabbed navegation PHP

2007-03-30 Thread Edward Kay


> -Original Message-
> From: Dwayne Heronimo [mailto:[EMAIL PROTECTED]
> Sent: 30 March 2007 14:06
> To: php-general@lists.php.net
> Subject: [PHP] tabbed navegation PHP
>
>
> Dear All,
>
> I have made a tabbed navegation with CSS. And if you set
> class="active" to
> one of the tabs, it will then be highlighted.
> So I thought to make this dymamic with PHP. Using the $_GET
> variable I can
> get the page name above with something like. $page_name = $_GET['page'] ;
> so I can tell the class when to be active to what page.
>
> Should I use the isset function for this? I am very new to PHP
> but here is
> my try, but of course its not working:
>
>  if (isset ($_GET['page'])) {
>
>  $page_name = $_GET['page'] ;
>
>   if ($page_name = "default") {
>$flg_page_default=1;
>   }
>   if ($page_name = "about") {
>$flg_page_about=1;
>   }
>
> }
> ?>
>

This isn't working as you aren't comparing in your if statements. You need
to use the == operator; an = on it's own is an assignment.

>
>
>  else echo '';
> ?> href="index.php?page=default">home
>  echo ''; ?>
> href="index.php?page=default">about
>
>
> Of should I stick to just static html :(
>
> Dwayne
>
> --
> 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] preview string with strlen PHP (help)

2007-03-23 Thread Edward Kay

> -Original Message-
> From: Dwayne Heronimo [mailto:[EMAIL PROTECTED]

> Dear All,
>
> I am very new to programming. I want to make a preview text that would
> display only a part of the text that is a text field in a database.
>
> //Begin Make preview string
>
>  $minitxt = $row_show_cat['text'];
>  $len = strlen($minitxt);
>
>  if ($len > 235)
>  {
>   $len = 235;
>  }
>  else
>  {
>   $len = $len;
>  }
>
>  $newstring = substr($minitxt,0,$len);
>
>  $previewtext = $newstring;
>
> //End Make preview string
>
> But if I want to display this somewhere in the page it will only
> display the
> first record of at every text column row 
>
> Althought I am very new to php and programming. I thought maybe I should
> rewrite it into a function. But my function won't work.
>
>
> function previewString($showcatvar) {
>
>  $minitxt = $showcatvar;
>  $len = strlen($minitxt);
>
>  if ($len > 235)
>  {
>   $len = 235;
>  }
>  else
>  {
>   $len = $len;
>  }
>
>  $newstring = substr($minitxt,0,$len);
>
>  $previewtext = $newstring;
>
>  $previewtext = $whowcatvar;
>
> }
>
>
> and to display it in the page:
>
> 
>
> IT displays notthing. But I think I am doing somthing wrong. I am
> assigning
> the wrong variables to the $row_show_cat['text']) ???
>
> Please let me know

Hi Dwayne,

Your function isn't working as you expect because you are not returning any
value. I would rewrite it as:

function previewString($strInput) {
// Max length allowed
// You could also store this in a config file or pass in as
// a second, possibly optional argument.
$intMaxLen = 235;

if (strlen($strInput) > $intMaxLen) {
// Too long so trucate it (and add ... to show
// it is truncated. I subtract 3 to allow for ...)
return substr($strInput, 0, ($intMaxLen-3)).'...'
}

// If we get here it is less than or equal to the allowed max so just
return it
return $strInput;
}

You would then call the function when you needed the truncated string, e.g.


If you are outputting this to a web page, you'll probably also want to pass
it through the htmlentities function: 

Good luck,
Edward

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



RE: [PHP] POST a variable

2007-03-23 Thread Edward Kay
> -Original Message-
> From: Németh Zoltán [mailto:[EMAIL PROTECTED]

> 2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt írta:
> > Okay, I feel like the correct answer to this is about 2mm back 
> in my grey
> > matter.
> > 
> > 1. I have a query that pulls the last row number when a newly inserted
> > record is added:
> > 
> > $maximum="SELECT MAX(payment_id) FROM payment_request";
> >   $max_result=mssql_query($maximum);
> >   while($max=mssql_fetch_row($max_result)){
> >   }
> >   $max_id = $max[0];
> > 
> > 2. I have multiple selections for the user to pick, but 
> regardless of what
> > they choose I want the $max_id variable to be passed to the next page.
> > 
> > 3.  Would I go about this by assigning $max_id to a hidden 
> field like below?
> > 
> > " size="5"
> > maxlength="10" name="max_id" />
> > 
> > 4.  And then to retrieve this value on my next page just get it out of
> > $_POST['max_id']  ??
> > 
> > Does that all sound correct?
> 
> basically yes

Personally, I'd put it in a session variable. This reduces the amount of data 
sent to/from the client and also stops anyone altering the value themselves. 

> but if you want the id of the row you just inserted, using
> mysql_insert_id() is better because if another insert is happening at
> the same time, select max() may give you incorrect result

This would be true if he was using MySQL. The code given uses MSSQL and there 
is no mssql_insert_id function (in my PHP manual).

Edward 

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



RE: [PHP] read only texbox to html with php

2007-03-21 Thread Edward Kay
2007. 03. 21, szerda keltezéssel 11.51-kor Ross ezt írta:
> I have a readonly textbox that gets mailed as a newsletter. The 
text is a 
> standard covering letter. The problem is when I try and convert 
it to html 
> it doesn't work  It is inserted into a variable via a form textarea 
> $mail_text.
> 
>  "available on the web site  href="http://www.myurl.org";>http://www.myurl.org so you can 
see who is 
> doing."
> 

If I understand correctly, you are setting the value of an HTML textbox to some 
HTML code. When viewing the page, you want the HTML in the textbox to be 
rendered. This isn't possible.

> I tried this
> 
> htmlentities((stripslashes($mail_text)));
> 
> 
> Any ideas?
> 

Why can't you forget the textbox just output the HTML directly?

Edward

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



RE: [PHP] Running PHP on a windows server-your views

2007-03-19 Thread Edward Kay
> On 3/19/07, Edward Kay <[EMAIL PROTECTED]> wrote:
> > > On 3/19/07, Angelo Zanetti <[EMAIL PROTECTED]> wrote:
> > > > HI all.
> > > >
> > > > I would like some honest answers and if you have any experience with
> > > > problems or no problems running PHP on a windows server.
> > > >
> > > > Basically we are interested to know if there are any
> problems/security
> > > > issues/stability issues/performance issues or any other
> issues running a
> > > > production site (big live site) on a windows server.
> > > >
> > > > Im assuming it will be running IIS.
> > > >
> > > > The site is very important and any issues will hamper the
> functionality
> > > > and accessibility of the site.
> > > >
> > > > All your responses will be greatly appreciated.
> > > >
> > > > TIA
> > > > Angelo
> > > > --
> > >
> >
> > From my experience, it seems many more people in the web
> community run PHP
> > under Linux than Windows. Therefore, if, no, when you get stuck with
> > something, the chances of you finding the answer quickly would be much
> > higher with Linux.
> >
> > Edward
> >
> That's not totally true, as PHP doesn't differ a lot if running on
> linux/windows. And even users that run PHP on linux know sometimes
> answers for people running PHP on windows...
>
> Tijnema.

You're right, PHP scripting doesn't differ that much between operating
systems and the few inconsistencies are generally known from both sides.

>From my interpretation of the OP though, the question is not so much about
PHP coding but rather the web server setup. I think that there is generally
more support on the web for running web servers on Linux than Windows, and
this is especially true when using PHP.

Edward

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



RE: [PHP] Running PHP on a windows server-your views

2007-03-19 Thread Edward Kay
> On 3/19/07, Angelo Zanetti <[EMAIL PROTECTED]> wrote:
> > HI all.
> >
> > I would like some honest answers and if you have any experience with
> > problems or no problems running PHP on a windows server.
> >
> > Basically we are interested to know if there are any problems/security
> > issues/stability issues/performance issues or any other issues running a
> > production site (big live site) on a windows server.
> >
> > Im assuming it will be running IIS.
> >
> > The site is very important and any issues will hamper the functionality
> > and accessibility of the site.
> >
> > All your responses will be greatly appreciated.
> >
> > TIA
> > Angelo
> > --
>

>From my experience, it seems many more people in the web community run PHP
under Linux than Windows. Therefore, if, no, when you get stuck with
something, the chances of you finding the answer quickly would be much
higher with Linux.

Edward

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



  1   2   >