[PHP] Will the progress bar like Xupload add too much weight to the Apache server?

2008-03-20 Thread Shelley

Hi all,

Here is the Xupload progress bar link:
http://www.sibsoft.net/xupload.html

My question is:
Will the upload progress bar like that add too much weight to the Apache 
server, especially to a server with millions of visitors each day?


Thanks in advance.

--
Regards,
Shelley ( PHP Architecture: http://phparch.cn )


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



[PHP] Problems with mime encoding of Japanese Characters in Subject and 'From:', 'Reply-to:', ... fields.

2008-03-20 Thread Dietrich Bollmann
Hi, 

--- note ---
I sent a similar message already to php-i18n - but this list seems
not to be used very much (20 messages this year) so I am posting it
here again...


I try to send messages written in Japanese (Kana/Kanji) with php.

Everything works fine - only when the subject (or the name of the
sender) becomes longer, there seems to be something wrong with the
encoding: Neither my nor the mail reader of other (Japanese) friends 
decodes the mime string. At the place of the Japanese Characters, 
the mime string itself is displayed in the subject (to, reply to) 
field.

As this doesn't happen for other Japanese emails with even longer
subjects, I suppose I did something wrong ... but what?

Here how I convert the subject (the name is converted using the same
method and the sources are saved in UTF-8 using emacs):

  $subjectJIS  = mb_convert_encoding($subject, ISO-2022-JP, AUTO);
  $subjectMIME = mb_encode_mimeheader($subjectJIS, ISO-2022-JP, B);
  ...snip...
  mail($to, $subjectMIME, $bodyJIS, $headers);

Here part of the message as it is displayed by my mail program:

  From:
=?ISO-2022-JP?B?GyRCJCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7?==?ISO-2022-JP?B?eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3ob?=(B
 [EMAIL PROTECTED]
  ...snip...
  Subject:
=?ISO-2022-JP?B?GyRCJCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7?= 
=?ISO-2022-JP?B?eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3ob?= (B
  ...snip...
  
  かな漢字かな漢字かな漢字かな漢字かな漢字かな漢字かな漢字かな漢字かな漢
字かな漢字

And here part of the mail text itself:

  ...snip...
  Subject:

=?ISO-2022-JP?B?GyRCJCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7?=

=?ISO-2022-JP?B?eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3ob?=
=?ISO-2022-JP?B?KEI=?=
  MIME-Version: 1.0
  From:
=?ISO-2022-JP?B?GyRCJCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7?= 
=?ISO-2022-JP?B?eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3ob?= 
=?ISO-2022-JP?B?KEI=?= [EMAIL PROTECTED]
  ...snip...
  Content-Type: text/plain; charset=ISO-2022-JP
  ...snip...
  
  かな漢字かな漢字かな漢字かな漢字かな漢字かな漢字かな漢字かな漢字かな漢
字かな漢字

Here a part of another (spam) mail which is correctly displayed by my
mail program:

  MIME-Version: 1.0
  Subject:
=?ISO-2022-JP?B?GyRCIXolXSUkJXMlSBsoQjEwGyRCR1whdUF3TkEbKEI=?=
=?ISO-2022-JP?B?GyRCTDVOQSF6GyhCMSwwMDAbJEIxXyU4JWUbKEI=?=
=?ISO-2022-JP?B?GyRCJSglaiE8Qmc9ODlnISohWjNaRTchWxsoQg==?=
=?ISO-2022-JP?B?GyRCIUobKEIyMDA4LzAzLzE5?= =?ISO-2022-JP?B?KQ==?=
  From: =?ISO-2022-JP?B?GyRCM1pFNztUPmwlOCVlJSglaiE8ISYlIhsoQg==?=
=?ISO-2022-JP?B?GyRCJS8lOyU1JWohPCVLJWUhPCU5GyhC?=
[EMAIL PROTECTED]
  
Displayed as:

  From: 楽天市場ジュエリー・アクセサリーニュース
[EMAIL PROTECTED]
  ...snip...
  Subject:  ★ポイント10倍&送料無料★1,000円ジュエリー大集合!【楽天】
(2008/03/19)
  
If anybody can explain me the problem I would be most grateful :)

Thanks, Dietrich


---
PS: I appended a little example program which produces the problem.

The same program works correctly when using the following values:

  $subject = かな漢字;
  $senderName = かな漢字;

Thanks for your help :)


!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
 head
 meta http-equiv=content-type content=text/html;
charset=UTF-8 /
 titleContact Me/title
 /head
 body

 h1かな漢字/h1

 ?php # Script 10.1 - email.php

function sendEmail($recipientEmailAddress, $subject, $body, $senderName,
$senderEmailAddress) {

// set current language to Japanese
mb_language(ja);

// encode subject
// - first using JIS (ISO-2022-JP)
// - after encoding the resulting JIS string with the MIME header
encoding scheme
$subjectJIS  = mb_convert_encoding($subject, ISO-2022-JP, AUTO);
$subjectMIME = mb_encode_mimeheader($subjectJIS, ISO-2022-JP,
B);

// encode the name of the sender
// - first using JIS (ISO-2022-JP)
// - after encoding the resulting JIS string with the MIME header
encoding scheme
$senderNameJIS  = mb_convert_encoding($senderName, ISO-2022-JP,
AUTO);
$senderNameMIME = mb_encode_mimeheader($senderNameJIS,
ISO-2022-JP, B);

// encode body
// - using JIS (ISO-2022-JP)
// - the used coding system had to be specified in the
Content-Type/charset header:
//   Content-Type: text/plain; charset=ISO-2022-JP
$bodyJIS = mb_convert_encoding($body, ISO-2022-JP, AUTO);

// formatting the sender string
$senderMIME = sprintf(%s %s, $senderNameMIME,
$senderEmailAddress);

// formatting the mime header
$headers  = MIME-Version: 1.0\n ;
$headers .= sprintf(From: %s\n, $senderMIME);
$headers .= sprintf(Reply-To: %s\n, $senderMIME);
$headers .= Content-Type: text/plain; charset=ISO-2022-JP\n;
   
// send encoded mail
$result = mail($recipientEmailAddress, $subjectMIME, $bodyJIS,
$headers);

// return result
return $result;
 }

$to = [EMAIL 

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

2008-03-20 Thread Dotan Cohen
On 20/03/2008, tedd [EMAIL PROTECTED] wrote:
 At 9:29 PM +0200 3/19/08, Dotan Cohen wrote:
  I am asking the second question: how many Hebrew characters in a
  string that _very_likely_ contains other characters as well. The array
  suggestion sounds about what I am doing: checking if each letter is a
  Hebrew character.
  
  I will also look into the mb_ functions. I did not know about them
  before. Thanks.
  
  Dotan Cohen


 Dotan:

  It really doesn't make any difference.

  If you have a single character that is not ASCII, then it's something
  beyond ASCII and you'll need to use the mb_functions.

  Unicode contains all known characters (code points) including ASCII
  with values equal to ASCII -- so there's no problem between code
  points and ASCII.

  The beyond ASCII string problem is basically what is a character? We
  all know what an a is, but what about a with a ~ above it? Is
  it one character or two? If it's a combination of two code points,
  then it's a grapheme.

  What about the character fi when it's combined? Is it one character
  or two? In this case, it's a ligature and is a single code point.

  So, when you are trying to count characters in a string, using ASCII
  based functions won't work because they might count one character as
  two and break the character in two parts. Or, the character might be
  actually two characters, but they should be counted as one. As such,
  mb_functions are designed to work with these types of problems where
  as standard string functions won't.

  The easy way to tell IF you should use mb_functions is if all the
  characters you're working with appear in the ASCII table, then
  standard string functions apply. However, if any of the characters
  are not found in ASCII, then you need to go another route.

  At least, that's my understanding.


  Cheers,

  tedd

Thank you Tedd, that was very helpful. After reading your mail from
yesterday I went to wikipedia to learn what graphemes and ligatures
are. Your example of fi was there, otherwise I would have had no
idea that those letters can be combined. In Hebrew and Arabic,
especially, I can see how the vowel points (Hebrew) and combinations
like LA (Arabic) can confuse the ASCII function. Thanks.

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?


[PHP] Re: Will the progress bar like Xupload add too much weight to the Apacheserver?

2008-03-20 Thread Manuel Lemos
Hello,

on 03/20/2008 03:32 AM Shelley said the following:
 My question is:
 Will the upload progress bar like that add too much weight to the Apache
 server, especially to a server with millions of visitors each day?

It is hard to tell. It seems to rely on a mod_perl script.

You may also want to try this forms generation and validation class that
 comes with an upload progress plug-in that relies only on PHP:

http://www.phpclasses.org/formsgeneration

Here you can test it live:

http://www.meta-language.net/forms-examples.html?example=test_upload_progress

Here you can watch it live:

http://www.phpclasses.org/browse/video/1/package/1/section/plugin-upload-meter.html

-- 

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



[PHP] Re: Problems with mime encoding of Japanese Characters in Subject and'From:', 'Reply-to:', ... fields.

2008-03-20 Thread Manuel Lemos
Hello,

on 03/20/2008 04:06 AM Dietrich Bollmann said the following:
 Hi, 
 
 --- note ---
 I sent a similar message already to php-i18n - but this list seems
 not to be used very much (20 messages this year) so I am posting it
 here again...
 
 
 I try to send messages written in Japanese (Kana/Kanji) with php.
 
 Everything works fine - only when the subject (or the name of the
 sender) becomes longer, there seems to be something wrong with the
 encoding: Neither my nor the mail reader of other (Japanese) friends 
 decodes the mime string. At the place of the Japanese Characters, 
 the mime string itself is displayed in the subject (to, reply to) 
 field.
 
 As this doesn't happen for other Japanese emails with even longer
 subjects, I suppose I did something wrong ... but what?

You may want to try this MIME message composing and sending class that
can send messages with encoded headers correctly using any character
set. Take a look at the test_multibyte_message.php example script:

http://www.phpclasses.org/mimemessage


-- 

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



Re: [PHP] Problems with mime encoding of Japanese Characters in Subject and 'From:', 'Reply-to:', ... fields.

2008-03-20 Thread Dietrich Bollmann
Hi - in order to see the Japanese Characters in the previous mail 
you might have to switch the Character Encoding of your Email reader
to Unicode (UTF-8).  In my case (I am using the Evolution mail program
on Linux): 

  View  Character Encoding  Unicode (UTF-8)

Dietrich

On Thu, 2008-03-20 at 16:06 +0900, Dietrich Bollmann wrote:
 I try to send messages written in Japanese (Kana/Kanji) with php.
 
 Everything works fine - only when the subject (or the name of the
 sender) becomes longer, there seems to be something wrong with the
 encoding: Neither my nor the mail reader of other (Japanese) friends 
 decodes the mime string. At the place of the Japanese Characters, 
 the mime string itself is displayed in the subject (to, reply to) 
 field.
 
 As this doesn't happen for other Japanese emails with even longer
 subjects, I suppose I did something wrong ... but what?


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



[PHP] Re: fwrite/fclose troubles

2008-03-20 Thread Peter Ford

Mark Weaver wrote:

Hi all,

I've been lurking and reading now for some time, but have decided to
come out of the shadows cause I've got an issue that's gonna drive me 
crazy!


I'm developing an application and within this application is a class
that is very simple and only serves a singular purpose - to make log
entries to help with debugging. Problem is, now I'm debugging the damned
logging class that is supposed to be helping me debug the application as
I'm putting it together! sigh I've looked and looked all over the
place, but I don't seem to be able to find an answer to this problem.
The only information that I have found so far deals with permissions and
I don't think that's the problem. At first I was getting an access
denied error but since setting dir perms and log file perms so that both
apache and my user can right to both the directory and the file that one
has gone away.

Log Directory permissions: /mystuff/logs  rwx-rwx-rwx (777)
Log file permissions: /mystuff/logs/run.log   rwx-rwx-rwx
(777)

At any rate, the following is the information I'm getting in the apache
error_log while working on this particular portion of the application:

PHP Warning:  fwrite(): supplied argument is not a valid stream resource
in /mystuff/inc/Log.inc on line 22,
PHP Warning:  fclose(): supplied argument is not a valid stream resource
in /mystuff/inc/Log.inc on line 23,

The Log class:
-
class Log{
public $path, $entry, $logfile;

public function Log(){}

public function setLog($path,$file){

$this-path = $path;
$this-logfile = $file;
}

public function writeLog($entry){

// open the file, in this case the log file
$h = $this-path/$this-logfile;
fopen($h, 'a+');
fwrite($h,$entry);
fclose($h);
}
}

Code snippet where attempting to write log entry from program:
 


$pl_log = new Log;
$pl_log-setLog($logpath,run.log);
   
$usernanme = $_POST['username'];

$password = $_POST['secret'];
   
/**

   * (debugging) logging incoming values from form:
   */
$pl_log-writeLog(getDateTime(): Incoming values from Login Form:
blah...blah...blah\n);

Any help with this would be most appreciated. (be gentle... I'm a PERL
program learning PHP OOP)




As Stut pointed out, you've misunderstood the difference between a file resource 
and a file name.


Try something like:


 public function writeLog($entry)
 {
 // open the file, in this case the log file
 $fileName = $this-path.'/'.$this-logfile;
 $h = fopen($fileName, 'a+');
 fwrite($h,$entry);
 fclose($h);
 }

The file resource that fwrite and fclose need is the *result* of opening the 
file, not the file name as you were doing.
Ideally, you would check the value of $h after the fopen call, to make sure that 
it had successfully opened the file.


Also, I changed the way you were constructing the file name: interpolating the 
variables in a string is slightly less efficient than concatenating the bits 
together, and there are possible gotchas when using the $this-variable 
structure in a string like that.

An alternative syntax is to escape the variables with braces:

$fileName = {$this-path}/{$this-logfile};


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Anyone using clsMsDocGenerator?

2008-03-20 Thread George Pitcher
Hi,

If anyone is using clsMsDocGenerator to produce MSWord files without using
COM, I have a just one question (I tried the PHPClasses forum, but couldn't
get my forum post in).

How do you remove borders from tables?

I am preformatting a html string with att the data going into the document,
including tables, but they always show a fine border, even though border is
set to 0 in my table formatting.

Any suggestions?

Cheers

George


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



[PHP] Re: selling gpl software?

2008-03-20 Thread Colin Guthrie
Larry Garfield wrote:
 On Wednesday 19 March 2008, Colin Guthrie wrote:
 
 Also as it's GPL and as you are supplying the modifications you make
 to your client, you are obliged to release the changes you make to the
 community. If this was a 100% internal development (e.g. you are
 employed directly by your client, not as a contractor), then you are not
 obliged to release the changes.
 
 Not true.  If you take an open source project, modify it, and give a copy to 
 your client, you are under no obligation to give anyone else in the world a 
 copy of your modified code.  What you ARE required to do is give that 
 modified to code to your client under the GPL so that he can, if he wants to, 
 share it with the world, and anyone he gives a copy to can also share it with 
 the world if they want to, etc.

Is that true? I would have thought that by developing under contract and
then subsequently supplying your modifications to your client, this
constitutes distribution of the code. It is this distribution of the
code that I've always considered the trigger for having to share it
back to the community - e.g. if your changes are internal to your
company you don't need to share it. Earlier I wrote that whether he was
employed directly or as a contractor would have bearing and this
statement was based on the above understanding. Am I wrong?

Col



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



RES: [PHP] Newbie question, Which way is best?

2008-03-20 Thread Thiago Pojda
De: George J [mailto:[EMAIL PROTECTED] 

 So calling the script via the form works i.e it passes the 
 neccessary variables to constrct the sql query for the next 
 call. 

As Shawn said, if you really need the query again add it to session, never,
NEVER give the user the ability to see/execute queries by himself (remember
POST data could be easily manipulated). Remember what Daniel said, adding a
DELETE FROM is not hard and veeery bad.

 If the user clicks one of the pagination links, that 
 calls itself, all that is passed is the page=$i variable. I 
 need to include the 'SELECT * FROM...' query either as a string 
 or an array of seperate values for the changed query.

Ok, let me ask you something. Why post to itself? You could have a script
only to do form actions, that way you can:
1 Separate huge php validations with your html form.
2 Use functions to handle the incoming data and writing the new query (or
the old one again).

As it's built at server side, the user is never going to see your query or
[1]manipulate it as you're writing it all over again, just using your old
parameters (they could be added as hidden fields in the form if strictly
necessary).


 So, as I see it, the pagination links won't POST the form 
 variables. How do I pass the 'SELECT * FROM mytable WHERE 
 selection=option LIMIT start, range' 
 query to the called script?

You should try building a default query where you only add the parameters
given by the user. If you can't seem to recover that, add them to $_SESSION
and you'll be fine next time you want them (if you don't overwrite it =] ).

 George
Welcome and keep asking :)


