php-general Digest 5 Oct 2004 12:52:07 -0000 Issue 3035
Topics (messages 198630 through 198659):
something wrong with $_SERVER var
198630 by: Merlin
198632 by: Chuck Wolber
Re: Best and easy html text area replacement tool?
198631 by: Greg Donald
198646 by: Warren Vail
email templating system
198633 by: adwinwijaya
198634 by: John Holmes
198635 by: adwinwijaya
198637 by: John Holmes
198639 by: adwinwijaya
returning values/information from perl apps to php apps..
198636 by: bruce
198638 by: John Holmes
198641 by: bruce
198642 by: Randy J. Ray
Memory Usage
198640 by: Juan Pablo Herrera
Re: Recursive Interpolation
198643 by: Chuck Wolber
198645 by: Michael Sims
198648 by: Chuck Wolber
[Newbie Guide] For the benefit of new members
198644 by: Gnanavel
Help needed Postgresql and PHP
198647 by: suma parakala
198649 by: Warren Vail
validate a tag
198650 by: Pahlevanzadeh Mohsen
Math problem with modulus
198651 by: Christoph Schwadorf
198656 by: M. Sokolewicz
checkbox arrays and validation
198652 by: Angelo Zanetti
198653 by: Ford, Mike
198654 by: John Holmes
198655 by: Marek Kilimajer
198657 by: Angelo Zanetti
198658 by: Marek Kilimajer
198659 by: Angelo Zanetti
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Hi there,
I am experiencing a strange behaviour with $_SERVER vars.
Somehow the var: $_SERVER[SERVER_PORT] seems to be 443 even if
it is 80. I had following statement inside my app:
if ($_SERVER[SERVER_PORT] == '443' AND !$SSL){
header("Location:http://".$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI]);
exit;
}
This was to redirect ssl url to standard protocol (due to relative links on the
page).
Some users with IE could not load any pages anymore (ssl was disabled). The
normal url was not loadable and only a white screen showed up. Did not happen
with firefox most of the time. But why?? The server port was not 443 so the
statemetn could never become true?!
Any ideas? I am lost :-(
Merlin
--- End Message ---
--- Begin Message ---
On Tue, 5 Oct 2004, Merlin wrote:
> I am experiencing a strange behaviour with $_SERVER vars.
> Somehow the var: $_SERVER[SERVER_PORT] seems to be 443 even if
> it is 80. I had following statement inside my app:
>
> if ($_SERVER[SERVER_PORT] == '443' AND !$SSL){
> header("Location:http://".$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI]);
> exit;
> }
You can start by putting a space between the "Location:" and the rest of
your URL.
-Chuck
--
http://www.quantumlinux.com
Quantum Linux Laboratories, LLC.
ACCELERATING Business with Open Technology
"The measure of the restoration lies in the extent to which we apply
social values more noble than mere monetary profit." - FDR
--- End Message ---
--- Begin Message ---
On Mon, 4 Oct 2004 16:50:17 -0400, Bosky, Dave <[EMAIL PROTECTED]> wrote:
> I'm looking for an easy to use html textarea replacement script and figured
> this was the place to locate the most popular.
What is a "html textarea replacement script" ?
I could be wrong but it sounds like javascript, not PHP.
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
--- End Message ---
--- Begin Message ---
I guess I have no patience with the "topic police" since it's difficult to
develop a good PHP "user interface" without the use of JavaScript, and I
consider anything that involves getting the most out of PHP "on topic", but
since I'm in charge of absolutely nothing, all I can do is provide a little
information.
I've actually used a couple of these JavaScript add-on's and like the
structure and reliability of HTMLAREA.
http://www.interactivetools.com/products/htmlarea/
It provides a nice plug-in interface that other developers have used to make
JavaScript extensions available that includes;
* Image Upload Manager
* Spell Checking (On a Unix/Linux host)
* Enhanced Table Formatting
* Multiple Language Capability (haven't look too close at this one)
* Even something for Audio (haven't looked at this, either)
* And probably some that I haven't mentioned (doing this from memory).
And the price is the same as PHP (free).
Good luck,
Warren Vail
-----Original Message-----
From: Bosky, Dave [mailto:[EMAIL PROTECTED]
Sent: Monday, October 04, 2004 1:50 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Best and easy html text area replacement tool?
I'm looking for an easy to use html textarea replacement script and figured
this was the place to locate the most popular.
Thanks,
Dave
HTC Disclaimer: The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader of this
message is not the intended recipient, or an employee or agent responsible
for delivering this message to the intended recipient, you are hereby
notified that any dissemination, distribution or copying of this
communication is strictly prohibited. If you have received this
communication in error, please notify us immediately by replying to the
message and deleting it from your computer. Thank you.
--- End Message ---
--- Begin Message ---
Hello php-general,
Currently I use Smarty for page templating system, and I am happy with
this. But is there any way to produce a file with smarty instead of
displaying it as a page.
I want to use this as email templating, I want to create an email and
I have a template like smarty and I want to assign it just like
smarty. Is there any templating system that suitable for me ?
Example:
[email.tpl]
Hello {$user},
Welcome to {$name_of_web}
regards,
{$system_administrator}
[email.php]
$email->assign('user', $user);
$email->assign('system_administrator', $system_administrator);
$email->assign('name_of_web', $name_of_web);
$email->send('/templates/email.tpl') ;
--
Best regards,
adwin
--- End Message ---
--- Begin Message ---
adwinwijaya wrote:
Hello php-general,
Currently I use Smarty for page templating system, and I am happy with
this. But is there any way to produce a file with smarty instead of
displaying it as a page.
I want to use this as email templating, I want to create an email and
I have a template like smarty and I want to assign it just like
smarty. Is there any templating system that suitable for me ?
Example:
[email.tpl]
Hello {$user},
Welcome to {$name_of_web}
regards,
{$system_administrator}
[email.php]
$email->assign('user', $user);
$email->assign('system_administrator', $system_administrator);
$email->assign('name_of_web', $name_of_web);
$message = $email->fetch('/templates/email.tpl');
mail($to,$subject,$message);
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Hello John,
Tuesday, October 5, 2004, 11:43:34 AM, you wrote:
JH> X-Apparently-To: [EMAIL PROTECTED] via
JH> 216.109.117.233; Mon, 04 Oct 2004 18:44:39 -0700
JH> X-Originating-IP: [216.92.131.4]
JH> Return-Path:
JH> <[EMAIL PROTECTED]>
JH> Received: from 216.92.131.4 (HELO pb1.pair.com) (216.92.131.4)
JH> by mta127.mail.sc5.yahoo.com with SMTP; Mon, 04 Oct 2004 18:44:39 -0700
JH> Received: (qmail 77197 invoked by uid 1010); 5 Oct 2004 01:44:21 -0000
JH> Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
JH> Precedence: bulk
JH> list-help: <mailto:[EMAIL PROTECTED]>
JH> list-unsubscribe: <mailto:[EMAIL PROTECTED]>
JH> list-post: <mailto:[EMAIL PROTECTED]>
JH> Delivered-To: mailing list [EMAIL PROTECTED]
JH> Received: (qmail 77146 invoked by uid 1010); 5 Oct 2004 01:44:21 -0000
JH> Delivered-To: [EMAIL PROTECTED]
JH> Delivered-To: [EMAIL PROTECTED]
JH> X-Ironport-AV: i="3.85,122,1094443200";
JH> d="scan'208"; a="380869305:sNHT13028200"
JH> Message-ID: <[EMAIL PROTECTED]>
JH> Date: Mon, 04 Oct 2004 21:43:34 -0400
JH> From: John Holmes <[EMAIL PROTECTED]>
JH> User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803)
JH> X-Accept-Language: en-us, en
JH> MIME-Version: 1.0
JH> To: adwinwijaya <[EMAIL PROTECTED]>
JH> CC: [EMAIL PROTECTED]
JH> References: <[EMAIL PROTECTED]>
JH> In-Reply-To: <[EMAIL PROTECTED]>
JH> Content-Type: text/plain; charset=windows-1252; format=flowed
JH> Content-Transfer-Encoding: 8bit
JH> Subject: Re: [PHP] email templating system
JH> adwinwijaya wrote:
>> Hello php-general,
>>
>> Currently I use Smarty for page templating system, and I am happy with
>> this. But is there any way to produce a file with smarty instead of
>> displaying it as a page.
>>
>> I want to use this as email templating, I want to create an email and
>> I have a template like smarty and I want to assign it just like
>> smarty. Is there any templating system that suitable for me ?
>>
>>
>> Example:
>> [email.tpl]
>>
>> Hello {$user},
>>
>> Welcome to {$name_of_web}
>>
>> regards,
>> {$system_administrator}
>>
>> [email.php]
>>
>> $email->assign('user', $user);
>> $email->assign('system_administrator', $system_administrator);
>> $email->assign('name_of_web', $name_of_web);
$message = $email->>fetch('/templates/email.tpl');
JH> mail($to,$subject,$message);
no, This is not what I mean. I know about mail() function.
I just want to create email, but I want it like smarty, have if, for
etc in the email template.
--
Best regards,
adwin
--- End Message ---
--- Begin Message ---
adwinwijaya wrote:
$message = $email->>fetch('/templates/email.tpl');
JH> mail($to,$subject,$message);
no, This is not what I mean. I know about mail() function.
I just want to create email, but I want it like smarty, have if, for
etc in the email template.
Yes, that is what you mean. fetch() is going to parse the smarty "email"
template (where you have your IF, FOR, smarty variables, etc) and return
the parsed template to you. Then you stick that into mail().
If you want to use $email->send(), then you'll have to modify the smarty
class or write a class that extends smarty and implements the send()
method.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Hello John,
Tuesday, October 5, 2004, 11:59:19 AM, you wrote:
JH> Yes, that is what you mean. fetch() is going to parse the smarty "email"
JH> template (where you have your IF, FOR, smarty variables, etc) and return
JH> the parsed template to you. Then you stick that into mail().
JH> If you want to use $email->send(), then you'll have to modify the smarty
JH> class or write a class that extends smarty and implements the send()
JH> method.
Oh .. that's right John, I just know that smarty has fetch() method :(
... thanks for your help :)
--
Best regards,
adwin
--- End Message ---
--- Begin Message ---
hi...
i'm trying to return values/information from a perl app to a php app. what's
the best way??
foo.php
blah....
res = system(dog.pl)
.
.
-----------
dog.pl
$vars....
.
.
.
------------------
the issue i'm having is that perl only seems to allow an app to have an
'exit' value of a short int. i need to return values that might be multiple
arrarys. should i simply write the perl return values into an output file,
and read the output vars from the output file in the php file...
comments/thoughts/etc....
thanks....
-bruce
--- End Message ---
--- Begin Message ---
bruce wrote:
i'm trying to return values/information from a perl app to a php app. what's
the best way??
[snip]
the issue i'm having is that perl only seems to allow an app to have an
'exit' value of a short int. i need to return values that might be multiple
arrarys. should i simply write the perl return values into an output file,
and read the output vars from the output file in the php file...
There are some notes on the apache_note() manual page that suggest it
could be useful. Perhaps you could put a serialized value into an apache
note in Perl and then retrieve it in PHP?
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
eric...
how does using serialize allow the information from the perl app to be used
by the php parent app. unless you're implying that the serialized
information is stored in an external file, that's then read by the php
calling/parent app...
-bruce
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
Eric Germann
Sent: Monday, October 04, 2004 7:49 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: returning values/information from perl apps to php apps..
Php::serialize
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
bruce
Sent: Monday, October 04, 2004 9:55 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: returning values/information from perl apps to php apps..
hi...
i'm trying to return values/information from a perl app to a php app. what's
the best way??
foo.php
blah....
res = system(dog.pl)
.
.
-----------
dog.pl
$vars....
.
.
.
------------------
the issue i'm having is that perl only seems to allow an app to have an
'exit' value of a short int. i need to return values that might be multiple
arrarys. should i simply write the perl return values into an output file,
and read the output vars from the output file in the php file...
comments/thoughts/etc....
thanks....
-bruce
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--- End Message ---
--- Begin Message ---
the issue i'm having is that perl only seems to allow an app to have an
'exit' value of a short int. i need to return values that might be multiple
arrarys. should i simply write the perl return values into an output file,
and read the output vars from the output file in the php file...
I believe that PHP has facilities for executing external processes and saving
the text of the output (I've done just a sprinkling of PHP, so I'm limited
there). But if that is the case, there is nothing preventing you from having
the Perl application print out the desired data in a structured format
(comma-separated values, tab-separated, or even mock-XML) and having the PHP
then parse it. Indeed, if you output it as XML, I believe that PHP has classes
built-in that would allow you to effectively go straight to having a DOM
representation of the data.
Randy
--
[EMAIL PROTECTED] http://www.rjray.org http://www.svsm.org
Always code as if the guy who ends up maintaining your code will be a violent
psychopath who knows where you live. -- Rick Osborne
--- End Message ---
--- Begin Message ---
Hi!
I need management the use of the memory when a php script is execute. How
can i do it?.I know mysql_free_result for free all memory associated with the result,
is it all?.
Regards,
JP
--- End Message ---
--- Begin Message ---
On Mon, 4 Oct 2004, Chuck Wolber wrote:
> Database *FIELD* with text data in it. The text data contains sentences
> interspersed with $foo['bar'] array variables. The idea is that when one
> selects this field, PHP will interpolate $foo['bar'] with the currently
> defined $foo array variable. This allows for "form letter" like
> dispatches to be created.
The method I've come up with in the meantime, I believe is much more
effective than heredocs, but still an ugly hack:
function interpolate ($text, $msg_variable) {
$msg_key = '_FP_VAR_';
foreach (array_keys($msg_variable) as $key) {
$token = $msg_key.$key;
$text = preg_replace("/$token/", "$msg_variable[$key]", $text);
}
return ($text);
}
--
http://www.quantumlinux.com
Quantum Linux Laboratories, LLC.
ACCELERATING Business with Open Technology
"The measure of the restoration lies in the extent to which we apply
social values more noble than mere monetary profit." - FDR
--- End Message ---
--- Begin Message ---
Chuck Wolber wrote:
> The method I've come up with in the meantime, I believe is much more
> effective than heredocs, but still an ugly hack:
>
> function interpolate ($text, $msg_variable) {
> $msg_key = '_FP_VAR_';
>
> foreach (array_keys($msg_variable) as $key) {
> $token = $msg_key.$key;
> $text = preg_replace("/$token/", "$msg_variable[$key]",
> $text); }
>
> return ($text);
> }
What's ugly about it? I saw your earlier post I was actually planning on
responding and suggesting something exactly like you just came up with. My
version had the $token surrounded by markers, such as
This is a ?:token:?
but that's the only difference. I think it's fairly clean and logical.
The only problem I can see with this approach is that it's inefficient as
$msg_variable gets larger or the $text gets larger, since you're iterating
through every key of the former, even if the token isn't in $text, and you
run preg_replace() once for each token, but that shouldn't hurt you unless
you really have a heavy traffic site, IMHO.
I toyed around with using preg_replace_callback() for this eariler, but the
only problem with it is that you can't create a callback that accepts more
than just one variable (the array of matches). This means I couldn't get
the equivalent of your $msg_variable passed to the callback, so I had to
make it global in the callback function (yuk). If it weren't for that it'd
be a perfect solution, because preg_replace_callback would only be called
once and the function wouldn't need to iterate through all of $msg_variable.
It's times like that that I miss Perl's more powerful variable scoping
rules. Ah well...
--- End Message ---
--- Begin Message ---
On Mon, 4 Oct 2004, Michael Sims wrote:
> Chuck Wolber wrote:
> > The method I've come up with in the meantime, I believe is much more
> > effective than heredocs, but still an ugly hack:
> >
> > function interpolate ($text, $msg_variable) {
> > $msg_key = '_FP_VAR_';
> >
> > foreach (array_keys($msg_variable) as $key) {
> > $token = $msg_key.$key;
> > $text = preg_replace("/$token/", "$msg_variable[$key]",
> > $text); }
> >
> > return ($text);
> > }
>
> What's ugly about it? I saw your earlier post I was actually planning
> on responding and suggesting something exactly like you just came up
> with.
The main problem (aside from performance, which you addressed) is that it
does not handle corner cases such as when you want to use one of your
variables within the text of the dispatch (escaping). It is also not
truly recursive.
>From a hacker standpoint, it extends the base PHP tool set, rather than
making use of existing tools (not necessarily a bad thing). IMHO a
non-ugly version of this would allow you to use standard PHP variables in
your dispatch and force PHP itself to re-interpret the variables. This is
why I think an interpolate() function would have to be built in to the
base PHP interpreter rather than be done with the language itself.
> I think it's fairly clean and logical.
Thank you :)
> The only problem I can see with this approach is that it's inefficient
> as $msg_variable gets larger or the $text gets larger, since you're
> iterating through every key of the former, even if the token isn't in
> $text, and you run preg_replace() once for each token, but that
> shouldn't hurt you unless you really have a heavy traffic site, IMHO.
Right, which is another reason my hack shouldn't be considered a
generalized solution to the recursive interpolation problem. Any
developers on the list want to comment on a possible interpolate()
function?
> I toyed around with using preg_replace_callback() for this eariler, but
> the only problem with it is that you can't create a callback that
> accepts more than just one variable (the array of matches). This means
> I couldn't get the equivalent of your $msg_variable passed to the
> callback, so I had to make it global in the callback function (yuk).
> If it weren't for that it'd be a perfect solution, because
> preg_replace_callback would only be called once and the function
> wouldn't need to iterate through all of $msg_variable. It's times like
> that that I miss Perl's more powerful variable scoping rules. Ah
> well...
Definitely cleaner and even appears (at first glance) that it lends itself
to being recursive a lot easier than mine. Could you solve the global
problem by doing a $this.msg_variable sort of thing within the callback?
-Chuck
--
http://www.quantumlinux.com
Quantum Linux Laboratories, LLC.
ACCELERATING Business with Open Technology
"The measure of the restoration lies in the extent to which we apply
social values more noble than mere monetary profit." - FDR
--- End Message ---
--- Begin Message ---
1. If you have any queries/problems about PHP
try http://www.php.net/manual/en first. You
can download a copy and use it offline also.
Please also try
http://www.php.net/manual/faq.php
for answers to frequently answered questions
about PHP (added by Christophe Chisogne).
2. Try http://www.google.com next. Searching
for "php YOUR QUERY" may fetch you relevant
information within the first 10 results.
3. There is a searchable archive of the
mailing list discussion at
http://phparch.com/mailinglists. Many of the
common topics are discussed repeatedly, and
you may get answer to your query from the
earlier discussions.
For example: One of the repeatedly discussed
question in the list is "Best PHP editor".
Everyone has his/her favourite editor.
You can get all the opinions by going through
the list archives. If you want a chosen list
try this link :
http://www.thelinuxconsultancy.co.uk/phpeditors/
(contributed by Christophe Chisogne).
4. Not sure if PHP is working or you want
find out what extensions are available to
you?
Just put the following code into a file with
a .php extension and access it through your
webserver:
<?php
phpinfo();
?>
If PHP is installed you will see a page with
a lot of information on it. If PHP is not
installed (or not working correctly) your
browser will try to download the file.
(contributed by Teren and reworded by Chris W
Parker)
5. If you are stuck with a script and do not
understand what is wrong, instead of posting
the whole script, try doing some research
yourself. One useful trick is to print
the variable/sql query using print or echo
command and check whether you get what you
expected.
After diagnosing the problem, send the
details of your efforts (following steps 1,
2 & 3) and ask for help.
6. PHP is a server side scripting language.
Whatever processing PHP does takes place
BEFORE the output reaches the client.
Therefore, it is not possible to access
users' computer related information (OS,
screen size etc) using PHP. Nor can you
modify any the user side settings. You need
to go for JavaScript and ask the question in
a JavaScript list.
On the other hand, you can access the
information that is SENT by the user's
browser when a client requests a page from
your server. You can find details about
browser, OS etc as reported by
this request. - contributed by Wouter van
Vliet and reworded by Chris W Parker.
7. Provide a clear descriptive subject line.
Avoid general subjects like "Help!!", "A
Question" etc. Especially avoid blank
subjects.
8. When you want to start a new topic, open a
new mail composer and enter the mailing list
address [EMAIL PROTECTED] instead of
replying to an existing thread and replacing
the subject and body with your message.
9. Only quote the relevant parts of
an email when replying. Do not Quote
everything (including huge code snippets)
only to say "I agree", for instance.
[contribued by Paul Waring]
10. It's always a good idea to post back to
the list once you've solved your problem.
People usually add [SOLVED] to the subject
line of their email when posting solutions.
By posting your solution you're helping the
next person with the same question.
[contribued by Chris W Parker]
11. Ask smart questions
http://catb.org/~esr/faqs/smart-questions.html
[contributed by Jay Blanchard)
12. Do not send your email to the list with
attachments. If you don't have a place to
upload your code, try the many pastebin
websites (such as www.pastebin.com).
[contributed by Burhan Khalid]
Following these guidelines will ensure that
you get effective responses from the list
members. Otherwise, your questions might not
be answered.
Hope you have a good time programming with
PHP.
--
Integrated Management Tools for leather
industry
----------------------------------
http://www.leatherlink.net
S.Gnanavel,
BSG LeatherLink (P) Ltd,
Chennai - 600106
--- End Message ---
--- Begin Message ---
Hi
I am developing an application using php and postgresql . My problem is I
need to retrieve name and addresses from table(postgres sql table) and
print letter (body of letter will be same). Kindly help /Suggest how i can
do this
Thanks
Suma
_________________________________________________________________
Looking for a soulmate? http://www.shaadi.com/ptnr.php?ptnr=hmltag Log onto
Shaadi.com.
--- End Message ---
--- Begin Message ---
Extracting name and addresses from postgres as a comma separated values
"CSV" file should be doable with postgress utilities or scripts. Assuming
you have access to a word processor like Microsoft Word, that has a "Mail
Merge" capability, where your letter can be merged and printed with names
and addresses from your CSV file.
Factors affecting the wisdom of this approach are;
* The volume of letters you expect to print and the printers you expect to
use (bubble jet ink cartridges are expensive).
* If name and address are the only substitutions in the letter. Greetings,
additional content may require more that a CSV solution.
* Special bulk mail requirements like zip code sort and selections should be
doable in postgres.
* For really large volumes you will need to break down the workload for
multiple printers in a fashion that makes sense.
If you want to reinvent the wheel by developing your own mail merge process,
I would recommend against it, unless there is some significant gain by doing
that. I'm guessing that your have already considered this, but are looking
for some other solution for some reason that is not apparent to me.
Good Luck,
Warren Vail
-----Original Message-----
From: suma parakala [mailto:[EMAIL PROTECTED]
Sent: Monday, October 04, 2004 11:23 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Help needed Postgresql and PHP
Hi
I am developing an application using php and postgresql . My problem is I
need to retrieve name and addresses from table(postgres sql table) and
print letter (body of letter will be same). Kindly help /Suggest how i can
do this
Thanks
Suma
_________________________________________________________________
Looking for a soulmate? http://www.shaadi.com/ptnr.php?ptnr=hmltag Log onto
Shaadi.com.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Dear,I have a input text tag that it named question.
Also i have a 2 radio bottum.
When i receive their value,I want to test that
question tag is empty or not.If empty,I again send to
client until client fill out this tag.
Can u solve my problem?
<?php
function display_form()
{
echo "<form action=\"".$_SERVER['PHP_SELF']. "\"
method=\"post\">";
echo "Your question<input type=\"text\"
name=\"question\" "><br />";
echo "radio type <input type=\"radio\"
name=\"type_of_reply\" value=\"0\"><br />";
echo "check box type <input type=\"radio\"
name=\"type_of_reply\" value=\"1\"><br />";
echo "<input type=\"submit\">";
/* if (empty($HTTP_POST_VARS['question']))
{
echo "please fill out question field.";
display_form();
}//end of if*/
}//end of display_form func
function test_var()
{
if (empty($HTTP_POST_VARS['question']))
{
echo "please fill out question field.";
display_form();
}//end of if
}//end of func
function insert_to_question()
{
display_form();
while(empty($HTTP_POST_VARS['question']))
test_var();
}//end of insert_to_question func
insert_to_question();
?>
=====
---------DIGITAL SIGNATURE-------------------
///Mohsen Pahlevanzadeh////////
Network administrator & programmer
My home phone is: +98213810146
My email address is
m_pahlevanzadeh at yahoo dot com
My website is: http://webnegar.net
----------------------------------------------------------------
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
--- End Message ---
--- Begin Message ---
Hello.
I have some problems with basic math in the function below.
function Custom_Round($Digit, $Divisor) {
return (($Digit / $Divisor) - (($Digit % $Divisor) / $Divisor));
}
Custom_Round(23, 10) returns float(2) as expected.
Same for Custom_Round(22, 10).
BUT when you compare the both results like below
Custom_Round(23, 10)!=Custom_Round(22, 10)
I always get bool(true) whereas the result should be bool(false)
When I have debuged this small piece of code I found out that
intval(Custom_Round(23, 10)) = 1
whats definitly not expected.
But intval(Custom_Round(22, 10)) = 2 as expected.
Replacing Custom_Round() by Floor() works fine, but why does the custom
function doing the same not work? Is this a bug in PHP?
This problem occurse in PHP 4.3.3 and PHP 5.0.1.
Thanks for help,
Christoph
--- End Message ---
--- Begin Message ---
Christoph Schwadorf wrote:
Hello.
I have some problems with basic math in the function below.
function Custom_Round($Digit, $Divisor) {
return (($Digit / $Divisor) - (($Digit % $Divisor) / $Divisor));
}
Custom_Round(23, 10) returns float(2) as expected.
Same for Custom_Round(22, 10).
BUT when you compare the both results like below
Custom_Round(23, 10)!=Custom_Round(22, 10)
I always get bool(true) whereas the result should be bool(false)
When I have debuged this small piece of code I found out that
intval(Custom_Round(23, 10)) = 1
whats definitly not expected.
But intval(Custom_Round(22, 10)) = 2 as expected.
Replacing Custom_Round() by Floor() works fine, but why does the custom
function doing the same not work? Is this a bug in PHP?
This problem occurse in PHP 4.3.3 and PHP 5.0.1.
Thanks for help,
Christoph
intval converts other types to integers. Integers can only be whole
numbers, eg 1, 2, 15, -789, etc. No matter what decimals, intval
converts it to the lower (closer to 0) integer value. Eg 2.5 => 2,
19.9=>19, -25.3 => -25 etc.
What happens now is that you're converting a float to an integer,
float=>integer conversion has a lot of "problems", floating point
numbers have a lot more precision. Numbers given as being float(2) can
actually be something of the like
1.99999999999999999999999999999999999999, and when converted to intgers,
they drop down to 1 instead of 2.
This is explained here:
http://www.php.net/manual/en/language.types.integer.php#language.types.integer.casting.from-float
--- End Message ---
--- Begin Message ---
Hi all,
this might be slightly off-topic in a way but Im looking for help not
flaming.
Ok I have a checkbox array that I populate from a DB using php:
while ($row = mysql_fetch_array($result))
echo("<input type=checkbox name=chkmodels[] value=" .
$row['models_id'] . ">" . $row['models_type'] . "<br>");
So when I want to see each variable in the array I use:
foreach ($_POST['chkmodels'] as $c)
{
echo("<br> value: " . $c);
}
this is fine.
but what I want to clarify is that if I change my PHP echo statement
to:
echo("<input type=checkbox name=chkmodels value=" . $row['models_id'] .
">" . $row['models_type'] . "<br>");
basically without the [] then it is still recognised as an array. But
when the array is passed back it is returned as a string separated by
commas. Then I should use the split() function to create an array.
IE:
$modelsArray = split('[,]', $chkmodels);
however when I try the second way (without the [])
like this:
if(isset($_POST['chkmodels']))
$selModels=$_POST['chkmodels'];
else
header("Location: ../freesample.php");
if(isset($selModels))
{
echo("selmodels: " .$selModels);
$selModelsInd = split('[,]',$selModels);
echo("<br>Ind modesl" . $selModelsInd);
foreach ($selModelsInd as $c)
{
echo("<br> value: " . $c);
}
}
I get the following results, when I select 2 checkboxes:
selmodels: 2
Ind modeslArray
value: 2
this is wrong and should output the following:
selmodels: 2
Ind modeslArray
value: 1
value: 2
as the values of the selected checkboxes are 1 and 2 and also there are
two that are selected.
Here is the OT part. how do I reference the checkboxes in javascript if
the chkmodels[] is used?
I have tried many things like:
myCheckboxArray = document.forms[0].elements["chkmodels[]"];
and
myCheckboxArray = document.frmft[0].elements["chkmodels[]"]; //where
frmft is the name of my form.
If someone could please advise me as to what I'm doing wrong or why the
information is not being outputted as expected, that would be really
helpful.
thanks in advance
Angelo
--------------------------------------------------------------------
Disclaimer
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is
intended for the attention and use only of the addressee.
Should you have received this e-mail in error, please delete
and destroy it and any attachments thereto immediately.
Under no circumstances will the Cape Technikon or the sender
of this e-mail be liable to any party for any direct, indirect,
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911
--- End Message ---
--- Begin Message ---
On 05 October 2004 11:10, Angelo Zanetti wrote:
> Hi all,
>
> this might be slightly off-topic in a way but Im looking for help not
> flaming.
>
> Ok I have a checkbox array that I populate from a DB using php:
>
> while ($row = mysql_fetch_array($result))
> echo("<input type=checkbox name=chkmodels[] value=" .
> $row['models_id'] . ">" . $row['models_type'] . "<br>");
>
> So when I want to see each variable in the array I use:
>
> foreach ($_POST['chkmodels'] as $c)
> {
> echo("<br> value: " . $c);
> }
>
> this is fine.
>
> but what I want to clarify is that if I change my PHP echo statement
> to:
>
> echo("<input type=checkbox name=chkmodels value=" . $row['models_id']
> . ">" . $row['models_type'] . "<br>");
>
> basically without the [] then it is still recognised as an array. But
> when the array is passed back it is returned as a string separated by
> commas.
No, this is incorrect. You will see only the last value selected, returned
as a simple scalar. PHP doesn't do automatic array-ification of multiple
values -- that's why you need the [] in the name attribute.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
--- End Message ---
--- Begin Message ---
Angelo Zanetti wrote:
but what I want to clarify is that if I change my PHP echo statement
to:
echo("<input type=checkbox name=chkmodels value=" . $row['models_id'] .
">" . $row['models_type'] . "<br>");
basically without the [] then it is still recognised as an array. But
when the array is passed back it is returned as a string separated by
commas. Then I should use the split() function to create an array.
If you leave off the [], then only the last checkbox value remains in
$_POST['chkmodels']. It is not passed as a comma separated string.
If you look at the query string, you'll see something like this:
?chkmodels=1&chkmodels=2
which means PHP makes $_POST['chkmodels'] equal to 1 for the first
variable, then sets the same $_POST['chkmodels'] equal to 2 for the
second variable in the query string. End result is one value (not an
array) remaining in $_POST['chkmodels'].
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Angelo Zanetti wrote:
Here is the OT part. how do I reference the checkboxes in javascript if
the chkmodels[] is used?
I have tried many things like:
myCheckboxArray = document.forms[0].elements["chkmodels[]"];
The above should work. Is it really the first form on the page?
--- End Message ---
--- Begin Message ---
its the only form on the page...
Based on the other responses I will have to use chkmodels[] and need to
get the javascript working. Is it not possible to use the forms name
when referencing the array?
thank again.
Angelo
>>> Marek Kilimajer <[EMAIL PROTECTED]> 10/5/2004 1:52:02 PM >>>
Angelo Zanetti wrote:
> Here is the OT part. how do I reference the checkboxes in javascript
if
> the chkmodels[] is used?
>
> I have tried many things like:
>
> myCheckboxArray = document.forms[0].elements["chkmodels[]"];
The above should work. Is it really the first form on the page?
--------------------------------------------------------------------
Disclaimer
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is
intended for the attention and use only of the addressee.
Should you have received this e-mail in error, please delete
and destroy it and any attachments thereto immediately.
Under no circumstances will the Cape Technikon or the sender
of this e-mail be liable to any party for any direct, indirect,
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911
--- End Message ---
--- Begin Message ---
Angelo Zanetti wrote:
its the only form on the page...
Based on the other responses I will have to use chkmodels[] and need to
get the javascript working. Is it not possible to use the forms name
when referencing the array?
You should be able to use:
document.formName
document.forms[0]
document.forms['formName']
thank again.
Angelo
Marek Kilimajer <[EMAIL PROTECTED]> 10/5/2004 1:52:02 PM >>>
Angelo Zanetti wrote:
Here is the OT part. how do I reference the checkboxes in javascript
if
the chkmodels[] is used?
I have tried many things like:
myCheckboxArray = document.forms[0].elements["chkmodels[]"];
The above should work. Is it really the first form on the page?
--- End Message ---
--- Begin Message ---
Hi Marek,
I try to access the array like this:
document.frmft.elements["chkmodels[]"];
but doesnt work. I also tried this:
models = document.forms['frmft'].elements["chkmodels[]"];
is there not a problem with the elements part?
thanks
>>> Marek Kilimajer <[EMAIL PROTECTED]> 10/5/2004 2:19:26 PM >>>
Angelo Zanetti wrote:
> its the only form on the page...
>
> Based on the other responses I will have to use chkmodels[] and need
to
> get the javascript working. Is it not possible to use the forms name
> when referencing the array?
You should be able to use:
document.formName
document.forms[0]
document.forms['formName']
>
> thank again.
> Angelo
>
>
>>>>Marek Kilimajer <[EMAIL PROTECTED]> 10/5/2004 1:52:02 PM >>>
>
> Angelo Zanetti wrote:
>
>>Here is the OT part. how do I reference the checkboxes in javascript
>
> if
>
>>the chkmodels[] is used?
>>
>>I have tried many things like:
>>
>>myCheckboxArray = document.forms[0].elements["chkmodels[]"];
>
>
> The above should work. Is it really the first form on the page?
--------------------------------------------------------------------
Disclaimer
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is
intended for the attention and use only of the addressee.
Should you have received this e-mail in error, please delete
and destroy it and any attachments thereto immediately.
Under no circumstances will the Cape Technikon or the sender
of this e-mail be liable to any party for any direct, indirect,
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911
--- End Message ---