OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
[suspicious - maybe spam] php-general Digest 19 Oct 2005 03:52:23 -0000 Issue 3745

php-general-digest-helplists.php.net
Date: Tue Oct 18 2005 - 22:52:23 CDT


php-general Digest 19 Oct 2005 03:52:23 -0000 Issue 3745

Topics (messages 224277 through 224312):

Re: some problems with php form
        224277 by: Bruce Gilbert
        224278 by: Minuk Choi
        224293 by: Ford, Mike

Re: How can I count the usage of mail function in scripts?
        224279 by: Oliver Grätz
        224280 by: Oliver Grätz
        224283 by: Greg Donald
        224309 by: Oliver Grätz

Inserting NULL Integer Values
        224281 by: Shaun
        224285 by: Ben Litton
        224287 by: tg-php.gryffyndevelopment.com
        224289 by: Shaun
        224290 by: Ben Litton
        224291 by: Ben Litton
        224292 by: Richard Lynch
        224295 by: Richard Lynch
        224298 by: Shaun
        224299 by: tg-php.gryffyndevelopment.com
        224303 by: Ben Litton
        224311 by: Oliver Grätz

Re: No redirect with header()
        224282 by: Oliver Grätz

Re: asynchronous PHP to PHP call
        224284 by: Oliver Grätz

Re: php, expect and screen
        224286 by: Ben

Using .htaccess files with PHP CGI
        224288 by: Jason Kovacs

Recommended Reading?
        224294 by: Alan Lord
        224301 by: Jordan Miller
        224304 by: Ben Litton
        224310 by: Oliver Grätz

Open Lampshade
        224296 by: Aaron Greenspan

Re: fckeditor and PDF and pesky users
        224297 by: Richard Lynch

White background with imagecreatetruecolor()
        224300 by: John Nichel

Re: White background with imagecreatetruecolor() [SOLVED]
        224302 by: John Nichel

LDAPS agaisnt Active Directory
        224305 by: Aaron Axelsen

has anyone a script for generating dates to a rule?
        224306 by: Vizion

PHP and files Upload
        224307 by: feiticeir0

[suspicious - maybe spam] RE: [PHP] Recommended Reading?
        224308 by: Death Gauge

Java editor
        224312 by: John Taylor-Johnston

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


I think so Minuk. Here is the *entire* form code below. Maybe someone can
also point out why the email regex validation code isn't working?
 TIA
 /****************************begin PHP form
code*************************************/

<?php
$form_block=<<<END_FORM
<form method="post" action="{$_SERVER['PHP_SELF']}" class="info_request" >
<fieldset class="left">
<legend title="About You">About You</legend>

<p><label for="firstname"><span class="red">*</span> First Name: </label><br
/>

<input class="<?PHP if ($error_msg){echo "input.error";}else{echo "
input.normal";}?>" id="firstname" name="firstname" type="text" value="<?PHP
echo $_POST['firstname'];?>">

<p><label for="lastname"><span class="red">*</span> Last Name:</label><br />

<input id="lastname" name="lastname" type="text"
value="{$_POST['lastname']}" /></p>

<p><label for="company"><span class="red">*</span> Company: </label><br />

<input id="company" name="company" type="text" value="{$_POST['company']}"
/></p>

<p><label for="phone"><span class="red">*</span> Phone: </label><br />

<input id="phone" name="phone" type="text" value="{$_POST['phone']}" /></p>

<p><label for="email"><span class="red">*</span> e-mail: </label><br />

<input id="email" name="email" type="text" value="{$_POST['email']}" /></p>

<p><label for="email2"><span class="red">*</span> re-enter e-mail:
</label><br />

<input id="email2" name="email2" type="text" value="{$_POST['email2']}"
/></p>
</fieldset>
<fieldset>
<legend title="More Info.">More Info.</legend>
<p><label for="URL"><span class="red">*</span>
URL:</label><br<http://mail.google.com/mail/</label><br>/>

<input id="URL" type="text" name="URL" value="{$_POST['URL']}"/> </p>

<p><label for="Contact_Preference"><span class="red">*</span> Best way to
reach:</label><br />

<select name="Contact_Preference" id="Contact_Preference">
<option value="email">email</option>
<option value="phone">phone</option>
<option value="snail_mail">snail mail</option>

</select>
</p>

<p><label for="Contact_Time"><span class="red">*</span> Best time to
contact:</label><br />

<select name="Contact_Time" id="Contact_Time">

<option value="morning">morning</option>
<option value="evening">evening</option>
<option value="anytime">anytime</option>

</select></p>

<input type="hidden" name="op" value="ds" />

<textarea name="message" id="message" rows="" cols="" >Send us a detailed
message specifying what you wish to accomplish with your web site.
</textarea>
<input class="submit" src="/images/submit.gif" alt="Submit" type="image"
name="submit" />