[1] As long as you treat the user input properly, as other said.
 



--
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



[PHP] Playing around with strings

2008-03-20 Thread Robin Vickery
Hiyah,

Here's a trick you can use to evaluate expressions within strings. It
may not be particularly useful, but I thought it was interesting.

It exploits two things:

1. If you interpolate an array element within a string, the index of
the element is evaluated as a php expression.

2. You can can make your own magic arrays by extending arrayObject.


?php
class identityArrayObject extends arrayObject
{
  public function offsetGet($index)
  {
return $index;
  }
}

$eval = new identityArrayObject;

print The square root of {$eval[pow(2,2)]} is {$eval[sqrt(4)]} \n;

print Price: $price GBP ({$eval[$price * 1.175]} GBP including tax) \n;

?

You can extend it to add your own formatting elements:

?php
class uppercaseArrayObject extends arrayObject
{
  public function offsetGet($index)
  {
return strtoupper($index);
  }
}

$U = new uppercaseArrayObject;
$city = 'edinburgh';

print The capital of Scotland is $U[$city] \n;
?

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



Re: [PHP] Re: selling gpl software?

2008-03-20 Thread Larry Garfield
On Thursday 20 March 2008, Colin Guthrie wrote:
 Larry Garfield wrote:
  On Wednesday 19 March 2008, Colin Guthrie wrote:
  Also as it's GPL and as you are supplying the modifications you make
  to your client, you are obliged to release the changes you make to the
  community. If this was a 100% internal development (e.g. you are
  employed directly by your client, not as a contractor), then you are not
  obliged to release the changes.
 
  Not true.  If you take an open source project, modify it, and give a copy
  to your client, you are under no obligation to give anyone else in the
  world a copy of your modified code.  What you ARE required to do is give
  that modified to code to your client under the GPL so that he can, if he
  wants to, share it with the world, and anyone he gives a copy to can also
  share it with the world if they want to, etc.

 Is that true? I would have thought that by developing under contract and
 then subsequently supplying your modifications to your client, this
 constitutes distribution of the code. It is this distribution of the
 code that I've always considered the trigger for having to share it
 back to the community - e.g. if your changes are internal to your
 company you don't need to share it. Earlier I wrote that whether he was
 employed directly or as a contractor would have bearing and this
 statement was based on the above understanding. Am I wrong?

 Col

If the code is work for hire and the initial ownership is with the 
client/company, then there is no distribution and so you are not required to 
do anything.  That includes if you are a full time employee of the company.

If the code you write is owned by you and given to a client, that is 
distribution.  You can either give the client a copy of the source at the 
same time, in which case you needn't share it with anyone else, or say you 
can get it from this FTP if you want, in which case anyone may access it 
because when the client distributes the runnable version of the code to 
someone else, they will also say and you can get it from this FTP if you 
want.  

As PHP is its own source code, the latter is generally not an issue since the 
source code is provided automatically.  

So in the OP's case, if he takes an existing GPLed project, modifies it in 
whatever way (including removing mention of the original project), and gives 
a copy to his client, his only legal obligation is to provide the client with 
the code under the GPL so that the client can, if he wants, pass the code on 
to someone else under the GPL.  Someone else could be a public FTP server 
or not.

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] Double click problem

2008-03-20 Thread Lamp Lists
the way I solved the click back button issue (simplified vresion):

confirmation page (conf.php) - transfer page (tp.php) - thank you page 
(typ.php)

#conf.php
# after the form is submitted and confirmed
header('location: tp.php?url=typ.php');
exit;

#tp.php
header('location:$_GET['url']);
exit;

and, if visitor clicks on back button on thakyou page he will go actually to 
the transfer page - which will send him back to thankyou page
;)

-ll



- Original Message 
From: tedd [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Wednesday, March 19, 2008 11:43:06 AM
Subject: Re: [PHP] Double click problem

At 4:19 PM + 3/19/08, Richard Heyes wrote:
tedd wrote:
// ...

Your first (and the quickest by far) method to employ would be to 
disable the submit button using Jabbascript when the form is 
submitted. That will stop the vast majority of occurrences. You 
could also employ an intermediary page which actually does the card 
processing and when complete redirects to the thank you page. ie.

Form -- Please wait... page -- Thank you page

That's in place. The person clicks the confirm purchase and they 
are taken to a confirm and thank you page.

The problem here is two fold -- 1) clicking the confirm 
purchasebutton twice, which I think js will stop; 2) and clicking 
the back-button which the token should stop.

Now, I just need to develop a test for this. Sometime writing a test 
is more of a problem than writing the solution.

Thanks for everyone's help.

Cheers,

tedd


-- 
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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


  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

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

2008-03-20 Thread Philip Thompson

On Mar 19, 2008, at 11:55 PM, Shelley wrote:

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



The archive of my results was saved here:
http://phparch.cn/index.php/mysql/35-MySQL-programming/126-fastest-way-to-get-total-records-from-a-table


Just an FYI about your article. Evan is supposed to be spelled  
even. ;)




--
Regards,
Shelley ( PHP Architecture: http://phparch.cn )


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



Re: [PHP] Will the progress bar like Xupload add too much weight to the Apache server?

2008-03-20 Thread Daniel Brown
On Thu, Mar 20, 2008 at 2:32 AM, Shelley [EMAIL PROTECTED] wrote:
 Hi all,

  Here is the Xupload progress bar link:
  http://www.sibsoft.net/xupload.html

  My question is:
  Will the upload progress bar like that add too much weight to the Apache
  server, especially to a server with millions of visitors each day?

You consistently ask irrelevant questions here.  Not only is
Xupload not written in PHP, your question relates to Perl and Apache
--- not at all to PHP.

Please select the correct list when asking questions.

-- 
/Daniel P. Brown
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283

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



Re: [PHP] php book

2008-03-20 Thread Lamp Lists
opinions of good book is almost the same as opinion of good car.
I can suggest you to go to barnes and noble or borders or any other bookstore, 
buy cup of coffee or tea, grab all php books from shelf and read some chapters. 
you are no going to learn anything, rather to compare styles. some authors 
use a lot of code, some to much code, some explain to details some throw just 
links where to find more info, some explain functions with examples, some just 
in general... you know what I mean.
spend 2-3 hours going through the books and then pick one you like (the style) 
the most.

my 2 cents.

-ll



- Original Message 
From: alexus [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Wednesday, March 19, 2008 9:50:23 AM
Subject: [PHP] php book

what book would you guys suggest for someone who's new and wants to learn php?

-- 
http://alexus.org/

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


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

[PHP] Re: algorithm of pages beaking

2008-03-20 Thread tedd

At 11:35 PM + 3/19/08, George J wrote:

Hi,

I'm trying to resolve an issue with a pagination routine. Sounds like we're
working on a similar routine. I have a query returning products from a
database and then display the results in a defined number of products per
page.

Checkout - 'Newbie question, Which way is best?' in this newsgroup.

George


George:

Which is the best way? Well of course, my way. :-)

Here's a demo (with code):

http://webbytedd.com/bbb/paging/

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
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 tedd

At 9:10 AM +0200 3/20/08, Dotan Cohen wrote:

On 20/03/2008, tedd [EMAIL PROTECTED] wrote:
   At least, that's my understanding.



  Cheers,

  tedd


Thank you Tedd, that was very helpful. After reading your mail from
yesterday I went to wikipedia to learn what graphemes and ligatures
are. Your example of fi was there, otherwise I would have had no
idea that those letters can be combined. In Hebrew and Arabic,
especially, I can see how the vowel points (Hebrew) and combinations
like LA (Arabic) can confuse the ASCII function. Thanks.

Dotan Cohen


Dotan:

No problem -- if you want a great book on the subject, try:

Building Scalable Web Sites by Henderson

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

Plus, there's a lot more good stuff in that book.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Re: algorithm of pages beaking

2008-03-20 Thread Robert Cummings

On Thu, 2008-03-20 at 11:32 -0400, tedd wrote:
 At 11:35 PM + 3/19/08, George J wrote:
 Hi,
 
 I'm trying to resolve an issue with a pagination routine. Sounds like we're
 working on a similar routine. I have a query returning products from a
 database and then display the results in a defined number of products per
 page.
 
 Checkout - 'Newbie question, Which way is best?' in this newsgroup.
 
 George
 
 George:
 
 Which is the best way? Well of course, my way. :-)
 
 Here's a demo (with code):
 
 http://webbytedd.com/bbb/paging/

Your page pops up my JavaScript error console... 

Reference to undefined variable: startup

:)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] php book

2008-03-20 Thread Wolf

 Lamp Lists [EMAIL PROTECTED] wrote: 
 opinions of good book is almost the same as opinion of good car.

!-- Snip --

I myself prefer books along the lines of the Sam's teach yourself * in * 
hours/minutes series.  I picked up the PHP/MySQL/Apache book when I first 
started learning PHP and still keep it around.  I have looked at the Bibles 
around for PHP and other languages but prefer books that give you the entire 
chunk of code they are talking about instead of piece-mealing it together,  
It's the Context that is important to me.

But I generally keep a browser pointed to php.net and search the functions on 
the site  while trying to get a particularly irritating bit of code to mesh 
with the rest.

YMMV,

Wolf

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



Re: [PHP] Newbie question, Which way is best?

2008-03-20 Thread Philip Thompson

On Mar 19, 2008, at 5:13 PM, George J wrote:

Hi Jason,