</fieldset>
</form>
</div>
<p><span class="red">*</span> indicates a required field (all fields are
required).</p>
END_FORM;
if ($_POST['op']!='ds') {
echo "$form_block";
} else if ($_POST["op"] == "ds") {

//Function saves time and space by eliminating unneccesary code
function check($fieldname)
{
global $err_msg;
if($_POST[$fieldname] == "")
{
if ( !isset($err_msg)) { $err_msg = "<span class='red'>You haven't entered
your ".$fieldname."!</span><br />"; }
elseif ( isset($err_msg)) { $err_msg="<span class='red'>You haven't entered
your ".$fieldname."!</span><br />"; }
}
return $err_msg;
}

if(!eregi("^(.+)(.+)\\.(.+)$",$_POST['email']))
{
$error_msg .= "<BR />Your email appears to be invalid.";
$ok = "false";
}

 //////////////////////////
///Function execution/////
//////////////////////////

check('firstname');
check('lastname');
check('company');
check('phone');
check('email');
check('email2');
check('URL');
check('Contact_Preference');
check('Contact_Time');
check('message');

//Validating Email Address
if ($_POST['email'] != $_POST['email2']) { $email_err = "\n<span
class='red'>e-mail address fields do not match!</span>"; }

if (isset($err_msg) || isset($email_err)) { echo
$err_msg.$email_err."\n\n".$form_block; }
else {
//it's ok to send, so build the mail
$msg = "E-mail sent from
www.inspired-evolution.com\n<http://www.inspired-evolution.com/n>
";
$msg .="Sender's first name: {$_POST['firstname']}\n";
$msg .="Sender's last name: {$_POST['lastname']}\n";
$msg .="Company name: {$_POST['company']}\n";
$msg .="Senders Phone number: {$_POST['phone']}\n";
$msg .="Senders email address: {$_POST['email']}\n";
$msg .="Senders email address (re-typed): {$_POST['email2']}\n";
$msg .="The website is : {$_POST['URL']}\n";
$msg .="I prefer to be contacted via: {$_POST['Contact_Preference']}\n";
$msg .="The Best time to contact is: {$_POST['Contact_Time']}\n";
$msg .="Message: {$_POST['message']}\n\n";
$to ="webguyncgmail.com";
$subject ="There has been a disturbance in the force";
$mailheaders ="From: Inspired-Evolution.com
<http://www.inspired-evolution.com>\n <http://www.inspired-evolution.com>/n>
";
$mailheaders .="Reply-To: {$_POST['email']}\n";
//send the mail
mail ($to, $subject, $msg, $mailheaders);
//display information to user
echo "<p>Hola, <strong>$firstname</strong>!.<br /><br />
We have received your request for a web site review , and will respond
shortly.<br />
Thanks for visiting inspired-evolution.com
<http://inspired-evolution.com>and have a wonderful day!<br /><br />
Regards,<br /><br />
<strong>Inspired Evolution</strong></p>";
}

}
?>
/****************************end PHP form
code*************************************/

 On 10/18/05, Minuk Choi <Choi.Minukverizon.net> wrote:
>
> Can you post your Contact_Form_test.php?
>
> <input class="<?PHP
> if ($error_msg)
> {
> echo "input.error";
> }
> else
> {
> echo "input.normal";
> }
> ?>" id="firstname" name="firstname" type="text" value="<?PHP echo
> $_POST['firstname'];?>">
>
> should parse into HTML by PHP. This block, I am assuming is placed in a
> HTML tag and not in a <?PHP block, correct?
>
>
>
> Bruce Gilbert wrote:
>
> >Minuk,
> > your revisions gives me an error:
> > *Parse error*: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,
> expecting
> >T_STRING or T_VARIABLE or T_NUM_STRING in *
> >/hsphere/local/home/bruceg/inspired-evolution.com/Contact_Form_test.php<http://evolution.com/Contact_Form_test.php>
> <http://evolution.com/Contact_Form_test.php>
> >* on line *63*
> > -Bruce
> >
> > On 10/17/05, Minuk Choi <Choi.Minukverizon.net> wrote:
> >
> >
> >>Wait a minute... you meant
> >>
> >><input class="
> >><?PHP
> >>if ($error_msg)
> >>{
> >>echo "input.error";
> >>}
> >>else
> >>{
> >>echo "input.normal";
> >>}
> >>?>" id="firstname" name="firstname" type="text" value="<?PHP echo
> >>$_POST['firstname'];?>">
> >>
> >>
> >>...or am I looking at the wrong thing?
> >>
> >>Bruce Gilbert wrote:
> >>
> >>
> >>
> >>>---------- Forwarded message ----------
> >>>From: "Richard Lynch" <ceol-i-e.com>
> >>>To: "Mark Rees" <mreesitsagoodprice.com>
> >>>Date: Mon, 17 Oct 2005 15:12:50 -0500 (CDT)
> >>>Subject: Re: [PHP] Re: a couple of problems with PHP form
> >>>On Mon, October 17, 2005 5:32 am, Mark Rees wrote:
> >>>
> >>>
> >>>
> >>>
> >>>>-----------------------------------------------------
> >>>>sorry, my editor has not indented again
> >>>>-----------------------------------------------------
> >>>>also, I want the field to appear hilighted when there is no
> >>>>information so I am doing this:
> >>>>
> >>>><input class="<? if($error_msg){ echo "error"; } ELSE { echo
> >>>>"normal"; } id="firstname" name="firstname" type="text"
> >>>>value="{$_POST['firstname']}"? />"
> >>>>
> >>>>
> >>>>
> >>>>
> >>>I think the quote mark balancing is messed up here...
> >>>
> >>>
> >>>
> >>>
> >>>><input class="
> >>>>this starts a quote for the class=
> >>>>There appears to be no ending quote for that...
> >>>>
> >>>>
> >>>>
> >>>>
> >>>I>t may simply have been lost in email editing, however...
> >>>
> >>>
> >>>adding the input.error didn't solve the problem dang it.! If there is
> >>>a ending quote missing, I don't see it right off hand.
> >>>
> >>>I know have:
> >>>
> >>>
> >>><input class="<? if($error_msg){ echo "input.error"; } ELSE { echo
> >>>"input.normal"; } id="firstname" name="firstname" type="text"
> >>>value="{$_POST['firstname']}"? />"
> >>>
> >>>in the css:
> >>>
> >>>input.error {
> >>>border: 2px inset red;
> >>>margin:0;
> >>>font-family: arial, helvetica, sans-serif;
> >>>color: #036;
> >>>width: 15em;
> >>>padding-left: .25em;
> >>>font-weight: bold;
> >>>background: #eee;
> >>>}
> >>>
> >>>
> >>>
> >>>
> >>>
> >
> >
> >
> >--
> >::Bruce::
> >
> >
> >
>

--
::Bruce::

attached mail follows:


Seems like you're using some sort of a template or something.

I am not familiar with this type, so I'm afraid I can't be of much
help... but if i had to guess, it seems that you have to use {} instead
of <?PHP and ?> So try this :

replace from the <?PHP line down to the input.error/input.normal line
with this

<?php
/*
 * Do all the logic BEFORE the form layout
 */
$class = "input.normal";

if ($error_msg)
        $class = "input.error";

$form_block=<<<END_FORM
<form method="post" action="{$_SERVER['PHP_SELF']}" class="info_request" >
<fieldset class="left">
<legend title="About You">About You</legend>

<p><label for="firstname"><span class="red">*</span> First Name: </label><br
/>

<input class="{$class?}" id="firstname" name="firstname" type="text" value="{$_POST['firstname']}">

Regarding the regex,

check out this page http://www.sitepoint.com/article/regular-expressions-php

the gist of it is
|
eregi('^[a-zA-Z0-9._-]+[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$', $email)|

Good Luck

Bruce Gilbert wrote:

>I think so Minuk. Here is the *entire* form code below. Maybe someone can
>also point out why the email regex validation code isn't working?
> TIA
> /****************************begin PHP form
>code*************************************/
>
><?php
>$form_block=<<<END_FORM
><form method="post" action="{$_SERVER['PHP_SELF']}" class="info_request" >
><fieldset class="left">
><legend title="About You">About You</legend>
>
><p><label for="firstname"><span class="red">*</span> First Name: </label><br
>/>
>
><input class="<?PHP if ($error_msg){echo "input.error";}else{echo "
>input.normal";}?>" id="firstname" name="firstname" type="text" value="<?PHP
>echo $_POST['firstname'];?>">
>
><p><label for="lastname"><span class="red">*</span> Last Name:</label><br />
>
><input id="lastname" name="lastname" type="text"
>value="{$_POST['lastname']}" /></p>
>
><p><label for="company"><span class="red">*</span> Company: </label><br />
>
><input id="company" name="company" type="text" value="{$_POST['company']}"
>/></p>
>
><p><label for="phone"><span class="red">*</span> Phone: </label><br />
>
><input id="phone" name="phone" type="text" value="{$_POST['phone']}" /></p>
>
><p><label for="email"><span class="red">*</span> e-mail: </label><br />
>
><input id="email" name="email" type="text" value="{$_POST['email']}" /></p>
>
><p><label for="email2"><span class="red">*</span> re-enter e-mail:
></label><br />
>
><input id="email2" name="email2" type="text" value="{$_POST['email2']}"
>/></p>
></fieldset>
><fieldset>
><legend title="More Info.">More Info.</legend>
><p><label for="URL"><span class="red">*</span>
>URL:</label><br<http://mail.google.com/mail/</label><br>/>
>
><input id="URL" type="text" name="URL" value="{$_POST['URL']}"/> </p>
>
><p><label for="Contact_Preference"><span class="red">*</span> Best way to
>reach:</label><br />
>
><select name="Contact_Preference" id="Contact_Preference">
><option value="email">email</option>
><option value="phone">phone</option>
><option value="snail_mail">snail mail</option>
>
></select>
></p>
>
><p><label for="Contact_Time"><span class="red">*</span> Best time to
>contact:</label><br />
>
><select name="Contact_Time" id="Contact_Time">
>
><option value="morning">morning</option>
><option value="evening">evening</option>
><option value="anytime">anytime</option>
>
></select></p>
>
><input type="hidden" name="op" value="ds" />
>
><textarea name="message" id="message" rows="" cols="" >Send us a detailed
>message specifying what you wish to accomplish with your web site.
></textarea>
><input class="submit" src="/images/submit.gif" alt="Submit" type="image"
>name="submit" />
>
></fieldset>
></form>
></div>
><p><span class="red">*</span> indicates a required field (all fields are
>required).</p>
>END_FORM;
>if ($_POST['op']!='ds') {
>echo "$form_block";
>} else if ($_POST["op"] == "ds") {
>
>//Function saves time and space by eliminating unneccesary code
>function check($fieldname)
>{
>global $err_msg;
>if($_POST[$fieldname] == "")
>{
>if ( !isset($err_msg)) { $err_msg = "<span class='red'>You haven't entered
>your ".$fieldname."!</span><br />"; }
>elseif ( isset($err_msg)) { $err_msg="<span class='red'>You haven't entered
>your ".$fieldname."!</span><br />"; }
>}
>return $err_msg;
>}
>
>if(!eregi("^(.+)(.+)\\.(.+)$",$_POST['email']))
>{
>$error_msg .= "<BR />Your email appears to be invalid.";
>$ok = "false";
>}
>
> //////////////////////////
>///Function execution/////
>//////////////////////////
>
>check('firstname');
>check('lastname');
>check('company');
>check('phone');
>check('email');
>check('email2');
>check('URL');
>check('Contact_Preference');
>check('Contact_Time');
>check('message');
>
>//Validating Email Address
>if ($_POST['email'] != $_POST['email2']) { $email_err = "\n<span
>class='red'>e-mail address fields do not match!</span>"; }
>
>if (isset($err_msg) || isset($email_err)) { echo
>$err_msg.$email_err."\n\n".$form_block; }
>else {
>//it's ok to send, so build the mail
>$msg = "E-mail sent from
>www.inspired-evolution.com\n<http://www.inspired-evolution.com/n>
>";
>$msg .="Sender's first name: {$_POST['firstname']}\n";
>$msg .="Sender's last name: {$_POST['lastname']}\n";
>$msg .="Company name: {$_POST['company']}\n";
>$msg .="Senders Phone number: {$_POST['phone']}\n";
>$msg .="Senders email address: {$_POST['email']}\n";
>$msg .="Senders email address (re-typed): {$_POST['email2']}\n";
>$msg .="The website is : {$_POST['URL']}\n";
>$msg .="I prefer to be contacted via: {$_POST['Contact_Preference']}\n";
>$msg .="The Best time to contact is: {$_POST['Contact_Time']}\n";
>$msg .="Message: {$_POST['message']}\n\n";
>$to ="webguyncgmail.com";
>$subject ="There has been a disturbance in the force";
>$mailheaders ="From: Inspired-Evolution.com
><http://www.inspired-evolution.com>\n <http://www.inspired-evolution.com>/n>
>";
>$mailheaders .="Reply-To: {$_POST['email']}\n";
>//send the mail
>mail ($to, $subject, $msg, $mailheaders);
>//display information to user
>echo "<p>Hola, <strong>$firstname</strong>!.<br /><br />
>We have received your request for a web site review , and will respond
>shortly.<br />
>Thanks for visiting inspired-evolution.com
><http://inspired-evolution.com>and have a wonderful day!<br /><br />
>Regards,<br /><br />
><strong>Inspired Evolution</strong></p>";
>}
>
>}
>?>
>/****************************end PHP form
>code*************************************/
>
>
> On 10/18/05, Minuk Choi <Choi.Minukverizon.net> wrote:
>
>
>>Can you post your Contact_Form_test.php?
>>
>><input class="<?PHP
>>if ($error_msg)
>>{
>>echo "input.error";
>>}
>>else
>>{
>>echo "input.normal";
>>}
>>?>" id="firstname" name="firstname" type="text" value="<?PHP echo
>>$_POST['firstname'];?>">
>>
>>should parse into HTML by PHP. This block, I am assuming is placed in a
>>HTML tag and not in a <?PHP block, correct?
>>
>>
>>
>>Bruce Gilbert wrote:
>>
>>
>>
>>>Minuk,
>>>your revisions gives me an error:
>>>*Parse error*: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,
>>>
>>>
>>expecting
>>
>>
>>>T_STRING or T_VARIABLE or T_NUM_STRING in *
>>>/hsphere/local/home/bruceg/inspired-evolution.com/Contact_Form_test.php<http://evolution.com/Contact_Form_test.php>
>>>
>>>
>><http://evolution.com/Contact_Form_test.php>
>>
>>
>>>* on line *63*
>>>-Bruce
>>>
>>>On 10/17/05, Minuk Choi <Choi.Minukverizon.net> wrote:
>>>
>>>
>>>
>>>
>>>>Wait a minute... you meant
>>>>
>>>><input class="
>>>><?PHP
>>>>if ($error_msg)
>>>>{
>>>>echo "input.error";
>>>>}
>>>>else
>>>>{
>>>>echo "input.normal";
>>>>}
>>>>?>" id="firstname" name="firstname" type="text" value="<?PHP echo
>>>>$_POST['firstname'];?>">
>>>>
>>>>
>>>>...or am I looking at the wrong thing?
>>>>
>>>>Bruce Gilbert wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>---------- Forwarded message ----------
>>>>>From: "Richard Lynch" <ceol-i-e.com>
>>>>>To: "Mark Rees" <mreesitsagoodprice.com>
>>>>>Date: Mon, 17 Oct 2005 15:12:50 -0500 (CDT)
>>>>>Subject: Re: [PHP] Re: a couple of problems with PHP form
>>>>>On Mon, October 17, 2005 5:32 am, Mark Rees wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>-----------------------------------------------------
>>>>>>sorry, my editor has not indented again
>>>>>>-----------------------------------------------------
>>>>>>also, I want the field to appear hilighted when there is no
>>>>>>information so I am doing this:
>>>>>>
>>>>>><input class="<? if($error_msg){ echo "error"; } ELSE { echo
>>>>>>"normal"; } id="firstname" name="firstname" type="text"
>>>>>>value="{$_POST['firstname']}"? />"
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>I think the quote mark balancing is messed up here...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>><input class="
>>>>>>this starts a quote for the class=
>>>>>>There appears to be no ending quote for that...
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>I>t may simply have been lost in email editing, however...
>>>>>
>>>>>
>>>>>adding the input.error didn't solve the problem dang it.! If there is
>>>>>a ending quote missing, I don't see it right off hand.
>>>>>
>>>>>I know have:
>>>>>
>>>>>
>>>>><input class="<? if($error_msg){ echo "input.error"; } ELSE { echo
>>>>>"input.normal"; } id="firstname" name="firstname" type="text"
>>>>>value="{$_POST['firstname']}"? />"
>>>>>
>>>>>in the css:
>>>>>
>>>>>input.error {
>>>>>border: 2px inset red;
>>>>>margin:0;
>>>>>font-family: arial, helvetica, sans-serif;
>>>>>color: #036;
>>>>>width: 15em;
>>>>>padding-left: .25em;
>>>>>font-weight: bold;
>>>>>background: #eee;
>>>>>}
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>--
>>>::Bruce::
>>>
>>>
>>>
>>>
>>>
>
>
>
>--
>::Bruce::
>
>
>

attached mail follows:


On 18 October 2005 15:50, Bruce Gilbert wrote:

> I think so Minuk. Here is the *entire* form code below. Maybe
> someone can
> also point out why the email regex validation code isn't working? TIA
> /****************************begin PHP form
> code*************************************/
>
> <?php
> $form_block=<<<END_FORM

Here starteth a heredoc ;)

> <form method="post" action="{$_SERVER['PHP_SELF']}"
> class="info_request" > <fieldset class="left">
> <legend title="About You">About You</legend>
>
> <p><label for="firstname"><span class="red">*</span> First
> Name: </label><br
> />
>
> <input class="<?PHP if ($error_msg){echo "input.error";}else{echo "

Here you try to start a block of PHP code within the heredoc. You can't do that.

Because you didn't show us the heredoc, most of the responses assumed you had broken out of PHP completely into HTML, which is why many of the solutions produced parse errors.

> input.normal";}?>" id="firstname" name="firstname"
> type="text" value="<?PHP
> echo $_POST['firstname'];?>">

Again, you're trying to use PHP code inside a heredoc -- this one's solvable, though: as you just want the value of the variable, you can use {$_POST['firstname']} (which I notice you do elsewhere!).

Actually, since you use the heredoc's value once almost immediately after assigning it, I think you probably would be better breaking out into PHP for most of this, thusly:

if ($_POST['op']!='ds') {

?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" class="info_request" >
<fieldset class="left">
<legend title="About You">About You</legend>

<p><label for="firstname"><span class="red">*</span> First Name: </label><br />

<input class="<?PHP
                if ($error_msg) {echo "error"}
                else {echo "normal"}
              ?>" id="firstname" name="firstname" type="text" value="<?php
echo $_POST['firstname'] ?>">

   ... etc. ...

<?php
} else if ($_POST["op"] == "ds") {

Hope this helps.

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: m.fordleedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

attached mail follows:


Cristea Adrian schrieb:
> Hello peoples!
>
> short question: How can I count the usage of mail function in scripts?
>
> long description :D
>
> I have a webserver, and I want to limit the usage of mail function for
> each host I have there.. Notice that i have a couple of hundrest of
> virtual hosts (domains and subdomains) there, and i want to limit
> them, let`s say.. 100 mails per day.. there is any solution to do
> that? (i know there is, i saw that in a nwebhosting company) .. can
> you guide me find this solution?

This is not a PHP problem. The mail() function just uses the mail server
of the system it is running on. There are several solutions to the problem.

For exmaple: If you could configure your server so that the user's PHP
scripts run under their user ID (chroot/CGI), you can use the normal
mail quota system.

And: No, I can't help you any further on this.

OLLi
____________
Mal: "You only gotta scare him."
Jayna: "Pain is scary..."
[firefly]

attached mail follows:


One more point: If I were your customer and you'd deploy such
restrictions, I would leave you. Usually customers pay a fix fee for
some free traffic and then must pay for traffic exceeding those limits.
What they do with that traffic is none of your business.

There are a lot of companies sending out newsletters in a mothly fashion
to all of their 20000 users who requested to get that newsletter...

OLLi

____________
"Time continues to skip forward randomly. Details at eleven...This is
the news at eleven.
The mysterious and unexplained... Turning to Entertainment News. Teen
Singer Wendy might
just be the latest... won three Emmies last night...found dead in her
bathtub."
[Futurama 314]

attached mail follows:


On 10/18/05, Oliver Grätz <oliver.graetzarcor.de> wrote:
> Usually customers pay a fix fee for
> some free traffic and then must pay for traffic exceeding those limits.
> What they do with that traffic is none of your business.

You've obviously never been a hosting provider.

--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/

attached mail follows:


Greg Donald schrieb:
> On 10/18/05, Oliver Grätz <oliver.graetzarcor.de> wrote:
>
>>Usually customers pay a fix fee for
>>some free traffic and then must pay for traffic exceeding those limits.
>>What they do with that traffic is none of your business.
>
>
> You've obviously never been a hosting provider.

Did I say that? I was talking about being a customer.

The type of content that might be forbidden in some countries is off
topic. The question deals with restricting the amount of mails a
customer may send in a certain amount of time. This is what I mean by
"none of his business".

I simply spoke of what the provider puts in the contract and on this
point the provider guarantees it's customers something like 50GB free
traffic with a fee of 49ct for each GB of traffic exceeding this limit.
Nothing about any restrictions on the amount of data of a certain type.

If the provider decides to limit the amount of mails per day to 100 the
why not limiting the amount of web pages served to 500? Or "not more
than 20 files per directory"? Or "may not serve GIF images"? Such
restrictions are simply ridiculous.

OLLi
____________
All Glory to the Hypno-Toad!
[Futurama 307]

attached mail follows:


Hi,

Up to this point in time I used to construct my insert statements like this

$qid = mysql_query('INSERT INTO MYTABLE (
                                column1,
                                column2,
                               ) VALUES (
                                "'.$value1.'",
                                "'.$value2.'"
                               )');

However I understand it is better to remove the quote marks around an insert
if the column type is an integer. This is easy to do, however if the $value
is empty it causes a mysql error. Has anyone encountered this and found a
solution?

Thanks for your advice

attached mail follows:


Either cast your empty ints (which should make it zero) or do an if
(!isset($variable)) { $variable = 'NULL'; }

Ben

On Tue, 18 Oct 2005 12:15:41 -0400, "Shaun" <shaunthornburghhotmail.com>
wrote:

> Hi,
>
> Up to this point in time I used to construct my insert statements like
> this
>
> $qid = mysql_query('INSERT INTO MYTABLE (
> column1,
> column2,
> ) VALUES (
> "'.$value1.'",
> "'.$value2.'"
> )');
>
> However I understand it is better to remove the quote marks around an
> insert
> if the column type is an integer. This is easy to do, however if the
> $value
> is empty it causes a mysql error. Has anyone encountered this and found a
> solution?
>
> Thanks for your advice

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

attached mail follows:


What Ben said is correct, but I'd like to elaborate so you know why it's correct.

The INSERT statement you're trying to end up with is:

INSERT INTO MYTABLE (column1, column2) VALUES ('somevalue1', 'somevalue2')

I'm not sure why it wouldn't work if you ended up with:
INSERT INTO MYTABLE (column1, column2) VALUES ('', '')

That should work. You can set it so you can't have NULL, but dont know of anything that tells the database not to accept '' as a value (barring triggers or other things that check on insert).

Anyway, assuming that the first example is what youre going for, then it sounds like this is what you want if the first value is empty:

INSERT INTO MYTABLE (column1, column2) VALUES (NULL, 'somevalue2')

So I might try something like this:

$value1 = "";
$value2 = "somevalue";

if (is_empty($value1)) {
  $value1 = "NULL";
} else {
  $value1 = "'" . $value1 . "'";
}

if (is_empty($value2)) {
  $value2 = "NULL";
} else {
  $value2 = "'" . $value2 . "'";
}

$qid = mysql_query("INSERT INTO MYTABLE (column1, column2) VALUES ($value1, $value2)");

That way, if it's empty, you'll get NULL, otherwise you'll get 'somevalue'.

I use double quotes (") PHP variable values (yeah, I know.. some people have issues because it makes everything inside interpret..blah blah..) and use single quotes (') for SQL stuff. Looks like you do the opposite. Whatever works for you.

Good luck!

-TG

= = = Original message = = =

Either cast your empty ints (which should make it zero) or do an if
(!isset($variable)) $variable = 'NULL';

Ben

On Tue, 18 Oct 2005 12:15:41 -0400, "Shaun" <shaunthornburghhotmail.com>
wrote:

> Hi,
>
> Up to this point in time I used to construct my insert statements like
> this
>
> $qid = mysql_query('INSERT INTO MYTABLE (
> column1,
> column2,
> ) VALUES (
> "'.$value1.'",
> "'.$value2.'"
> )');
>
> However I understand it is better to remove the quote marks around an
> insert
> if the column type is an integer. This is easy to do, however if the
> $value
> is empty it causes a mysql error. Has anyone encountered this and found a
> solution?
>
> Thanks for your advice

___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

attached mail follows:


Hi Ben,

Thanks for your reply, woudn't that insert a string with a value of'NULL';?

""Ben Litton"" <ben.littongmail.com> wrote in message
news:op.syun6jsq1nzadmben.scienceboard.org...
> Either cast your empty ints (which should make it zero) or do an if
> (!isset($variable)) { $variable = 'NULL'; }
>
> Ben
>
> On Tue, 18 Oct 2005 12:15:41 -0400, "Shaun" <shaunthornburghhotmail.com>
> wrote:
>
>> Hi,
>>
>> Up to this point in time I used to construct my insert statements like
>> this
>>
>> $qid = mysql_query('INSERT INTO MYTABLE (
>> column1,
>> column2,
>> ) VALUES (
>> "'.$value1.'",
>> "'.$value2.'"
>> )');
>>
>> However I understand it is better to remove the quote marks around an
>> insert
>> if the column type is an integer. This is easy to do, however if the
>> $value
>> is empty it causes a mysql error. Has anyone encountered this and found a
>> solution?
>>
>> Thanks for your advice
>
>
>
> --
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

attached mail follows:


Yes, but NULL is a special thing to MySQL. If you don't quote 'NULL' it
just means 'empty' to mySQL. If your database schema allows NULLS (it's
optional), your insert will go through.

On Tue, 18 Oct 2005 13:10:32 -0400, "Shaun" <shaunthornburghhotmail.com>
wrote:

> Hi Ben,
>
> Thanks for your reply, woudn't that insert a string with a value
> of'NULL';?
>
> ""Ben Litton"" <ben.littongmail.com> wrote in message
> news:op.syun6jsq1nzadmben.scienceboard.org...
>> Either cast your empty ints (which should make it zero) or do an if
>> (!isset($variable)) { $variable = 'NULL'; }
>>
>> Ben
>>
>> On Tue, 18 Oct 2005 12:15:41 -0400, "Shaun"
>> <shaunthornburghhotmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> Up to this point in time I used to construct my insert statements like
>>> this
>>>
>>> $qid = mysql_query('INSERT INTO MYTABLE (
>>> column1,
>>> column2,
>>> ) VALUES (
>>> "'.$value1.'",
>>> "'.$value2.'"
>>> )');
>>>
>>> However I understand it is better to remove the quote marks around an
>>> insert
>>> if the column type is an integer. This is easy to do, however if the
>>> $value
>>> is empty it causes a mysql error. Has anyone encountered this and
>>> found a
>>> solution?
>>>
>>> Thanks for your advice
>>
>>
>>
>> --
>> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

attached mail follows:


Good explanation but I think he wanted to avoid quoting the integers. I
may be wrong, but I think not quoting integers is a decent practice
because it makes it easier to port your SQL over to a different database
if you later decide you must do so. Of course he could just add a single
quote to both sides of the string, whether it is empty or not, but if he
wants to go without any single quotes, he'll have to use NULL or a
numberic value for every column.

Everything you said is of course correct and a bit less lazy than my
explanation. I would just say that if he didn't want any single quotes at
all he could just replace your elses of $value = "'" . $value2 . "'"; with
$value = (int) $value1; OR $value1 = intval($value1).

If he decies not going to use quotes, it's probably a good idea to make
sure it's really an number or it'll break the query. He could also do an
is_numeric($value1) to make sure it really is one, but if you don't mind
converting an errant string to a zero, casting works fine.

As for the double quotes inside the parser thing, I do that too out of
laziness on occasion, but try not to. If the OP wants to stick to the
gospel and employ quotes he could make your else $value1 = '\'.$value1.\'';

_Ben

On Tue, 18 Oct 2005 13:42:19 -0400, <tg-phpgryffyndevelopment.com> wrote:

> What Ben said is correct, but I'd like to elaborate so you know why it's
> correct.
>
> The INSERT statement you're trying to end up with is:
>
> INSERT INTO MYTABLE (column1, column2) VALUES ('somevalue1',
> 'somevalue2')
>
>
> I'm not sure why it wouldn't work if you ended up with:
> INSERT INTO MYTABLE (column1, column2) VALUES ('', '')
>
> That should work. You can set it so you can't have NULL, but dont know
> of anything that tells the database not to accept '' as a value (barring
> triggers or other things that check on insert).
>
> Anyway, assuming that the first example is what youre going for, then it
> sounds like this is what you want if the first value is empty:
>
> INSERT INTO MYTABLE (column1, column2) VALUES (NULL, 'somevalue2')
>
> So I might try something like this:
>
> $value1 = "";
> $value2 = "somevalue";
>
> if (is_empty($value1)) {
> $value1 = "NULL";
> } else {
> $value1 = "'" . $value1 . "'";
> }
>
> if (is_empty($value2)) {
> $value2 = "NULL";
> } else {
> $value2 = "'" . $value2 . "'";
> }
>
> $qid = mysql_query("INSERT INTO MYTABLE (column1, column2) VALUES
> ($value1, $value2)");
>
> That way, if it's empty, you'll get NULL, otherwise you'll get
> 'somevalue'.
>
> I use double quotes (") PHP variable values (yeah, I know.. some people
> have issues because it makes everything inside interpret..blah blah..)
> and use single quotes (') for SQL stuff. Looks like you do the
> opposite. Whatever works for you.
>
> Good luck!
>
> -TG
>
> = = = Original message = = =
>
> Either cast your empty ints (which should make it zero) or do an if
> (!isset($variable)) $variable = 'NULL';
>
> Ben
>
> On Tue, 18 Oct 2005 12:15:41 -0400, "Shaun" <shaunthornburghhotmail.com>
> wrote:
>
>> Hi,
>>
>> Up to this point in time I used to construct my insert statements like
>> this
>>
>> $qid = mysql_query('INSERT INTO MYTABLE (
>> column1,
>> column2,
>> ) VALUES (
>> "'.$value1.'",
>> "'.$value2.'"
>> )');
>>
>> However I understand it is better to remove the quote marks around an
>> insert
>> if the column type is an integer. This is easy to do, however if the
>> $value
>> is empty it causes a mysql error. Has anyone encountered this and found
>> a
>> solution?
>>
>> Thanks for your advice
>
>
> ___________________________________________________________
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

attached mail follows:


$value2 = strlen($value2) ? $value2 : 'NULL';

On Tue, October 18, 2005 11:15 am, Shaun wrote:
> Hi,
>
> Up to this point in time I used to construct my insert statements like
> this
>
> $qid = mysql_query('INSERT INTO MYTABLE (
> column1,
> column2,
> ) VALUES (
> "'.$value1.'",
> "'.$value2.'"
> )');
>
> However I understand it is better to remove the quote marks around an
> insert
> if the column type is an integer. This is easy to do, however if the
> $value
> is empty it causes a mysql error. Has anyone encountered this and
> found a
> solution?
>
> Thanks for your advice
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Tue, October 18, 2005 12:42 pm, tg-phpgryffyndevelopment.com wrote:
> That should work. You can set it so you can't have NULL, but dont
> know of anything that tells the database not to accept '' as a value

Any database, other than MySQL, is *NOT* going to accept '' as an
integer value.

Because '' is not an integer by any stretch of the imagination.

If you don't care about ever porting your application to something
other than MySQL, then you can IGNORE the advice to not use '' on
integers.

If there's ANY possibility that some day somebody might maybe wanna
use a different database with your application, then don't confuse
strings with integers.

Actually, it might be better for your own
education/sanity/comprehension/documentation/code to not confuse
strings and integers with '' around integers in the SQL, but if
everything ELSE is good in your code, and it's "always going to be
MySQL" then it's fine.

Note that:

$value2 = 'NULL'; //PHP $value2 is a string

$query = "insert into (integer_field) values ($value2)";
//PHP $query is a string, but...

The place-holder in $value2 will be just: NULL

No quotes.

No apostrophes.

Not a string.

NULL

SQL NULL value representing "no value"

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Hi all,

Thanks for your replies, rather than check each vaule by name I am trying to
produce a more dynamic solution:

foreach ($_POST as $key => $value) {
  if ($value == '') {
    $_POST[$key] == 'NULL';
  }
}

I was expecting $_POST[$key] to be the same as $key, however this isnt the
case:

$key = city
$_POST[$key] = London
$value = London

Any ideas?

""Richard Lynch"" <ceol-i-e.com> wrote in message
news:6246.67.108.68.36.1129661387.squirrelwww.l-i-e.com...
> On Tue, October 18, 2005 12:42 pm, tg-phpgryffyndevelopment.com wrote:
>> That should work. You can set it so you can't have NULL, but dont
>> know of anything that tells the database not to accept '' as a value
>
> Any database, other than MySQL, is *NOT* going to accept '' as an
> integer value.
>
> Because '' is not an integer by any stretch of the imagination.
>
> If you don't care about ever porting your application to something
> other than MySQL, then you can IGNORE the advice to not use '' on
> integers.
>
> If there's ANY possibility that some day somebody might maybe wanna
> use a different database with your application, then don't confuse
> strings with integers.
>
> Actually, it might be better for your own
> education/sanity/comprehension/documentation/code to not confuse
> strings and integers with '' around integers in the SQL, but if
> everything ELSE is good in your code, and it's "always going to be
> MySQL" then it's fine.
>
> Note that:
>
> $value2 = 'NULL'; //PHP $value2 is a string
>
> $query = "insert into (integer_field) values ($value2)";
> //PHP $query is a string, but...
>
> The place-holder in $value2 will be just: NULL
>
> No quotes.
>
> No apostrophes.
>
> Not a string.
>
> NULL
>
> SQL NULL value representing "no value"
>
> --
> Like Music?
> http://l-i-e.com/artists.htm

attached mail follows:


Sorry everyone, I missed the "integer" requirement here. I apologize. And yes, '' isn't a good integer value and will throw an error.

That's what I get for not reading thoroughly enough :)

-TG

= = = Original message = = =

On Tue, October 18, 2005 12:42 pm, tg-phpgryffyndevelopment.com wrote:
> That should work. You can set it so you can't have NULL, but dont
> know of anything that tells the database not to accept '' as a value

Any database, other than MySQL, is *NOT* going to accept '' as an
integer value.

Because '' is not an integer by any stretch of the imagination.

If you don't care about ever porting your application to something
other than MySQL, then you can IGNORE the advice to not use '' on
integers.

If there's ANY possibility that some day somebody might maybe wanna
use a different database with your application, then don't confuse
strings with integers.

Actually, it might be better for your own
education/sanity/comprehension/documentation/code to not confuse
strings and integers with '' around integers in the SQL, but if
everything ELSE is good in your code, and it's "always going to be
MySQL" then it's fine.

Note that:

$value2 = 'NULL'; //PHP $value2 is a string

$query = "insert into (integer_field) values ($value2)";
//PHP $query is a string, but...

The place-holder in $value2 will be just: NULL

No quotes.

No apostrophes.

Not a string.

NULL

SQL NULL value representing "no value"

___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

attached mail follows:


You're using two =='s for your assignment.

On Tue, 18 Oct 2005 15:15:59 -0400, "Shaun" <shaunthornburghhotmail.com>
wrote:

> Hi all,
>
> Thanks for your replies, rather than check each vaule by name I am
> trying to
> produce a more dynamic solution:
>
> foreach ($_POST as $key => $value) {
> if ($value == '') {
> $_POST[$key] == 'NULL';
> }
> }
>
> I was expecting $_POST[$key] to be the same as $key, however this isnt
> the
> case:
>
> $key = city
> $_POST[$key] = London
> $value = London
>
> Any ideas?
>
> ""Richard Lynch"" <ceol-i-e.com> wrote in message
> news:6246.67.108.68.36.1129661387.squirrelwww.l-i-e.com...
>> On Tue, October 18, 2005 12:42 pm, tg-phpgryffyndevelopment.com wrote:
>>> That should work. You can set it so you can't have NULL, but dont
>>> know of anything that tells the database not to accept '' as a value
>>
>> Any database, other than MySQL, is *NOT* going to accept '' as an
>> integer value.
>>
>> Because '' is not an integer by any stretch of the imagination.
>>
>> If you don't care about ever porting your application to something
>> other than MySQL, then you can IGNORE the advice to not use '' on
>> integers.
>>
>> If there's ANY possibility that some day somebody might maybe wanna
>> use a different database with your application, then don't confuse
>> strings with integers.
>>
>> Actually, it might be better for your own
>> education/sanity/comprehension/documentation/code to not confuse
>> strings and integers with '' around integers in the SQL, but if
>> everything ELSE is good in your code, and it's "always going to be
>> MySQL" then it's fine.
>>
>> Note that:
>>
>> $value2 = 'NULL'; //PHP $value2 is a string
>>
>> $query = "insert into (integer_field) values ($value2)";
>> //PHP $query is a string, but...
>>
>> The place-holder in $value2 will be just: NULL
>>
>> No quotes.
>>
>> No apostrophes.
>>
>> Not a string.
>>
>> NULL
>>
>> SQL NULL value representing "no value"
>>
>> --
>> Like Music?
>> http://l-i-e.com/artists.htm

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

attached mail follows:


Shaun schrieb:
> $qid = mysql_query('INSERT INTO MYTABLE (
> column1,
> column2,
> ) VALUES (
> "'.$value1.'",
> "'.$value2.'"
> )');

A bit off-topic but important: Always make sure that you check the
contents of $value1 and $value2 before putting them into the query!
With

$value1 = 'xyz","xyz"); DELETE FROM MYTABLE;';

you might get surprising results!

This is called SQL injection and it's important to escape all the values
before putting them into the statement.

An even better solution are prepared statements! With PDO (available as
an extension for PHP 5.x) these are natively supported. You prepare the
statements without any of the values and call them with the values. The
engine automatically escapes your data.

OLLi
____________
Bug? That's not a bug, that's a feature.
[T. John Wendel]

attached mail follows:


Snippets are bad ;-)

Please post a full example that is _not_ working on your server.
Perhaps this is no PHP problem at all.

OLLi
____________
Byers: "What proof do you have?"
Bond: "I got this!"
Byers: "You're on the phone, Jimmy!"
[Lone Gunmen 09]

attached mail follows:


James schrieb:
> I have a PHP script running on server 1. I want it to call another
> script on server 2 to clean up some files. There may be tons of
> files and I don't want to wait until the second script is finished.
>
> Is there a way to asynchronously call the second PHP script?
>
> Right now I'm using fopen() to call the script on the second server.

Other option: Don't let the called script on server 2 do the work. Use
it to start another phpcli-script, then immediately send out the answer.
Something like

<?php
exec('/usr/bin/php cleanup.php &');
echo 'Cleanup started.';
?>

OLLi

____________
To the optimist, the glass is half full.
To the pessimist, the glass is half empty.
To the engineer, the glass is twice as big as it needs to be.

attached mail follows:


Olivier Cant said the following on 10/18/05 02:53:
> Hi list,
>
> I'm wondering if any one has any experience at connecting to a screen
> session under linux with a PHP script, and reading the pty output (and
> maybe writing somme stuff as well)
>
> I have an interactive program runing under screen which give me some
> status info, and I may also issue command to it and would like to
> interfce that whole thing using PHP... and screen because I can(t keep
> a console attached forever to it.
>
> Any idea ?

man screen suggests you might be attempting the impossible. Does your
program have to be run interactively or are there other non-interactive
ways to get your status information?

- Ben

attached mail follows:


I am using PHP5 as a CGI and I can't seem to figure out
how to set INI values through httpd.conf or .htaccess files.
Since PHP isn't built as a module, the php_admin_value
and php_value directives don't exist.

If I had a module version of PHP along side the CGI, this
would not help because as far as I know Apache won't parse
those php directives and pass them to the CGI instance.

I know I can call the CGI binary using a Handler and pass
var=value arguments using the '-d' flag, but I want to be able
to set them differently per Virtual Host.

Specifically, I want to set 'session.save_path' for each virtual
host to a directory other than the one set in php.ini that only
apache can read/write to since my suexec'd php cgi binary
can only write session data to a directory owned by the
virtual host user.

How can this be done? Any help would be appreciated, thanks.

-Jason Kovacs

attached mail follows:


Hi all,

Forgive this long diatribe, a bit off-topic I know, but it might
stimulate a good discussion...

I have built a few small apps in PHP before and, whilst they work, I
can't but help feeling that I go about the whole thing the WRONG way...

I am not a professional software person (far from it) but I am
reasonably competent in most things "technical". I trained in
Electronics, build my own PCs and Linux systems from scratch, have used
- just for fun - Java, Delphi, Visual Basic, PHP and a little C/C++.

I am now wanting to write my own application (using PHP of course) to do
something "really useful". And I am looking for some recommendations on
reading [books or links] about "how to design" my application and how to
think about the design in it's abstract form before I start writing
code.

Normally I end up writing little bits of code to solve small problems
and then sort of kludging them together to do something useful.

I would really like to try and go about this one the RIGHT way.

Thanks in advance.

Al

attached mail follows:


Zandstra's "PHP 5 objects patterns practice" has been getting
excellent reviews. i also recommend it.

http://www.amazon.com/gp/product/1590593804/

On Oct 18, 2005, at 1:43 PM, Alan Lord wrote:

> Hi all,
>
> Forgive this long diatribe, a bit off-topic I know, but it might
> stimulate a good discussion...
>
> I have built a few small apps in PHP before and, whilst they work, I
> can't but help feeling that I go about the whole thing the WRONG
> way...
>
> I am not a professional software person (far from it) but I am
> reasonably competent in most things "technical". I trained in
> Electronics, build my own PCs and Linux systems from scratch, have
> used
> - just for fun - Java, Delphi, Visual Basic, PHP and a little C/C++.
>
> I am now wanting to write my own application (using PHP of course)
> to do
> something "really useful". And I am looking for some
> recommendations on
> reading [books or links] about "how to design" my application and
> how to
> think about the design in it's abstract form before I start writing
> code.
>
> Normally I end up writing little bits of code to solve small problems
> and then sort of kludging them together to do something useful.
>
> I would really like to try and go about this one the RIGHT way.
>
> Thanks in advance.
>
> Al
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
>

attached mail follows:


I liked Schlossnagle's 'Advanced PHP Programming'
http://www.amazon.com/exec/obidos/tg/detail/-/0672325616/qid=1129664190/sr=8-1/ref=pd_bbs_1/002-6178615-3953615?v=glance&s=books&n=507846

It has a little primer on a variety of things but is for the php5 user.
You might also want to read a book called Code Complete

http://www.amazon.com/exec/obidos/tg/detail/-/0735619670/qid=1129664509/sr=8-1/ref=pd_bbs_1/002-6178615-3953615?v=glance&s=books&n=507846

It's probably written more for the C/C++/Java crowd, but is meant to
mostly be language neutral. It gives some great pointers on software
construction. Some seems fairly obvious, but if you're self-taught (like I
am) then you're sure to take a few things away from it.

Ben

On Tue, 18 Oct 2005 14:43:36 -0400, "Alan Lord" <alan.lorddsl.pipex.com>
wrote:

> Hi all,
>
> Forgive this long diatribe, a bit off-topic I know, but it might
> stimulate a good discussion...
>
> I have built a few small apps in PHP before and, whilst they work, I
> can't but help feeling that I go about the whole thing the WRONG way...
>
> I am not a professional software person (far from it) but I am
> reasonably competent in most things "technical". I trained in
> Electronics, build my own PCs and Linux systems from scratch, have used
> - just for fun - Java, Delphi, Visual Basic, PHP and a little C/C++.
>
> I am now wanting to write my own application (using PHP of course) to do
> something "really useful". And I am looking for some recommendations on
> reading [books or links] about "how to design" my application and how to
> think about the design in it's abstract form before I start writing
> code.
>
> Normally I end up writing little bits of code to solve small problems
> and then sort of kludging them together to do something useful.
>
> I would really like to try and go about this one the RIGHT way.
>
> Thanks in advance.
>
> Al

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

attached mail follows:


From a practical view:

*For big web projects:*
Make a plan! Do not start to write code before you exactly know what you
want to do. An important concept in the development of large web
applications is the MVC princinple (Model View Controller) which
basically urges you to seperate the data and the display. Get an insight
into MVC, it will help you in designing your application and it will
come in handy if you decide to implement more ways of displaying your
data than you thought of in the first place.

*For a certain problem:*
Do not reinvent the wheel! PHP is a language with a really large
function library. The amount of extensions that are directly available
is so high that chances are good you'll find a solution right there as a
function ready to use. So: Dig through the documentation at php.net!
Learn what extensions there are. Use the comments in the documentation,
they provide valuable examples.
If you can't solve your problem with the internal functions: Search the
web! The PEAR repository offers a lot of packages solving a lot of
problems BUT they are not always the best solution. Projects like AdoDB,
Propel etc. show that there are often more solutions than you wanted. So
do not compromise too much: If a solution does not exactly fit your
needs, continue the search.

*For the next project:*
DRY (Don't repeat yourself)! Code you've written once can come in handy
for the next project. So start to seperate the code you write into
application specific code and library code. You can reuse your library
for all of your projects.

*For any large development:*
It's a good idea to use a versioning system. Subversion is free and
ready to install on any Apache server. With PHP it's also an ideal
solution for deployment: Just make a release tag and check it out on
your production server. Add some config and off you go!

Happy Development!

OLLi
____________
"You see, Mr. President: The worlds hates America. And for good reason.
(I wont bother going into details)"
[24 319]

attached mail follows:


Hi everyone,

Just thought you might like to know that Lampshade, our previously
closed PHP framework, is now open-source:

http://www.thinkcomputer.com/corporate/news/pressreleases.html?id=24

Aaron

Aaron Greenspan
President & CEO
Think Computer Corporation

http://www.thinkcomputer.com

attached mail follows:


On Tue, October 18, 2005 8:30 am, Jochem Maas wrote:
> and the next site that displays a PDF when I wasn't expecting it
> and I have to spend the next five minutes waiting for the b'std to
> load
> (with the alternative being to KILL the browser - losing all open
> pages
> in the process) ... might just make me snap ;-)

Fire up Acrobat reader and change the preferences to only display
documents OUTSIDE the browser context.

Then you can nuke Acrobat and keep surfin'

I do it all the time.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


I'm diving into the gd functions for the first time, and I'm having a
problem creating a white background for an image when using
imagecreatetruecolor(). The manual says that this function will create
a _black_ image, but looking at imagecolorallocate() it says that the
first call to this function fills the background color, and they have
examples like this...

$im = imagecreatetruecolor('example.jpg');
// sets background to red
$background = imagecolorallocate($im, 255, 0, 0);

So, thinking that I could make a this with a white background, I did this...

$im = imagecreatetruecolor ( 140, 140 );
$bg = imagecolorallocate ( $im, 255, 255, 255 );
$orgimg = imagecreatefromjpeg ( $image_data['image'] );

imagecopyresampled ( $im, $orgimg, $thumb_x_offset, $thumb_y_offset, 0,
0, $new_thumb_x, $new_thumb_y, $image_data['image_x'],
$image_data['image_y'] );

imagejpeg ( $im, $image_paths['thumbs'] . $file_name );

And that creates the image with the right sizes and positions, but the
background is black. Is there something wrong in my code, or is the
manual wrong on the imagecolorallocate() function? TIA.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
johnkegworks.com

attached mail follows:


John Nichel wrote:
> I'm diving into the gd functions for the first time, and I'm having a
> problem creating a white background for an image when using
> imagecreatetruecolor(). The manual says that this function will create
> a _black_ image, but looking at imagecolorallocate() it says that the
> first call to this function fills the background color, and they have
> examples like this...
>
> $im = imagecreatetruecolor('example.jpg');
> // sets background to red
> $background = imagecolorallocate($im, 255, 0, 0);
>
> So, thinking that I could make a this with a white background, I did
> this...
>
> $im = imagecreatetruecolor ( 140, 140 );
> $bg = imagecolorallocate ( $im, 255, 255, 255 );
> $orgimg = imagecreatefromjpeg ( $image_data['image'] );
>
> imagecopyresampled ( $im, $orgimg, $thumb_x_offset, $thumb_y_offset, 0,
> 0, $new_thumb_x, $new_thumb_y, $image_data['image_x'],
> $image_data['image_y'] );
>
> imagejpeg ( $im, $image_paths['thumbs'] . $file_name );
>
> And that creates the image with the right sizes and positions, but the
> background is black. Is there something wrong in my code, or is the
> manual wrong on the imagecolorallocate() function? TIA.
>

The manual is _my_ friend....at least the comments in the manual are. I
had to use the imagefill() function...

$im = imagecreatetruecolor ( 140, 140 );
$bg = imagecolorallocate ( $im, 255, 255, 255 );
imagefill ( $im, 0, 0, $bg );

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
johnkegworks.com

attached mail follows:


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
Hello,

I am trying to authenticate against an Active Directory 2003 server
using LDAPS. I have the cert from the server, however i'm not exactly
sure how to set it up so that php will recognize it. I have read the
docs and googled a bit, but everyone seems to have a different way.
What is the best way to accomplish this?

- --
Aaron Axelsen
listsfrozenpc.net

Great hosting, low prices. Modevia Web Services LLC --
http://www.modevia.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
iD8DBQFDVWc2uucONIvD0AMRApAhAJ4uc7kriaMLXavTWHz6eFUYZjcLSgCfWQgo
wypmsI10a/J5goQi8cp1ZuU=
=fpYX
-----END PGP SIGNATURE-----

attached mail follows:


Hi

OK I am being lazy but unnecessarily reinventing the wheel is not my idea of
fun.

I need a script to populate database fields for year, month, day of month, day
of week to a rule

e.g start year, month, day end year month day
exclude [days of week] [from year, month, day to year, month, day] [specific
dates]

If no one has one you can point me to then contact me in a week or two and
ask for mine <chuckles>

thanks
david

--
40 yrs navigating and computing in blue waters.
English Owner & Captain of British Registered 60' bluewater Ketch S/V Taurus.
 Currently in San Diego, CA. Sailing bound for Europe via Panama Canal after
completing engineroom refit.

attached mail follows:


hello all.

I've managed to create files uploads pages in the past (dont remember if alredy with php 5).

till now, i havent need for testing or using.
today, i've tried to test an upload page (a very simple one) with php 5.0.5 and i was
unable to do it.

the script always says it was sucessful to upload the file, but the destination
directory was always empty...
even when checking the $_FILES global

$_FILES['var_name']['tmp_name'] and
$_FILES['var_name']['name'] and
$_FILES['var_name']['size'], the vars alwyas return empty values...

is there any issue with php5 about files uploads ?

in php.ini i set the temp directory to /tmp and still nothing works...

Cheers,

Bruno Santos

--
Open WebMail Project (http://openwebmail.org)

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

attached mail follows:


I've never read a book to do PHP or anything else. I simply google and go to
site after site reading tutorials and docs then making a sample page with
what I've read and learned.

--Death Gauge
"How do you gauge your death?!"

----Original Message Follows----
From: "Alan Lord" <alan.lorddsl.pipex.com>
To: <php-generallists.php.net>
Subject: [PHP] Recommended Reading?
Date: Tue, 18 Oct 2005 19:43:36 +0100

Hi all,

Forgive this long diatribe, a bit off-topic I know, but it might
stimulate a good discussion...

I have built a few small apps in PHP before and, whilst they work, I
can't but help feeling that I go about the whole thing the WRONG way...

I am not a professional software person (far from it) but I am
reasonably competent in most things "technical". I trained in
Electronics, build my own PCs and Linux systems from scratch, have used
- just for fun - Java, Delphi, Visual Basic, PHP and a little C/C++.

I am now wanting to write my own application (using PHP of course) to do
something "really useful". And I am looking for some recommendations on
reading [books or links] about "how to design" my application and how to
think about the design in it's abstract form before I start writing
code.

Normally I end up writing little bits of code to solve small problems
and then sort of kludging them together to do something useful.

I would really like to try and go about this one the RIGHT way.

Thanks in advance.

Al

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

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

attached mail follows:


Is there a OS java (or other) html editor I can implement on a Web page.
I want a user to type text, use bold, italics, etc.
I would then store the html in a MySQl record and then use php to insert
the edited text.
I've seen some packaged, in Moodle for example.
John