Hope this helps -
my 'display_products.php' script
--
form method='post' action='display_products.php'
...
input type='hidden' name= 'query' value=$query
input type='submit' Value='Go'/td
...
// pagination routine
conditional code...
}else{
  echo(a href=\display_products.php?page=$i\img src=$st border= 
\0\

/a );

  }
---

So calling the script via the form works i.e it passes the neccessary
variables to constrct the sql query for the next call. If the user  
clicks
one of the pagination links, that calls itself, all that is passed  
is the
page=$i variable. I need to include the 'SELECT * FROM...' query  
either as a

string or an array of seperate values for the changed query.

So, as I see it, the pagination links won't POST the form variables.  
How do
I pass the 'SELECT * FROM mytable WHERE selection=option LIMIT  
start, range'

query
to the called script?

George


I don't know if anyone has answered the question you have asked at  
least twice... How do I pass the query to the next page? Here's how  
I would approach it. Don't pass the query - all you need is the page  
number. This code hasn't been tested, but I think you'll get the idea.


?php
// thispage.php
if (isset ($_POST['submitted'])) {
$resultsPerPage = 50; // or whatever value
$page = mysql_real_escape_string ($_POST['page']);

$start = ($page * $resultsPerPage) - $resultsPerPage;
$length = $start + $resultsPerPage;

// Notice how you don't send the query in the POST or GET, just  
the page number
$sql = SELECT `field` FROM `table` WHERE (`field_a` =  
'someValue') LIMIT $start, $length;

$results = mysql_query ($sql);
}

// Go to next page
$page = $_POST['page'] ? (int) $_POST['page'] + 1 : 1;
?
...
form method=post action=thispage.php
input type=submit value=Go /
input type=hidden name=page value=?php echo htmlentities  
($page); ? /

input type=hidden name=submitted value=1 /
/form
...

?php
while ($row = mysql_fetch_array ($results, MYSQL_ASSOC)) {
// Display results
}
?


Hopefully that helps a little bit.

~Philip

--
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] Double click problem

2008-03-20 Thread Eric Butera
On Thu, Mar 20, 2008 at 10:39 AM, Lamp Lists [EMAIL PROTECTED] wrote:
 the way I solved the click back button issue (simplified vresion):

  confirmation page (conf.php) - transfer page (tp.php) - thank you page 
 (typ.php)

  #conf.php
  # after the form is submitted and confirmed
  header('location: tp.php?url=typ.php');
  exit;

  #tp.php
  header('location:$_GET['url']);
  exit;

  and, if visitor clicks on back button on thakyou page he will go actually to 
 the transfer page - which will send him back to thankyou page
  ;)

  -ll





  - Original Message 
  From: tedd [EMAIL PROTECTED]
  To: php-general@lists.php.net
  Sent: Wednesday, March 19, 2008 11:43:06 AM
  Subject: Re: [PHP] Double click problem

  At 4:19 PM + 3/19/08, Richard Heyes wrote:
  tedd wrote:
  // ...
  
  Your first (and the quickest by far) method to employ would be to
  disable the submit button using Jabbascript when the form is
  submitted. That will stop the vast majority of occurrences. You
  could also employ an intermediary page which actually does the card
  processing and when complete redirects to the thank you page. ie.
  
  Form -- Please wait... page -- Thank you page

  That's in place. The person clicks the confirm purchase and they
  are taken to a confirm and thank you page.

  The problem here is two fold -- 1) clicking the confirm
  purchasebutton twice, which I think js will stop; 2) and clicking
  the back-button which the token should stop.

  Now, I just need to develop a test for this. Sometime writing a test
  is more of a problem than writing the solution.

  Thanks for everyone's help.

  Cheers,

  tedd


  --
  ---
  http://sperling.com  http://ancientstones.com  http://earthstones.com

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



   
 
  Looking for last minute shopping deals?
  Find them fast with Yahoo! Search.  
 http://tools.search.yahoo.com/newsearch/category.php?category=shopping

Allowing unscrubbed user data in a header is a really bad idea.

- http://en.wikipedia.org/wiki/HTTP_response_splitting
- http://www.owasp.org/index.php/Open_redirect

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



[PHP] newbie question about one php script passing control to another

2008-03-20 Thread Rod Clay
Hello.  I am new to php programming, but have spent many years 
programming in many other languages, most recently perl (with which php 
seems to have much in common!).  In every other language I've worked 
with there is a way for one program to pass control to another.  
However, so far in all of the books and other documentation I've looked 
at for php, I cannot find a way for one php program to pass control to 
another.  Is this possible in php, and, if so, please let me know how.  
Thank you.


Rod Clay
[EMAIL PROTECTED]

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



Re: [PHP] Newbie question, Which way is best?

2008-03-20 Thread George J

Thiago Pojda [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 De: George J [mailto:[EMAIL PROTECTED]

 So calling the script via the form works i.e it passes the
 neccessary variables to constrct the sql query for the next
 call.

 As Shawn said, if you really need the query again add it to session, 
 never,
 NEVER give the user the ability to see/execute queries by himself 
 (remember
 POST data could be easily manipulated). Remember what Daniel said, adding 
 a
 DELETE FROM is not hard and veeery bad
OK. I see the logic.

 Ok, let me ask you something. Why post to itself? You could have a script
 only to do form actions, that way you can:
 1 Separate huge php validations with your html form.
 2 Use functions to handle the incoming data and writing the new query (or
 the old one again).

I suspect that most folk in my position start the learning process by 
finding a script that does a similar task and adapting it. This is basically 
what I've done. I started by finding a form example and then added a 
pagination routine then... Several deadends later... Not the best way to 
write anything but the simplest of scripts. However, the numerous changes to 
the code has entailed lots of learning during the process. So in answer to 
your question. I didn't set out with any idea of the best way to write the 
script. Just a broad idea of what I wanted to end up with.

 As it's built at server side, the user is never going to see your query or
 [1]manipulate it as you're writing it all over again, just using your old
 parameters (they could be added as hidden fields in the form if strictly
 necessary).


 So, as I see it, the pagination links won't POST the form
 variables. How do I pass the 'SELECT * FROM mytable WHERE
 selection=option LIMIT start, range'
 query to the called script?

 You should try building a default query where you only add the parameters
 given by the user. If you can't seem to recover that, add them to 
 $_SESSION
 and you'll be fine next time you want them (if you don't overwrite it 
 =] ).

My query code-

---SQL query construction block
  $query = SELECT * FROM prods ;
  if($catagory != 0){   // 
if category != 0
 $where=WHERE c = $catagory ;
 if ($manu != 0){  // check 
manu != 0
$and = AND m = $manu ;
if ($searchstring != 0){
   $and = $and.AND description LIKE \%$searchstring%\ ; // 
check like != 0
}
 }else{
...
$query=$query.$where.$and.$like

---
Can you please explain your suggestion above in laymans terms. I can't see 
what you have in mind. Is it your suggestion to use one script, containing a 
from, that calls another script that handles my query construction? That far 
I follow you but what happens next?




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



Re: [PHP] Double click problem

2008-03-20 Thread Lamp Lists
- Original Message 
From: Eric Butera [EMAIL PROTECTED]
To: Lamp Lists [EMAIL PROTECTED]
Cc: tedd [EMAIL PROTECTED]; php-general@lists.php.net
Sent: Thursday, March 20, 2008 11:00:19 AM
Subject: Re: [PHP] Double click problem

On Thu, Mar 20, 2008 at 10:39 AM, Lamp Lists [EMAIL PROTECTED] wrote:
 the way I solved the click back button issue (simplified vresion):

  confirmation page (conf.php) - transfer page (tp.php) - thank you page 
 (typ.php)

  #conf.php
  # after the form is submitted and confirmed
  header('location: tp.php?url=typ.php');
  exit;

  #tp.php
  header('location:$_GET['url']);
  exit;

  and, if visitor clicks on back button on thakyou page he will go actually to 
 the transfer page - which will send him back to thankyou page
  ;)

  -ll





  - Original Message 
  From: tedd [EMAIL PROTECTED]
  To: php-general@lists.php.net
  Sent: Wednesday, March 19, 2008 11:43:06 AM
  Subject: Re: [PHP] Double click problem

  At 4:19 PM + 3/19/08, Richard Heyes wrote:
  tedd wrote:
  // ...
  
  Your first (and the quickest by far) method to employ would be to
  disable the submit button using Jabbascript when the form is
  submitted. That will stop the vast majority of occurrences. You
  could also employ an intermediary page which actually does the card
  processing and when complete redirects to the thank you page. ie.
  
  Form -- Please wait... page -- Thank you page

  That's in place. The person clicks the confirm purchase and they
  are taken to a confirm and thank you page.

  The problem here is two fold -- 1) clicking the confirm
  purchasebutton twice, which I think js will stop; 2) and clicking
  the back-button which the token should stop.

  Now, I just need to develop a test for this. Sometime writing a test
  is more of a problem than writing the solution.

  Thanks for everyone's help.

  Cheers,

  tedd


  --
  ---
  http://sperling.com  http://ancientstones.com  http://earthstones.com

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



  
 
  Looking for last minute shopping deals?
  Find them fast with Yahoo! Search.  
 http://tools.search.yahoo.com/newsearch/category.php?category=shopping

Allowing unscrubbed user data in a header is a really bad idea.

- http://en.wikipedia.org/wiki/HTTP_response_splitting
- http://www.owasp.org/index.php/Open_redirect


I agree with you to use exactly this way is bad idea.
But, as I said on the begining of my post it's simplified version, to get my 
point. My code on tp.php actually use sveral validations before forward to 
thank you page :D

-ll


  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

RE: [PHP] newbie question about one php script passing control to another

2008-03-20 Thread admin
Im not sure I understand the question.

Pass control from index.php to welcome.php ???


index.php : ? echo form action=welcome.php method=postinput type=hidden 
name=tagme value=yesinput type=submit value='Continue'/form; ?

welcome.php ? if($_POST['tagme'] == yes){
echo Congrats you are there;}ELSE{echo You failed;}
?

That kind of pass control?



Hello.  I am new to php programming, but have spent many years 
programming in many other languages, most recently perl (with which php 
seems to have much in common!).  In every other language I've worked 
with there is a way for one program to pass control to another.  
However, so far in all of the books and other documentation I've looked 
at for php, I cannot find a way for one php program to pass control to 
another.  Is this possible in php, and, if so, please let me know how.  
Thank you.

Rod Clay
[EMAIL PROTECTED]

-- 
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



[PHP] why use {} around vraiable?

2008-03-20 Thread Lamp Lists
hi,
I saw several times that some people use this
 
$parameters = array(
  'param1' = {$_POST[param1]},
  'param2' = {$_POST[param2]}
 );

or

 $query = mysql_query(SELECT * FROM table1 WHERE id='{$session_id}');

I would use:

$parameters = array(
  'param1' = $_POST[param1],
  'param2' = $_POST[param2]
 );
 
 and

 $query = mysql_query(SELECT * FROM table1 WHERE id=' .$session_id. ' );


does it really matter? is there really difference or these are just two 
styles?

thanks.

-ll


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

Re: [PHP] why use {} around vraiable?

2008-03-20 Thread Robert Cummings

On Thu, 2008-03-20 at 09:22 -0700, Lamp Lists wrote:
 hi,
 I saw several times that some people use this
  
 $parameters = array(
   'param1' = {$_POST[param1]},
   'param2' = {$_POST[param2]}
  );

Ignorance.

 or
 
  $query = mysql_query(SELECT * FROM table1 WHERE id='{$session_id}');

Ignorance/Habit since you only need to do that if the context of the
variable is ambiguous... for instance:

   $something = Something blah $blehblah blah blah.

When what was really wanted was:

   $something = Something blah {$bleh}blah blah blah.

One would hope that in the example you provided the developer properly
escaped $session_id.

 I would use:
 
 $parameters = array(
   'param1' = $_POST[param1],
   'param2' = $_POST[param2]
  );

I sure would too (although I'd use single quotes for the array indices).
I'd also append a dangling , to that last array entry to make it
simplistic to add another entry and never worry about having to add a ,
to the previous entry. The following is perfectly legal in PHP and is an
intentional feature:

$parameters = array
(
'param1' = $_POST['param1'],
'param2' = $_POST['param2'],
);
 
  and
 
  $query = mysql_query(SELECT * FROM table1 WHERE id=' .$session_id.
 ' );

That's broken unless you're relying on a MySQL type conversion trick to
match the session ID since you've prepended and appended the id match
with spaced. You probably meant to type:

SELECT * FROM table1 WHERE id='.$session_id.' 

In that case, I normally do similar for queries, except mine look more
like:

SELECT * FROM table1 WHERE id=.$db-quote( $session_id ). 

Where the quote() method performs both the quoting and the escaping.

 does it really matter? is there really difference or these are just two 
 styles?

It matters greatly if it's incorrect :) Otherwise it matters less so but
one is more efficient than the other. There's absolutely no reason to
interpolate a value if the value is the variable's value itself.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] why use {} around vraiable?

2008-03-20 Thread Jason Pruim


On Mar 20, 2008, at 12:22 PM, Lamp Lists wrote:

hi,
I saw several times that some people use this

$parameters = array(
 'param1' = {$_POST[param1]},
 'param2' = {$_POST[param2]}
);

or

$query = mysql_query(SELECT * FROM table1 WHERE id='{$session_id}');

I would use:

$parameters = array(
 'param1' = $_POST[param1],
 'param2' = $_POST[param2]
);

and

$query = mysql_query(SELECT * FROM table1 WHERE id=' . 
$session_id. ' );



I may have been the one you were talking about so I figured I should  
reply. I picked up the habit doing that for stuff that was being  
displayed using HEREDOC. When I asked for some help awhile back on a  
project I was working on and they said to use HEREDOC, and gave an  
example of how to do it and they had all the variables surrounded with  
{} So I assumed you had to do it that way...


Anyone care to correct me?

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] why use {} around vraiable?

2008-03-20 Thread Nathan Nobbe
On Thu, Mar 20, 2008 at 12:22 PM, Lamp Lists [EMAIL PROTECTED] wrote:

 hi,
 I saw several times that some people use this

 $parameters = array(
  'param1' = {$_POST[param1]},
  'param2' = {$_POST[param2]}
  );

 or

  $query = mysql_query(SELECT * FROM table1 WHERE id='{$session_id}');

 I would use:

 $parameters = array(
  'param1' = $_POST[param1],
  'param2' = $_POST[param2]
  );

  and

  $query = mysql_query(SELECT * FROM table1 WHERE id=' .$session_id. '
 );


 does it really matter? is there really difference or these are just two
 styles?


the short answer is yes.
i think you can find a sufficient explanation here,
http://us.php.net/manual/en/language.types.string.php#language.types.string.parsing.simple
and here
http://us.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex

-nathan


Re: [PHP] newbie question about one php script passing control to another

2008-03-20 Thread Rod Clay
Yes, let me try to say more about exactly what I'm trying to do.  I have 
a php script running in a browser window (opened specifically for this 
purpose) in which the user keys a blog item, then hits 'submit.'  After 
this script has successfully added the new blog item to the database, 
what I'd like to do is automatically close this window, and pass control 
to the php script that displays the updated list of blog items (with of 
course the newly added blog item) in the original browser window (the 
window the user was looking at when s/he clicked on the 'Add a blog' 
link). 


[EMAIL PROTECTED] wrote:

Im not sure I understand the question.

Pass control from index.php to welcome.php ???


index.php : ? echo form action=welcome.php method=postinput type=hidden name=tagme 
value=yesinput type=submit value='Continue'/form; ?

welcome.php ? if($_POST['tagme'] == yes){
echo Congrats you are there;}ELSE{echo You failed;}
?

That kind of pass control?



Hello.  I am new to php programming, but have spent many years 
programming in many other languages, most recently perl (with which php 
seems to have much in common!).  In every other language I've worked 
with there is a way for one program to pass control to another.  
However, so far in all of the books and other documentation I've looked 
at for php, I cannot find a way for one php program to pass control to 
another.  Is this possible in php, and, if so, please let me know how.  
Thank you.


Rod Clay
[EMAIL PROTECTED]

  


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



Re: [PHP] why use {} around vraiable?

2008-03-20 Thread Ray Hauge

Lamp Lists wrote:

hi,
I saw several times that some people use this
 
$parameters = array(

  'param1' = {$_POST[param1]},
  'param2' = {$_POST[param2]}
 );

or

 $query = mysql_query(SELECT * FROM table1 WHERE id='{$session_id}');

I would use:

$parameters = array(
  'param1' = $_POST[param1],
  'param2' = $_POST[param2]
 );
 
 and


 $query = mysql_query(SELECT * FROM table1 WHERE id=' .$session_id. ' );


does it really matter? is there really difference or these are just two 
styles?

thanks.

-ll


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


The brackets are used to enforce that the entire contents between them 
is a variable.  It helps when you're using class members.


$example = this is an {$example-text};

It's also handy when you're putting variables in a heredoc.

I would suggest not using {$_POST[param1]}, like you said.  It's 
just going to make PHP figure out the string, then put the value in that 
string.  If you really wanted to make sure it's a string type then you 
can do (string)$_POST['param1'].


The short answer is you can do it the way you're doing and everything 
will work out just fine :)


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] why use {} around vraiable?

2008-03-20 Thread Robin Vickery
On 20/03/2008, Lamp Lists [EMAIL PROTECTED] wrote:
 hi,
  I saw several times that some people use this

  $parameters = array(
   'param1' = {$_POST[param1]},
   'param2' = {$_POST[param2]}
   );

  or

   $query = mysql_query(SELECT * FROM table1 WHERE id='{$session_id}');

  I would use:

  $parameters = array(
   'param1' = $_POST[param1],
   'param2' = $_POST[param2]
   );

   and

   $query = mysql_query(SELECT * FROM table1 WHERE id=' .$session_id. ' );


  does it really matter? is there really difference or these are just two 
 styles?

yes, it matters when you're trying to include a complex variable

this is a $variable; # ok
this is an $array[12]; # ok
this is an $array[word]; # warning under E_STRICT
this is an $array[two words]; # not ok, can't have whitespace
this is an {$array[two words]}; # not ok, indexes should be quoted
this is an {$array['two words']}; # ok
this is an $object-property; # ok if you're after the property
this is an {$object}-property; # but you need brackets if you want
the object as a string

etc...

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



[PHP] Re: Playing around with strings

2008-03-20 Thread Robin Vickery
On 20/03/2008, Robin Vickery [EMAIL PROTECTED] wrote:
 Hiyah,

  Here's a trick you can use to evaluate expressions within strings. It
  may not be particularly useful, but I thought it was interesting.

  It exploits two things:

  1. If you interpolate an array element within a string, the index of
  the element is evaluated as a php expression.

  2. You can can make your own magic arrays by extending arrayObject.


  ?php
  class identityArrayObject extends arrayObject
  {
   public function offsetGet($index)
   {
 return $index;
   }
  }

  $eval = new identityArrayObject;

  print The square root of {$eval[pow(2,2)]} is {$eval[sqrt(4)]} \n;

  print Price: $price GBP ({$eval[$price * 1.175]} GBP including tax) \n;

  ?

  You can extend it to add your own formatting elements:

  ?php
  class uppercaseArrayObject extends arrayObject
  {
   public function offsetGet($index)
   {
 return strtoupper($index);
   }
  }

  $U = new uppercaseArrayObject;
  $city = 'edinburgh';

  print The capital of Scotland is $U[$city] \n;
  ?


More generic:

?php

class transformArrayObject extends arrayObject
{
  protected $transform;

  public function __construct($transform = null)
  {
$this-transform = is_null($transform) ? array($this, 'identity')
: $transform;
  }

  public function offsetGet($index)
  {
return call_user_func($this-transform, $index);
  }

  public function identity($index)
  {
return $index;
  }
}

$eval = new transformArrayObject;
$U= new transformArrayObject('strtoupper');
$u= new transformArrayObject('ucfirst');
$L= new transformArrayObject('strtolower');
$GBP  = new transformArrayObject(create_function('$index', 'return
money_format(%n, $index);'));

$price = 50;
$tax = 1.175;
$city = 'EdInBurGH';

print A ticket to $U[$city] is: $GBP[$price] ({$GBP[$price * $tax]}
including VAT)\n;
// A ticket to EDINBURGH is: £50.00 (£58.75 including VAT)

?

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



Re: [PHP] why use {} around vraiable?

2008-03-20 Thread Brady Mitchell


On Mar 20, 2008, at 922AM, Lamp Lists wrote:

$query = mysql_query(SELECT * FROM table1 WHERE id='{$session_id}');


For a non-array value, the curly braces are unnecessary:
$query = mysql_query(SELECT * FROM table1 WHERE id='$session_id')

WIth an array element, you have to either use the curly braces or do  
as you have and end the string, concat the value and start the string  
again as needed.

$query = mysql_query(SELECT * FROM table1 WHERE id='{$clean['id']}')

When dealing with array elements, I use the curly braces method. IMO  
it's cleaner and easier to read.



I would use:

$parameters = array(
 'param1' = $_POST[param1],
 'param2' = $_POST[param2]
);


This is how I do it as well.

does it really matter? is there really difference or these are just  
two styles?


IMO, it's a matter of preference and style. There may be performance  
differences between the two, but I doubt that either one is so much  
worse than the other that it would have a noticeable impact on your  
script in most situations.


Brady

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



Re: [PHP] why use {} around vraiable?

2008-03-20 Thread Lamp Lists
- Original Message 
From: Nathan Nobbe [EMAIL PROTECTED]
To: Lamp Lists [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Thursday, March 20, 2008 11:35:42 AM
Subject: Re: [PHP] why use {} around vraiable?

On Thu, Mar 20, 2008 at 12:22 PM, Lamp Lists [EMAIL PROTECTED] wrote:

 hi,
 I saw several times that some people use this

 $parameters = array(
  'param1' = {$_POST[param1]},
  'param2' = {$_POST[param2]}
  );

 or

  $query = mysql_query(SELECT * FROM table1 WHERE id='{$session_id}');

 I would use:

 $parameters = array(
  'param1' = $_POST[param1],
  'param2' = $_POST[param2]
  );

  and

  $query = mysql_query(SELECT * FROM table1 WHERE id=' .$session_id. '
 );


 does it really matter? is there really difference or these are just two
 styles?


the short answer is yes.
i think you can find a sufficient explanation here,
http://us.php.net/manual/en/language.types.string.php#language.types.string.parsing.simple
and here
http://us.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex

-nathan



ok. I got it.
actually, my question was about: these two examples

$fruits = array('strawberry' = 'red', 'banana' = 'yellow');
echo A banana is {$fruits['banana']}.;
echo A banana is  . $fruits['banana'] . .;

are the same.

Though, learned few more other things too :D

Thanks guys.

-ll


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

[PHP] Re: selling gpl software?

2008-03-20 Thread Colin Guthrie
Larry Garfield wrote:
 If the code is work for hire and the initial ownership is with the 
 client/company, then there is no distribution and so you are not required to 
 do anything.  That includes if you are a full time employee of the company.

OK, that's more or less my understanding.

It is my understanding that, by default, contracting law states that any
work done under contract is your (the contractor's) copyright (e.g. on a
very loose contract that is the default case). Many employers of
contractors will typically change this default stance.

 So in the OP's case, if he takes an existing GPLed project, modifies it in 
 whatever way (including removing mention of the original project), and gives 
 a copy to his client, his only legal obligation is to provide the client with 
 the code under the GPL so that the client can, if he wants, pass the code on 
 to someone else under the GPL.  Someone else could be a public FTP server 
 or not.

I was half assuming the stance of the employer here was that he did not
want the changes shared.

So assuming this and the above note about contract law etc., then my
original statement is correct.

Whether these assumptions are correct in themselves (and this my whole
thread of assumption breaks down!), I'll leave for future research and
happily live in my bubble of ignorance ;)

Col



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



Re: [PHP] newbie question about one php script passing control to another

2008-03-20 Thread Daniel Brown
On Thu, Mar 20, 2008 at 12:37 PM, Rod Clay [EMAIL PROTECTED] wrote:
 Yes, let me try to say more about exactly what I'm trying to do.  I have
  a php script running in a browser window (opened specifically for this
  purpose) in which the user keys a blog item, then hits 'submit.'  After
  this script has successfully added the new blog item to the database,
  what I'd like to do is automatically close this window, and pass control
  to the php script that displays the updated list of blog items (with of
  course the newly added blog item) in the original browser window (the
  window the user was looking at when s/he clicked on the 'Add a blog'
  link).

That would be more of a JavaScript issue, really.  Have the user
click a link to refresh the parent and close the child.

On a different note, you probably got made fun of pretty often for
you name (especially last-name-first), eh?  My father's name was Dick
--- no joke.  Yeah he got hell all the time.  ;-P

-- 
/Daniel P. Brown
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283

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



Re: [PHP] Newbie question, Which way is best?

2008-03-20 Thread Shawn McKenzie
George J wrote:
 Thiago Pojda [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 De: George J [mailto:[EMAIL PROTECTED]

 So calling the script via the form works i.e it passes the
 neccessary variables to constrct the sql query for the next
 call.
 As Shawn said, if you really need the query again add it to session, 
 never,
 NEVER give the user the ability to see/execute queries by himself 
 (remember
 POST data could be easily manipulated). Remember what Daniel said, adding 
 a
 DELETE FROM is not hard and veeery bad
 OK. I see the logic.
 
 Ok, let me ask you something. Why post to itself? You could have a script
 only to do form actions, that way you can:
 1 Separate huge php validations with your html form.
 2 Use functions to handle the incoming data and writing the new query (or
 the old one again).
 
 I suspect that most folk in my position start the learning process by 
 finding a script that does a similar task and adapting it. This is basically 
 what I've done. I started by finding a form example and then added a 
 pagination routine then... Several deadends later... Not the best way to 
 write anything but the simplest of scripts. However, the numerous changes to 
 the code has entailed lots of learning during the process. So in answer to 
 your question. I didn't set out with any idea of the best way to write the 
 script. Just a broad idea of what I wanted to end up with.
 
 As it's built at server side, the user is never going to see your query or
 [1]manipulate it as you're writing it all over again, just using your old
 parameters (they could be added as hidden fields in the form if strictly
 necessary).


 So, as I see it, the pagination links won't POST the form
 variables. How do I pass the 'SELECT * FROM mytable WHERE
 selection=option LIMIT start, range'
 query to the called script?
 You should try building a default query where you only add the parameters
 given by the user. If you can't seem to recover that, add them to 
 $_SESSION
 and you'll be fine next time you want them (if you don't overwrite it 
 =] ).

 My query code-
 
 ---SQL query construction block
   $query = SELECT * FROM prods ;
   if($catagory != 0){   // 
 if category != 0
  $where=WHERE c = $catagory ;
  if ($manu != 0){  // check 
 manu != 0
 $and = AND m = $manu ;
 if ($searchstring != 0){
$and = $and.AND description LIKE \%$searchstring%\ ; // 
 check like != 0
 }
  }else{
 ...
 $query=$query.$where.$and.$like
 
 ---
 Can you please explain your suggestion above in laymans terms. I can't see 
 what you have in mind. Is it your suggestion to use one script, containing a 
 from, that calls another script that handles my query construction? That far 
 I follow you but what happens next?
 
 
 
What file is this?  is the pagination code in this file also?  If not
where?  Post you pagination code and this is a simple explanation.

Build your query as you've done and stick it in a session var.  It is
now available to future calls to this page or other pages.

-Shawn

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



Re: [PHP] Newbie question, Which way is best?

2008-03-20 Thread George J
Hi Shawn,

 My query code-

 ---SQL query construction block
   $query = SELECT * FROM prods ;
   if($catagory != 0){ 
 //
 if category != 0
  $where=WHERE c = $catagory ;
  if ($manu != 0){  // 
 check
 manu != 0
 $and = AND m = $manu ;
 if ($searchstring != 0){
$and = $and.AND description LIKE \%$searchstring%\ ; 
 //
 check like != 0
 }
  }else{
 ...
 $query=$query.$where.$and.$like

 ---
 Can you please explain your suggestion above in laymans terms. I can't 
 see
 what you have in mind. Is it your suggestion to use one script, 
 containing a
 from, that calls another script that handles my query construction? That 
 far
 I follow you but what happens next?



 What file is this?  is the pagination code in this file also?  If not
 where?  Post you pagination code and this is a simple explanation.

 Build your query as you've done and stick it in a session var.  It is
 now available to future calls to this page or other pages.

 -Shawn

The above code was included in post to show how query is constructed.

Heres my pagination code.
---
if($page  1){ // if number of pages  1 then display 'Previous' button
$pageprev = $page-1;
   echo(a href=\display_products.php?page=$pageprev\img 
src=\btnprevenabled.gif\ ALT=\Previous\ border=\0\ /a );
}else{
echo(img src=\btnprevdisnabled.gif\ ALT=\Previous\border=\0\ 
  );
}
//
$numpages = $totalrows / $show; //$show holds number of items to display per 
page
// display a button for each page with current page showing disabled button
for($i = 1; $i = $numpages; $i++){
   $str1=btn_;
   $str2=$i;
if($i == $page){
 $str3=$str1.$str2.disabled.gif;
  echo(img src=$str3 border=\0\ );
}else{
 $str3=$str1.$str2._enabled.gif;
echo(a href=\displayproducts.php?page=$i\img src=$str3 
border=\0\ /a );
 }
}
// if last page is less than full
if(($totalrows % $show) != 0){
   $str2=$i;
  if($i == $page){
 $str3=$str1.$str2.disabled.gif;
  echo(img src=$str3 border=\0\ );//$i );
}else{
 $str3=$str1.$str2.enabled.gif;
  echo(a href=\displayproducts.php?page=$i\img src=$str3 
border=\0\ /a );//$i/a );
}
}
// Display the enabled or disabled 'Next' button
if(($totalrows - ($show * $page))  0){
  //$str3=$str1.$str2.disabled.gif;
$pagenext =$page+1;
echo(a href=\displayproducts.php?page=$pagenext\img 
src=\btnnextenabled.gif\ border=\0\ /a);//$i/a );
}else{
   $pagenext =$page+1;
echo(img src=\btnnextdisabled.gif\ ALT=\Next\border=\0\  
);
}
?
/td/font/tr/table
---

Thanks for sticking with me.

George



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



Re: [PHP] newbie question about one php script passing control to another

2008-03-20 Thread Rick Pasotto
On Thu, Mar 20, 2008 at 12:08:39PM -0400, Rod Clay wrote:
 Hello.  I am new to php programming, but have spent many years
 programming in many other languages, most recently perl (with which
 php  seems to have much in common!).  In every other language I've
 worked  with there is a way for one program to pass control to
 another.   However, so far in all of the books and other documentation
 I've looked  at for php, I cannot find a way for one php program to
 pass control to  another.  Is this possible in php, and, if so, please
 let me know how.   Thank you.

This may be what you are looking for:

include('next_program');
exit();

If you do this, you have to keep in mind that all the variables you set
in the first program are *still* set in the second.

This is useful when your first program needs to choose which of two or
more programs to run next depending on its calculations. For example, if
your first program does error checking then it might want to run an
all_ok program or an edit program.

-- 
To be without a plan is the true genius and glory of the antislavery
 movement. The mission of that movement is to preach eternal truths, and
 to  bear witness to everlasting testimony against the giant falsehoods
 which bewitch and enslave the land. -- Nathaniel Peabody Rogers
Rick Pasotto[EMAIL PROTECTED]http://www.niof.net

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



Re: [PHP] newbie question about one php script passing control to another

2008-03-20 Thread tedd

At 12:08 PM -0400 3/20/08, Rod Clay wrote:
Hello.  I am new to php programming, but have spent many years 
programming in many other languages, most recently perl (with which 
php seems to have much in common!).  In every other language I've 
worked with there is a way for one program to pass control to 
another.  However, so far in all of the books and other 
documentation I've looked at for php, I cannot find a way for one 
php program to pass control to another.  Is this possible in php, 
and, if so, please let me know how.  Thank you.


Rod Clay
[EMAIL PROTECTED]


Rod:

If what you mean is one program to launch another, then look at this:

http://webbytedd.com/bb/php-run-php/

If you want to pass variables, there's several ways to do that -- 
but, that's a different question.


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Newbie question, Which way is best?

2008-03-20 Thread Philip Thompson

On Mar 20, 2008, at 12:05 PM, George Jamieson wrote:


Hi Philip,

Hope you don't mind me sending this to you direct. Thanks for the  
answer

but... I'm sorry I don't follow you.

My form sets up the query parameters. It works.

My pagination code passes the page no. It works.

What it doesn't do is provide the next execution of my script with the
query. I pass the page no. but how do I either use the same query  
but with
new LIMIT parameters or reconstruct the entire query with the new  
LIMIT.


My form gives the user options to search by manufacturer, gategory  
or search
string. sorted by description, finish or price. I've just added a  
drop down

box for number of items to be displayed at a time.

I want to use my pagination script to scroll, page by page, through  
the
resultset. So if I call my script again, with the new page number, I  
have no
way of reusing the same query as the user is not required to rePOST  
the form

with its parameters.

I can't see how your code allows me to do that.


Because I increment the page count ($page) each time... So, each time  
you hit Go, then it finds the next page. Of course, this is not really  
made for production - you would want to find a more user-friendly way  
to accomplish showing a result set.


You could change it up to use _GET instead:

a href=thispage.php?page=3Go to Page 3/a

Then modify your PHP code to accept _GET values along with/instead of  
_POST values:


?php
if (isset ($_POST['submitted']) || !empty ($_GET['page'])) {
$page = $_POST['page'] ? (int) $_POST['page'] : (int)  
$_GET['page'];

...
}
?

I feel like we've explained this fairly well, but you may not  
completely understand. Let us know if we need to break it down a  
little bit more. We would be happy to point you to some materials that  
can assist you.


~Philip



Regards
George


to the called script?


George


I don't know if anyone has answered the question you have asked at
least twice... How do I pass the query to the next page? Here's how
I would approach it. Don't pass the query - all you need is the page
number. This code hasn't been tested, but I think you'll get the  
idea.


?php
// thispage.php
if (isset ($_POST['submitted'])) {
$resultsPerPage = 50; // or whatever value
$page = mysql_real_escape_string ($_POST['page']);

$start = ($page * $resultsPerPage) - $resultsPerPage;
$length = $start + $resultsPerPage;

// Notice how you don't send the query in the POST or GET, just
the page number
$sql = SELECT `field` FROM `table` WHERE (`field_a` =
'someValue') LIMIT $start, $length;
$results = mysql_query ($sql);
}

// Go to next page
$page = $_POST['page'] ? (int) $_POST['page'] + 1 : 1;
?
...
form method=post action=thispage.php
input type=submit value=Go /
input type=hidden name=page value=?php echo htmlentities
($page); ? /
input type=hidden name=submitted value=1 /
/form
...

?php
while ($row = mysql_fetch_array ($results, MYSQL_ASSOC)) {
// Display results
}
?


Hopefully that helps a little bit.

~Philip


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



[PHP] MCrypt not decrypting simple text

2008-03-20 Thread Dan
I'm using MCrypt and I have two very simple functions.  All I'm doing is 
giving the function some text and a password, it encrypts the text and saves 
it as a text file on the server.  Then I at some later time run another php 
file which decrypts using the decrypt function given the text and the SAME 
password as the first time and all I get is garbage.  What am I doing wrong? 
What do I need to change so that I can get this to work the way I described?


function aes_128_encrypt($text,$password) {

  $size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
   $iv = mcrypt_create_iv($size, MCRYPT_DEV_RANDOM);

   $text .= chr(3).chr(3).chr(3);

   return bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $password, $text, 
MCRYPT_MODE_ECB, $iv));


} // End of function

and

function aes_128_decrypt($encrypted_text,$password) {

   $size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
   $iv = mcrypt_create_iv($size, MCRYPT_DEV_RANDOM);

   return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $password, pack(H*, 
$encrypted_text), MCRYPT_MODE_ECB, $iv);


} // End of function


- Dan 



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



[PHP] Convert html to pdf with php

2008-03-20 Thread Robert Burdo
Does anyone know how to convert an HTML form to a pdf with php?

-- 
Robert Burdo
nuschooldesign.com


[PHP] question about customized error

2008-03-20 Thread Sudhakar
if a user by mistake types the wrong url directly in the address bar ex=
www.website.com/abou.php instead of
typing www.website.com/aboutus.php instead of the browser displaying File
not found or a 404 error message i would like to display a customized page
which will still have the same look and feel of my website in terms of the
layout and i would like to
a) display a message such as = Page could not be found and b) the url that
the user originally typed should remain in the browser = I guess this would
be the case anyway but i was wondering if something needs to be done in
order to reatin the original address the user typed.

Does this have to be done from apache perspective or can it be done using
php. please suggest the procedure in either case apache OR php.

please advice.

thanks.


Re: [PHP] Convert html to pdf with php

2008-03-20 Thread Philip Thompson

On Mar 20, 2008, at 4:42 PM, Robert Burdo wrote:

Does anyone know how to convert an HTML form to a pdf with php?



Have you STFW?  =D  http://www.google.com/search?q=php+html+to+pdf

I use dompdf. Unfortunately, the guy who created it isn't intending to  
upgrade it. Nonetheless, for most things, it does a good job - just  
send it the HTML.


I've also use fpdf before. If you really want to draw out the PDF  
yourself, this is the way to go. It's kinda tedious for me.


~Philip

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



Re: [PHP] Convert html to pdf with php

2008-03-20 Thread Al

I think Imagemagick will do it.

Philip Thompson wrote:

On Mar 20, 2008, at 4:42 PM, Robert Burdo wrote:

Does anyone know how to convert an HTML form to a pdf with php?



Have you STFW?  =D  http://www.google.com/search?q=php+html+to+pdf

I use dompdf. Unfortunately, the guy who created it isn't intending to 
upgrade it. Nonetheless, for most things, it does a good job - just send 
it the HTML.


I've also use fpdf before. If you really want to draw out the PDF 
yourself, this is the way to go. It's kinda tedious for me.


~Philip


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



Re: [PHP] question about customized error

2008-03-20 Thread Jim Lucas

Sudhakar wrote:

if a user by mistake types the wrong url directly in the address bar ex=
www.website.com/abou.php instead of
typing www.website.com/aboutus.php instead of the browser displaying File
not found or a 404 error message i would like to display a customized page
which will still have the same look and feel of my website in terms of the
layout and i would like to
a) display a message such as = Page could not be found and b) the url that
the user originally typed should remain in the browser = I guess this would
be the case anyway but i was wondering if something needs to be done in
order to reatin the original address the user typed.

Does this have to be done from apache perspective or can it be done using
php. please suggest the procedure in either case apache OR php.


Both will be involed.

You will use what is referred to as the ErrorDocument entry.

Have apache enforce a customer ErrorDocument for a 404 error.

Then create a php script that is referred to by the ErrorDocument entry.

error404.php

?php

echo Page not found, check your spelling and try again.;

?



please advice.

thanks.




--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] Re: fwrite/fclose troubles

2008-03-20 Thread Mark Weaver

Peter Ford wrote:

Mark Weaver wrote:

Hi all,

I've been lurking and reading now for some time, but have decided to
come out of the shadows cause I've got an issue that's gonna drive me 
crazy!


I'm developing an application and within this application is a class
that is very simple and only serves a singular purpose - to make log
entries to help with debugging. Problem is, now I'm debugging the damned
logging class that is supposed to be helping me debug the application as
I'm putting it together! sigh I've looked and looked all over the
place, but I don't seem to be able to find an answer to this problem.
The only information that I have found so far deals with permissions and
I don't think that's the problem. At first I was getting an access
denied error but since setting dir perms and log file perms so that both
apache and my user can right to both the directory and the file that one
has gone away.

Log Directory permissions: /mystuff/logs  rwx-rwx-rwx 
(777)

Log file permissions: /mystuff/logs/run.log   rwx-rwx-rwx
(777)

At any rate, the following is the information I'm getting in the apache
error_log while working on this particular portion of the application:

PHP Warning:  fwrite(): supplied argument is not a valid stream resource
in /mystuff/inc/Log.inc on line 22,
PHP Warning:  fclose(): supplied argument is not a valid stream resource
in /mystuff/inc/Log.inc on line 23,

The Log class:
-
class Log{
public $path, $entry, $logfile;
public function Log(){}
public function setLog($path,$file){
$this-path = $path;
$this-logfile = $file;
}
public function writeLog($entry){
// open the file, in this case the log file
$h = $this-path/$this-logfile;
fopen($h, 'a+');
fwrite($h,$entry);
fclose($h);
}
}

Code snippet where attempting to write log entry from program:
 


$pl_log = new Log;
$pl_log-setLog($logpath,run.log);
   $usernanme = $_POST['username'];
$password = $_POST['secret'];
   /**
   * (debugging) logging incoming values from form:
   */
$pl_log-writeLog(getDateTime(): Incoming values from Login 
Form:

blah...blah...blah\n);

Any help with this would be most appreciated. (be gentle... I'm a PERL
program learning PHP OOP)




As Stut pointed out, you've misunderstood the difference between a file 
resource and a file name.


Try something like:


 public function writeLog($entry)
 {
 // open the file, in this case the log file
 $fileName = $this-path.'/'.$this-logfile;
 $h = fopen($fileName, 'a+');
 fwrite($h,$entry);
 fclose($h);
 }

The file resource that fwrite and fclose need is the *result* of opening 
the file, not the file name as you were doing.
Ideally, you would check the value of $h after the fopen call, to make 
sure that it had successfully opened the file.


Also, I changed the way you were constructing the file name: 
interpolating the variables in a string is slightly less efficient than 
concatenating the bits together, and there are possible gotchas when 
using the $this-variable structure in a string like that.

An alternative syntax is to escape the variables with braces:

$fileName = {$this-path}/{$this-logfile};


Hi Peter,

Thank you for that information. I'm rather new at this sort of PHP 
coding and a bit embarrassed at the amount of OOP I've forgotten since 
college. Clearly there's a lot to learn. Like this concept of escaping 
you've mentioned. Until now the only type of escaping I'm familiar 
with from PERL is something like this: \$$some_dollar_amount, but I have 
 a feeling escaping things in PHP oop is quite a bit different. I 
haven't quite gotten my head around some of the stuff I've been reading 
about, but it's coming.


--
Mark

If you have found a very wise man, then you've found a man that at one 
time was an idiot and lived long enough to learn from his own stupidity.

==
Powered by CentOS5 (RHEL5)

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



Re: [PHP] Will the progress bar like Xupload add too much weight to the Apache server?

2008-03-20 Thread Shelley
Sorry. I won't. :(

On Thu, Mar 20, 2008 at 11:01 PM, Daniel Brown [EMAIL PROTECTED] wrote:

 On Thu, Mar 20, 2008 at 2:32 AM, Shelley [EMAIL PROTECTED] wrote:
  Hi all,
 
   Here is the Xupload progress bar link:
   http://www.sibsoft.net/xupload.html
 
   My question is:
   Will the upload progress bar like that add too much weight to the
 Apache
   server, especially to a server with millions of visitors each day?

 You consistently ask irrelevant questions here.  Not only is
 Xupload not written in PHP, your question relates to Perl and Apache
 --- not at all to PHP.

Please select the correct list when asking questions.

 --
 /Daniel P. Brown
 Forensic Services, Senior Unix Engineer
 1+ (570-) 362-0283




-- 
Regards,
Shelley