Re: [PHP] Coding Web search engine in PHP

2012-08-06 Thread Daniel Brown
On Mon, Aug 6, 2012 at 1:42 PM, shiplu  wrote:
>
> Thanks Daniel for clearing. I am pretty bad in English. :(

Don't sell yourself short.  Your English seems fine to me ---
better than many native-speakers.

-- 

Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] Coding Web search engine in PHP

2012-08-06 Thread shiplu
On Mon, Aug 6, 2012 at 11:22 PM, Daniel Brown  wrote:

> On Mon, Aug 6, 2012 at 1:15 PM, shiplu  wrote:
> >> Where *do* come up with those names :)
> >>
> >
> > Sorry I couldn't understand the meaning of your sentence. May be this is
> > due to cultural difference.
> >
> > Anyway, Solr is a search engine. Nutch is a crawler.  Both can be
> > integrated. Then one can send query to solr server from php using api.
> See
> > http://wiki.apache.org/solr/SolPHP
>
> She was just giggling about the silly-sounding names for
> high-quality products.
>
> --
> 
> Network Infrastructure Manager
> http://www.php.net/
>


Thanks Daniel for clearing. I am pretty bad in English. :(

-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader


Re: [PHP] Coding Web search engine in PHP

2012-08-06 Thread Daniel Brown
On Mon, Aug 6, 2012 at 1:15 PM, shiplu  wrote:
>> Where *do* come up with those names :)
>>
>
> Sorry I couldn't understand the meaning of your sentence. May be this is
> due to cultural difference.
>
> Anyway, Solr is a search engine. Nutch is a crawler.  Both can be
> integrated. Then one can send query to solr server from php using api. See
> http://wiki.apache.org/solr/SolPHP

She was just giggling about the silly-sounding names for
high-quality products.

-- 

Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] Coding Web search engine in PHP

2012-08-06 Thread shiplu
> Where *do* come up with those names :)
>

Sorry I couldn't understand the meaning of your sentence. May be this is
due to cultural difference.

Anyway, Solr is a search engine. Nutch is a crawler.  Both can be
integrated. Then one can send query to solr server from php using api. See
http://wiki.apache.org/solr/SolPHP


-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader


Re: [PHP] Coding Web search engine in PHP

2012-08-06 Thread tamouse mailing lists
On Aug 6, 2012 7:33 AM, "shiplu"  wrote:
> Solr with Nutch will do it.

Where *do* come up with those names :)


Re: [PHP] Coding Web search engine in PHP

2012-08-06 Thread shiplu
On Mon, Aug 6, 2012 at 8:24 PM, Ansry User 01 wrote:

> We are trying to code a very simple and customized search engine for
> internal purposes. Please suggest if the PHP is the way to go or suggest
> the alternatives??
>
> It would be great if you can lead us to the links which would give us a
> start!!
>
> Thanks
>
>

Solr with Nutch will do it. One is search server and other is crawler. You
need both.
Google these terms you'll get to the right direction.


-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader


Re: [PHP] Coding Web search engine in PHP

2012-08-06 Thread Gibbs

On 06/08/12 15:24, Ansry User 01 wrote:

We are trying to code a very simple and customized search engine for internal 
purposes. Please suggest if the PHP is the way to go or suggest the 
alternatives??

It would be great if you can lead us to the links which would give us a start!!

Thanks



This is a very vague question, it really depends. Some recommendations 
off the top of my head:


http://lucene.apache.org/solr/
http://sphinxsearch.com/

Gibbs

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



Re: [PHP] Coding Web search engine in PHP

2012-08-06 Thread Vikash Kumar
On 6 August 2012 19:54, Ansry User 01  wrote:

> We are trying to code a very simple and customized search engine for
> internal purposes. Please suggest if the PHP is the way to go or suggest
> the alternatives??
>
> It would be great if you can lead us to the links which would give us a
> start!!
>
> Thanks
>


try solr. http://lucene.apache.org/solr/


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


Re: [PHP] Coding for email response forms

2009-01-31 Thread Edmund Hertle
2009/1/30 Tom 

>
> "Shawn McKenzie"  wrote in message
> news:47.36.08436.e8b80...@pb1.pair.com...
> > Tom wrote:
> >> "Clancy"  wrote in message
> >> news:c77vn4pri9tsbaqg9avv3i7dnfb8nvk...@4ax.com...
> >>> On Mon, 26 Jan 2009 17:57:29 -0600, obeli...@comcast.net ("Tom")
> wrote:
> >>>
> >>> ..
> > Also make sure there aren't line returns or any nonsense like that in
> > the to & subjects.  Look up email header injection.  Your script
> might
> > become quite popular at advertising p3n1s pills otherwise. :)
>  Thanks I'll check it out. I tried including the above code but I still
>  can't
>  seem to get it to work. Must be missing something.
> 
>  Thanks,
> >>> David Powers books "PHP for Dreamweaver xxx" (Friends of Ed) give very
> >>> clear  instructions
> >>> on installing PHP and implementing the essential items such as this.
> >>>
> >> Thanks I'll check it out.
> >>
> >>  I am no Coder and don't have a lot of time to devote to these things,
> to
> >> busy running a business, but I do enjoy learning how things work which
> is
> >> why I have taken this on. Website is just for informational display as
> >> they
> >> don't produce much in the way of mortgage originations. I was hoping to
> >> get
> >> something along the lines of the actually coding needed to pull this
> off.
> >> I
> >> have spent every available moment over the last three  months on this
> >> website (which is my first) with nothing more than an online beginners
> >> course in CS3 & CSS. I have appreciated everyones feedbackl. If anyone
> >> has
> >> coding I can cut and paste with just a few adjustments on my end that
> >> would
> >> be great.
> >>
> >> Thanks,
> >> Tom
> >>
> >>
> > You have the code.  You just need to create a contact.php file and put
> > the email specific PHP in it and then modify your form to have
> > method="post" action="contact.php".
> >
> > --
> > Thanks!
> > -Shawn
> > http://www.spidean.com
>
> The following link shows my PHP configurations.
> http://www.richlandmtg.com/test.php Are there any that should be set
> differently? I noticed the system is Linux.
>

You should never let a php_info() file be accesibly to the public! Security
concerns!
And your problem has nothing to do with your php configuration or if your
server is linux or windows or...


Re: [PHP] Coding for email response forms

2009-01-30 Thread Tom

"Shawn McKenzie"  wrote in message 
news:47.36.08436.e8b80...@pb1.pair.com...
> Tom wrote:
>> "Clancy"  wrote in message
>> news:c77vn4pri9tsbaqg9avv3i7dnfb8nvk...@4ax.com...
>>> On Mon, 26 Jan 2009 17:57:29 -0600, obeli...@comcast.net ("Tom") wrote:
>>>
>>> ..
> Also make sure there aren't line returns or any nonsense like that in
> the to & subjects.  Look up email header injection.  Your script might
> become quite popular at advertising p3n1s pills otherwise. :)
 Thanks I'll check it out. I tried including the above code but I still
 can't
 seem to get it to work. Must be missing something.

 Thanks,
>>> David Powers books "PHP for Dreamweaver xxx" (Friends of Ed) give very
>>> clear  instructions
>>> on installing PHP and implementing the essential items such as this.
>>>
>> Thanks I'll check it out.
>>
>>  I am no Coder and don't have a lot of time to devote to these things, to
>> busy running a business, but I do enjoy learning how things work which is
>> why I have taken this on. Website is just for informational display as 
>> they
>> don't produce much in the way of mortgage originations. I was hoping to 
>> get
>> something along the lines of the actually coding needed to pull this off. 
>> I
>> have spent every available moment over the last three  months on this
>> website (which is my first) with nothing more than an online beginners
>> course in CS3 & CSS. I have appreciated everyones feedbackl. If anyone 
>> has
>> coding I can cut and paste with just a few adjustments on my end that 
>> would
>> be great.
>>
>> Thanks,
>> Tom
>>
>>
> You have the code.  You just need to create a contact.php file and put
> the email specific PHP in it and then modify your form to have
> method="post" action="contact.php".
>
> -- 
> Thanks!
> -Shawn
> http://www.spidean.com

The following link shows my PHP configurations.
http://www.richlandmtg.com/test.php Are there any that should be set 
differently? I noticed the system is Linux.

T 



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



Re: [PHP] Coding for email response forms

2009-01-28 Thread Shawn McKenzie
Tom wrote:
> "Clancy"  wrote in message 
> news:c77vn4pri9tsbaqg9avv3i7dnfb8nvk...@4ax.com...
>> On Mon, 26 Jan 2009 17:57:29 -0600, obeli...@comcast.net ("Tom") wrote:
>>
>> ..
 Also make sure there aren't line returns or any nonsense like that in
 the to & subjects.  Look up email header injection.  Your script might
 become quite popular at advertising p3n1s pills otherwise. :)
>>> Thanks I'll check it out. I tried including the above code but I still 
>>> can't
>>> seem to get it to work. Must be missing something.
>>>
>>> Thanks,
>> David Powers books "PHP for Dreamweaver xxx" (Friends of Ed) give very 
>> clear  instructions
>> on installing PHP and implementing the essential items such as this.
>>
> Thanks I'll check it out.
> 
>  I am no Coder and don't have a lot of time to devote to these things, to 
> busy running a business, but I do enjoy learning how things work which is 
> why I have taken this on. Website is just for informational display as they 
> don't produce much in the way of mortgage originations. I was hoping to get 
> something along the lines of the actually coding needed to pull this off. I 
> have spent every available moment over the last three  months on this 
> website (which is my first) with nothing more than an online beginners 
> course in CS3 & CSS. I have appreciated everyones feedbackl. If anyone has 
> coding I can cut and paste with just a few adjustments on my end that would 
> be great.
> 
> Thanks,
> Tom 
> 
> 
You have the code.  You just need to create a contact.php file and put
the email specific PHP in it and then modify your form to have
method="post" action="contact.php".

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Coding for email response forms

2009-01-28 Thread Tom
"Clancy"  wrote in message 
news:c77vn4pri9tsbaqg9avv3i7dnfb8nvk...@4ax.com...
> On Mon, 26 Jan 2009 17:57:29 -0600, obeli...@comcast.net ("Tom") wrote:
>
> ..
>>>
>>> Also make sure there aren't line returns or any nonsense like that in
>>> the to & subjects.  Look up email header injection.  Your script might
>>> become quite popular at advertising p3n1s pills otherwise. :)
>>
>>Thanks I'll check it out. I tried including the above code but I still 
>>can't
>>seem to get it to work. Must be missing something.
>>
>>Thanks,
>
> David Powers books "PHP for Dreamweaver xxx" (Friends of Ed) give very 
> clear  instructions
> on installing PHP and implementing the essential items such as this.
>
Thanks I'll check it out.

 I am no Coder and don't have a lot of time to devote to these things, to 
busy running a business, but I do enjoy learning how things work which is 
why I have taken this on. Website is just for informational display as they 
don't produce much in the way of mortgage originations. I was hoping to get 
something along the lines of the actually coding needed to pull this off. I 
have spent every available moment over the last three  months on this 
website (which is my first) with nothing more than an online beginners 
course in CS3 & CSS. I have appreciated everyones feedbackl. If anyone has 
coding I can cut and paste with just a few adjustments on my end that would 
be great.

Thanks,
Tom 



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



Re: [PHP] Coding for email response forms

2009-01-27 Thread Shawn McKenzie
Tom wrote:
> "Edmund Hertle"  wrote in message 
> news:f7ed91b20901261644y125f71aer3e0b70735c949...@mail.gmail.com...
>> 2009/1/26 Tom 
>>
>>> "Shawn McKenzie"  wrote in message
>>> news:497e3ab9.2060...@mckenzies.net...
>>>>
>>>> Shawn McKenzie wrote:
>>>>> Tom Scott wrote:
>>>>>> - Original Message - From: "Shawn McKenzie"
>>>>>> 
>>>>>> Newsgroups: php.general
>>>>>> To: 
>>>>>> Sent: Monday, January 26, 2009 3:52 PM
>>>>>> Subject: Re: [PHP] Coding for email response forms
>>>>>>
>>>>>>
>>>>>>> Tom wrote:
>>>>>>>> "Shawn McKenzie" <> wrote in message
>>>>>>>> news:a0.87.62571.3d92e...@pb1.pair.com...
>>>>>>>>> Tom wrote:
>>>>>>>>>> My Hosting site said that I needed to include the PHP otherwise
>>>>>>>>>> the form
>>>>>>>>>> won't work. I need to know where to include my email info to get
>>>>>>>>>> this set
>>>>>>>>>> up
>>>>>>>>>> don't I? What do you suggest?
>>>>>>>>>> T
>>>>>>>>>> "Daniel Brown"  wrote in message
>>>>>>>>>> news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com.
>>> ..
>>>>>>>>>>> On Mon, Jan 26, 2009 at 15:57, Tom  wrote:
>>>>>>>>>>>> I am a new user of PHP, and am using Dreamweaver CS3 for the
>>>>>>>>>>>> webpages.
>>>>>>>>>>>> The
>>>>>>>>>>>> following page has my form but the submit button is not working
>>>>>>>>>>>> properly.
>>>>>>>>>>>> http://www.richlandmtg.com/contacts.html
>>>>>>>>>>>> What code is needed and where does it get placed in the page.? 
>>>>>>>>>>>> I
>>>>>>>>>>>> thought
>>>>>>>>>>>> CS3
>>>>>>>>>>>> took care of this.
>>>>>>>>>>>Tom,
>>>>>>>>>>>
>>>>>>>>>>>This issue has nothing at all to do with PHP.  This is all
>>>>>>>>>>> client
>>>>>>>>>>> side (JavaScript and HTML).
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> 
>>>>>>>>>>> daniel.br...@parasane.net || danbr...@php.net
>>>>>>>>>>> http://www.parasane.net/ || http://www.pilotpig.net/
>>>>>>>>>>> Unadvertised dedicated server deals, too low to print - email me
>>>>>>>>>>> to find
>>>>>>>>>>> out!
>>>>>>>>> What you have now is a form that when submitted sends the data to
>>>>>>>>> itself.  So you either need to include some php in this file to
>>>>>>>>> gather
>>>>>>>>> up the data and email it when submitted, or submit to another file
>>>>>>>>> that
>>>>>>>>> does that.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Thanks!
>>>>>>>>> -Shawn
>>>>>>>>> http://www.spidean.com
>>>>>>>> Shawn,
>>>>>>>> So would that look something like this:
>>>>>>>> >>>>>>> if ($_SERVER['REQUEST_METHOD'] == "POST") {
>>>>>>>>
>>>>>>>> // Just to be safe, I strip out HTML tags
>>>>>>>> $realname = strip_tags($realname);
>>>>>>>> $email = strip_tags($email);
>>>>>>>> $feedback = strip_tags($feedback);
>>>>>>>>
>>>>>>>> // set the variables
>>>>>>>> // replace $...@mysite.com with your email
>>>>>>>> $sendto = "$...@mysite.com";
>>>>>>>> $s

RE: [PHP] Coding for email response forms

2009-01-27 Thread Boyd, Todd M.
> -Original Message-
> From: Tom [mailto:obeli...@comcast.net]
> Sent: Tuesday, January 27, 2009 9:58 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Coding for email response forms
> 
> 
> "Edmund Hertle"  wrote in message
> news:f7ed91b20901261644y125f71aer3e0b70735c949...@mail.gmail.com...
> > 2009/1/26 Tom 
> >
> >>
> >> "Shawn McKenzie"  wrote in message
> >> news:497e3ab9.2060...@mckenzies.net...
> >> >
> >> >
> >> > Shawn McKenzie wrote:
> >> >>
> >> >> Tom Scott wrote:
> >> >>> - Original Message - From: "Shawn McKenzie"
> >> >>> 
> >> >>> Newsgroups: php.general
> >> >>> To: 
> >> >>> Sent: Monday, January 26, 2009 3:52 PM
> >> >>> Subject: Re: [PHP] Coding for email response forms
> >> >>>
> >> >>>
> >> >>>> Tom wrote:
> >> >>>>> "Shawn McKenzie" <> wrote in message
> >> >>>>> news:a0.87.62571.3d92e...@pb1.pair.com...
> >> >>>>>> Tom wrote:
> >> >>>>>>> My Hosting site said that I needed to include the PHP
> otherwise
> >> >>>>>>> the form
> >> >>>>>>> won't work. I need to know where to include my email info
to
> get
> >> >>>>>>> this set
> >> >>>>>>> up
> >> >>>>>>> don't I? What do you suggest?
> >> >>>>>>> T
> >> >>>>>>> "Daniel Brown"  wrote in message
> >> >>>>>>>
> news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com.
> >> ..
> >> >>>>>>>> On Mon, Jan 26, 2009 at 15:57, Tom 
> wrote:
> >> >>>>>>>>> I am a new user of PHP, and am using Dreamweaver CS3 for
> the
> >> >>>>>>>>> webpages.
> >> >>>>>>>>> The
> >> >>>>>>>>> following page has my form but the submit button is not
> working
> >> >>>>>>>>> properly.
> >> >>>>>>>>> http://www.richlandmtg.com/contacts.html
> >> >>>>>>>>> What code is needed and where does it get placed in the
> page.?
> >> >>>>>>>>> I
> >> >>>>>>>>> thought
> >> >>>>>>>>> CS3
> >> >>>>>>>>> took care of this.
> >> >>>>>>>>Tom,
> >> >>>>>>>>
> >> >>>>>>>>This issue has nothing at all to do with PHP.  This is
> all
> >> >>>>>>>> client
> >> >>>>>>>> side (JavaScript and HTML).
> >> >>>>>> What you have now is a form that when submitted sends the
> data to
> >> >>>>>> itself.  So you either need to include some php in this file
> to
> >> >>>>>> gather
> >> >>>>>> up the data and email it when submitted, or submit to
another
> file
> >> >>>>>> that
> >> >>>>>> does that.
> >> >>>>> Shawn,
> >> >>>>> So would that look something like this:
> >> >>>>>  >> >>>>> if ($_SERVER['REQUEST_METHOD'] == "POST") {
> >> >>>>>
> >> >>>>> // Just to be safe, I strip out HTML tags
> >> >>>>> $realname = strip_tags($realname);
> >> >>>>> $email = strip_tags($email);
> >> >>>>> $feedback = strip_tags($feedback);
> >> >>>>>
> >> >>>>> // set the variables
> >> >>>>> // replace $...@mysite.com with your email
> >> >>>>> $sendto = "$...@mysite.com";
> >> >>>>> $subject = "Sending Email Feedback From My Website";
> >> >>>>> $message = "$realname, $email\n\n$feedback";
> >> >>>>>
> >> >>>>> // send the email
> >> >>>>> mail($sendto, $subject, $message);
> >> >>>>>
>

Re: [PHP] Coding for email response forms

2009-01-27 Thread Tom

"Edmund Hertle"  wrote in message 
news:f7ed91b20901261644y125f71aer3e0b70735c949...@mail.gmail.com...
> 2009/1/26 Tom 
>
>>
>> "Shawn McKenzie"  wrote in message
>> news:497e3ab9.2060...@mckenzies.net...
>> >
>> >
>> > Shawn McKenzie wrote:
>> >>
>> >> Tom Scott wrote:
>> >>> - Original Message - From: "Shawn McKenzie"
>> >>> 
>> >>> Newsgroups: php.general
>> >>> To: 
>> >>> Sent: Monday, January 26, 2009 3:52 PM
>> >>> Subject: Re: [PHP] Coding for email response forms
>> >>>
>> >>>
>> >>>> Tom wrote:
>> >>>>> "Shawn McKenzie" <> wrote in message
>> >>>>> news:a0.87.62571.3d92e...@pb1.pair.com...
>> >>>>>> Tom wrote:
>> >>>>>>> My Hosting site said that I needed to include the PHP otherwise
>> >>>>>>> the form
>> >>>>>>> won't work. I need to know where to include my email info to get
>> >>>>>>> this set
>> >>>>>>> up
>> >>>>>>> don't I? What do you suggest?
>> >>>>>>> T
>> >>>>>>> "Daniel Brown"  wrote in message
>> >>>>>>> news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com.
>> ..
>> >>>>>>>> On Mon, Jan 26, 2009 at 15:57, Tom  wrote:
>> >>>>>>>>> I am a new user of PHP, and am using Dreamweaver CS3 for the
>> >>>>>>>>> webpages.
>> >>>>>>>>> The
>> >>>>>>>>> following page has my form but the submit button is not working
>> >>>>>>>>> properly.
>> >>>>>>>>> http://www.richlandmtg.com/contacts.html
>> >>>>>>>>> What code is needed and where does it get placed in the page.? 
>> >>>>>>>>> I
>> >>>>>>>>> thought
>> >>>>>>>>> CS3
>> >>>>>>>>> took care of this.
>> >>>>>>>>Tom,
>> >>>>>>>>
>> >>>>>>>>This issue has nothing at all to do with PHP.  This is all
>> >>>>>>>> client
>> >>>>>>>> side (JavaScript and HTML).
>> >>>>>>>>
>> >>>>>>>> --
>> >>>>>>>> 
>> >>>>>>>> daniel.br...@parasane.net || danbr...@php.net
>> >>>>>>>> http://www.parasane.net/ || http://www.pilotpig.net/
>> >>>>>>>> Unadvertised dedicated server deals, too low to print - email me
>> >>>>>>>> to find
>> >>>>>>>> out!
>> >>>>>> What you have now is a form that when submitted sends the data to
>> >>>>>> itself.  So you either need to include some php in this file to
>> >>>>>> gather
>> >>>>>> up the data and email it when submitted, or submit to another file
>> >>>>>> that
>> >>>>>> does that.
>> >>>>>>
>> >>>>>>
>> >>>>>> --
>> >>>>>> Thanks!
>> >>>>>> -Shawn
>> >>>>>> http://www.spidean.com
>> >>>>> Shawn,
>> >>>>> So would that look something like this:
>> >>>>> > >>>>> if ($_SERVER['REQUEST_METHOD'] == "POST") {
>> >>>>>
>> >>>>> // Just to be safe, I strip out HTML tags
>> >>>>> $realname = strip_tags($realname);
>> >>>>> $email = strip_tags($email);
>> >>>>> $feedback = strip_tags($feedback);
>> >>>>>
>> >>>>> // set the variables
>> >>>>> // replace $...@mysite.com with your email
>> >>>>> $sendto = "$...@mysite.com";
>> >>>>> $subject = "Sending Email Feedback From My Website";
>> >>>>> $message = "$realname, $email\n\n$feedback";
>> >>>>>
>> >>>>> // send the email
>

Re: [PHP] Coding for email response forms

2009-01-26 Thread Edmund Hertle
2009/1/26 Tom 

>
> "Shawn McKenzie"  wrote in message
> news:497e3ab9.2060...@mckenzies.net...
> >
> >
> > Shawn McKenzie wrote:
> >>
> >> Tom Scott wrote:
> >>> - Original Message - From: "Shawn McKenzie"
> >>> 
> >>> Newsgroups: php.general
> >>> To: 
> >>> Sent: Monday, January 26, 2009 3:52 PM
> >>> Subject: Re: [PHP] Coding for email response forms
> >>>
> >>>
> >>>> Tom wrote:
> >>>>> "Shawn McKenzie" <> wrote in message
> >>>>> news:a0.87.62571.3d92e...@pb1.pair.com...
> >>>>>> Tom wrote:
> >>>>>>> My Hosting site said that I needed to include the PHP otherwise
> >>>>>>> the form
> >>>>>>> won't work. I need to know where to include my email info to get
> >>>>>>> this set
> >>>>>>> up
> >>>>>>> don't I? What do you suggest?
> >>>>>>> T
> >>>>>>> "Daniel Brown"  wrote in message
> >>>>>>> news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com.
> ..
> >>>>>>>> On Mon, Jan 26, 2009 at 15:57, Tom  wrote:
> >>>>>>>>> I am a new user of PHP, and am using Dreamweaver CS3 for the
> >>>>>>>>> webpages.
> >>>>>>>>> The
> >>>>>>>>> following page has my form but the submit button is not working
> >>>>>>>>> properly.
> >>>>>>>>> http://www.richlandmtg.com/contacts.html
> >>>>>>>>> What code is needed and where does it get placed in the page.? I
> >>>>>>>>> thought
> >>>>>>>>> CS3
> >>>>>>>>> took care of this.
> >>>>>>>>Tom,
> >>>>>>>>
> >>>>>>>>This issue has nothing at all to do with PHP.  This is all
> >>>>>>>> client
> >>>>>>>> side (JavaScript and HTML).
> >>>>>>>>
> >>>>>>>> --
> >>>>>>>> 
> >>>>>>>> daniel.br...@parasane.net || danbr...@php.net
> >>>>>>>> http://www.parasane.net/ || http://www.pilotpig.net/
> >>>>>>>> Unadvertised dedicated server deals, too low to print - email me
> >>>>>>>> to find
> >>>>>>>> out!
> >>>>>> What you have now is a form that when submitted sends the data to
> >>>>>> itself.  So you either need to include some php in this file to
> >>>>>> gather
> >>>>>> up the data and email it when submitted, or submit to another file
> >>>>>> that
> >>>>>> does that.
> >>>>>>
> >>>>>>
> >>>>>> --
> >>>>>> Thanks!
> >>>>>> -Shawn
> >>>>>> http://www.spidean.com
> >>>>> Shawn,
> >>>>> So would that look something like this:
> >>>>>  >>>>> if ($_SERVER['REQUEST_METHOD'] == "POST") {
> >>>>>
> >>>>> // Just to be safe, I strip out HTML tags
> >>>>> $realname = strip_tags($realname);
> >>>>> $email = strip_tags($email);
> >>>>> $feedback = strip_tags($feedback);
> >>>>>
> >>>>> // set the variables
> >>>>> // replace $...@mysite.com with your email
> >>>>> $sendto = "$...@mysite.com";
> >>>>> $subject = "Sending Email Feedback From My Website";
> >>>>> $message = "$realname, $email\n\n$feedback";
> >>>>>
> >>>>> // send the email
> >>>>> mail($sendto, $subject, $message);
> >>>>>
> >>>>> }
> >>>>> ?>
> >>>>>
> >>>>>
> >>>>>
> >>>> Oh, you should also think about some other things, such as validation.
> >>>> Is realname only alpha characters?  Is email in the form of a real
> >>>> email
> >>>> address?  At a bare minimum, are they not empty:
> >>>>
> >>>> if (empty($_POST['email']) ||
> >>>> empty($_POST['realname']) ||
> >>>> empty($_POST['feedback']))
> >>>> {
> >>>>echo 'You must complete all required fields!';
> >>>> // show form again
> >>>> }
> >>>>
> >>>>
> >>>> --
> >>>> Thanks!
> >>>> -Shawn
> >>>> http://www.spidean.com
> >>> Ok. I have the validation part.
> >>> http://www.richlandmtg.com/index-5.html still working on the Send
> >>> button.
> >>>
> >>> T
> >>>
> >>>
> >> Please reply all so this stays on the list.
> >>
> >> 1.  In the source for your link I see that the JS is doing some
> >> validation.
> >> 2.  You have method="get" in your form.  This will work, but you'll have
> >> to change the PHP code to use $_GET instead of $_POST vars.  Or change
> >> to method="post" in the form.
> >> 3.  If you want to keep the .html extension for the page, then you'll
> >> probably need to send the post to another script with a .php extension.
> >> Normally a file with a .html extension won't execute the PHP code.
> >>
> >> Thanks!
> >> -Shawn
> >>
> >>
> >>
> I was just looking at that. Someone told me to use GET instead of POST.
> Since JS is validating is it as easy replacing GET with POST ? Nothing else
> needed? Is it better to remove the JS and just code using PHP as you showed
> before?
> if (empty($_POST['email']) ||
> empty($_POST['realname']) ||
> empty($_POST['feedback']))
>
> Thanks,
> Tom


Yes, I think it is better to just use PHP code and post is the better method
(in this case) because with get all your fields and values will show up in
the url

-eddy


Re: [PHP] Coding for email response forms

2009-01-26 Thread Tom

"Eric Butera"  wrote in message 
news:6a8639eb0901261509s1008e1b1j89c2a8f63669e...@mail.gmail.com...
> On Mon, Jan 26, 2009 at 4:47 PM, Daniel Brown  wrote:
>> On Mon, Jan 26, 2009 at 16:34, Tom  wrote:
>>>
>>> Shawn,
>>> So would that look something like this:
>>> >> if ($_SERVER['REQUEST_METHOD'] == "POST") {
>>>
>>> // Just to be safe, I strip out HTML tags
>>> $realname = strip_tags($realname);
>>> $email = strip_tags($email);
>>> $feedback = strip_tags($feedback);
>>>
>>> // set the variables
>>> // replace $...@mysite.com with your email
>>> $sendto = "$...@mysite.com";
>>> $subject = "Sending Email Feedback From My Website";
>>> $message = "$realname, $email\n\n$feedback";
>>>
>>> // send the email
>>> mail($sendto, $subject, $message);
>>>
>>> }
>>> ?>
>>
>>For processing once it reaches the server, yes - almost exactly.
>> A few recommended changes though:
>>
>>* Change > different PHP configurations.
>>* Change your if() to if($_POST['realname'])
>>* DO NOT rely on register_globals - it's insecure and will
>> soon be phased-out of PHP.  Instead, using your code:
>>$realname = strip_tags($_POST['realname']);
>>* Use explicit headers with mail().  For example:
>>$headers  = "From: y...@example.com\r\n";
>>$headers .= "X-Mailer: PHP/".phpversion()."\r\n";
>>mail($sendto,$subject,$message,$headers);
>>* Do something (exit, header("Location: otherpage.html")
>> redirect, etc.) so that the form doesn't reappear.
>>
>>Then, either include that code at the top of the file in which
>> your HTML resides, or place it in it's own file (for example:
>> formproc.php) and change your form tag to:
>>> id="formName">
>>
>>
>>NB: My original responses that this wasn't PHP-related was based
>> on your original message, saying that your "submit button" wasn't
>> working, and then including HTML and JavaScript code only.  It didn't
>> appear as though it had anything to do with PHP.  Getting a good
>> answer is best-achieved by asking a well-formed question.
>>
>> --
>> 
>> daniel.br...@parasane.net || danbr...@php.net
>> http://www.parasane.net/ || http://www.pilotpig.net/
>> Unadvertised dedicated server deals, too low to print - email me to find 
>> out!
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> Also make sure there aren't line returns or any nonsense like that in
> the to & subjects.  Look up email header injection.  Your script might
> become quite popular at advertising p3n1s pills otherwise. :)

Thanks I'll check it out. I tried including the above code but I still can't 
seem to get it to work. Must be missing something.

Thanks,
T 



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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Eric Butera
On Mon, Jan 26, 2009 at 4:47 PM, Daniel Brown  wrote:
> On Mon, Jan 26, 2009 at 16:34, Tom  wrote:
>>
>> Shawn,
>> So would that look something like this:
>> > if ($_SERVER['REQUEST_METHOD'] == "POST") {
>>
>> // Just to be safe, I strip out HTML tags
>> $realname = strip_tags($realname);
>> $email = strip_tags($email);
>> $feedback = strip_tags($feedback);
>>
>> // set the variables
>> // replace $...@mysite.com with your email
>> $sendto = "$...@mysite.com";
>> $subject = "Sending Email Feedback From My Website";
>> $message = "$realname, $email\n\n$feedback";
>>
>> // send the email
>> mail($sendto, $subject, $message);
>>
>> }
>> ?>
>
>For processing once it reaches the server, yes - almost exactly.
> A few recommended changes though:
>
>* Change  different PHP configurations.
>* Change your if() to if($_POST['realname'])
>* DO NOT rely on register_globals - it's insecure and will
> soon be phased-out of PHP.  Instead, using your code:
>$realname = strip_tags($_POST['realname']);
>* Use explicit headers with mail().  For example:
>$headers  = "From: y...@example.com\r\n";
>$headers .= "X-Mailer: PHP/".phpversion()."\r\n";
>mail($sendto,$subject,$message,$headers);
>* Do something (exit, header("Location: otherpage.html")
> redirect, etc.) so that the form doesn't reappear.
>
>Then, either include that code at the top of the file in which
> your HTML resides, or place it in it's own file (for example:
> formproc.php) and change your form tag to:
> id="formName">
>
>
>NB: My original responses that this wasn't PHP-related was based
> on your original message, saying that your "submit button" wasn't
> working, and then including HTML and JavaScript code only.  It didn't
> appear as though it had anything to do with PHP.  Getting a good
> answer is best-achieved by asking a well-formed question.
>
> --
> 
> daniel.br...@parasane.net || danbr...@php.net
> http://www.parasane.net/ || http://www.pilotpig.net/
> Unadvertised dedicated server deals, too low to print - email me to find out!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Also make sure there aren't line returns or any nonsense like that in
the to & subjects.  Look up email header injection.  Your script might
become quite popular at advertising p3n1s pills otherwise. :)

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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Tom

"Shawn McKenzie"  wrote in message 
news:497e3ab9.2060...@mckenzies.net...
>
>
> Shawn McKenzie wrote:
>>
>> Tom Scott wrote:
>>> - Original Message - From: "Shawn McKenzie"
>>> 
>>> Newsgroups: php.general
>>> To: 
>>> Sent: Monday, January 26, 2009 3:52 PM
>>> Subject: Re: [PHP] Coding for email response forms
>>>
>>>
>>>> Tom wrote:
>>>>> "Shawn McKenzie" <> wrote in message
>>>>> news:a0.87.62571.3d92e...@pb1.pair.com...
>>>>>> Tom wrote:
>>>>>>> My Hosting site said that I needed to include the PHP otherwise
>>>>>>> the form
>>>>>>> won't work. I need to know where to include my email info to get
>>>>>>> this set
>>>>>>> up
>>>>>>> don't I? What do you suggest?
>>>>>>> T
>>>>>>> "Daniel Brown"  wrote in message
>>>>>>> news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com...
>>>>>>>> On Mon, Jan 26, 2009 at 15:57, Tom  wrote:
>>>>>>>>> I am a new user of PHP, and am using Dreamweaver CS3 for the
>>>>>>>>> webpages.
>>>>>>>>> The
>>>>>>>>> following page has my form but the submit button is not working
>>>>>>>>> properly.
>>>>>>>>> http://www.richlandmtg.com/contacts.html
>>>>>>>>> What code is needed and where does it get placed in the page.? I
>>>>>>>>> thought
>>>>>>>>> CS3
>>>>>>>>> took care of this.
>>>>>>>>Tom,
>>>>>>>>
>>>>>>>>This issue has nothing at all to do with PHP.  This is all 
>>>>>>>> client
>>>>>>>> side (JavaScript and HTML).
>>>>>>>>
>>>>>>>> -- 
>>>>>>>> 
>>>>>>>> daniel.br...@parasane.net || danbr...@php.net
>>>>>>>> http://www.parasane.net/ || http://www.pilotpig.net/
>>>>>>>> Unadvertised dedicated server deals, too low to print - email me
>>>>>>>> to find
>>>>>>>> out!
>>>>>> What you have now is a form that when submitted sends the data to
>>>>>> itself.  So you either need to include some php in this file to 
>>>>>> gather
>>>>>> up the data and email it when submitted, or submit to another file
>>>>>> that
>>>>>> does that.
>>>>>>
>>>>>>
>>>>>> -- 
>>>>>> Thanks!
>>>>>> -Shawn
>>>>>> http://www.spidean.com
>>>>> Shawn,
>>>>> So would that look something like this:
>>>>> >>>> if ($_SERVER['REQUEST_METHOD'] == "POST") {
>>>>>
>>>>> // Just to be safe, I strip out HTML tags
>>>>> $realname = strip_tags($realname);
>>>>> $email = strip_tags($email);
>>>>> $feedback = strip_tags($feedback);
>>>>>
>>>>> // set the variables
>>>>> // replace $...@mysite.com with your email
>>>>> $sendto = "$...@mysite.com";
>>>>> $subject = "Sending Email Feedback From My Website";
>>>>> $message = "$realname, $email\n\n$feedback";
>>>>>
>>>>> // send the email
>>>>> mail($sendto, $subject, $message);
>>>>>
>>>>> }
>>>>> ?>
>>>>>
>>>>>
>>>>>
>>>> Oh, you should also think about some other things, such as validation.
>>>> Is realname only alpha characters?  Is email in the form of a real 
>>>> email
>>>> address?  At a bare minimum, are they not empty:
>>>>
>>>> if (empty($_POST['email']) ||
>>>> empty($_POST['realname']) ||
>>>> empty($_POST['feedback']))
>>>> {
>>>>echo 'You must complete all required fields!';
>>>> // show form again
>>>> }
>>>>
>>>>
>>>> -- 
>>>> Thanks!
>>>> -Shawn
>>>> http://www.spidean.com
>>> Ok. I have the validation part.
>>> http://www.richlandmtg.com/index-5.html still working on the Send 
>>> button.
>>>
>>> T
>>>
>>>
>> Please reply all so this stays on the list.
>>
>> 1.  In the source for your link I see that the JS is doing some 
>> validation.
>> 2.  You have method="get" in your form.  This will work, but you'll have
>> to change the PHP code to use $_GET instead of $_POST vars.  Or change
>> to method="post" in the form.
>> 3.  If you want to keep the .html extension for the page, then you'll
>> probably need to send the post to another script with a .php extension.
>> Normally a file with a .html extension won't execute the PHP code.
>>
>> Thanks!
>> -Shawn
>>
>>
>>
I was just looking at that. Someone told me to use GET instead of POST. 
Since JS is validating is it as easy replacing GET with POST ? Nothing else 
needed? Is it better to remove the JS and just code using PHP as you showed 
before?
if (empty($_POST['email']) ||
empty($_POST['realname']) ||
empty($_POST['feedback']))

Thanks,
Tom



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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Shawn McKenzie


Shawn McKenzie wrote:
> 
> Tom Scott wrote:
>> - Original Message - From: "Shawn McKenzie"
>> 
>> Newsgroups: php.general
>> To: 
>> Sent: Monday, January 26, 2009 3:52 PM
>> Subject: Re: [PHP] Coding for email response forms
>>
>>
>>> Tom wrote:
>>>> "Shawn McKenzie" <> wrote in message
>>>> news:a0.87.62571.3d92e...@pb1.pair.com...
>>>>> Tom wrote:
>>>>>> My Hosting site said that I needed to include the PHP otherwise
>>>>>> the form
>>>>>> won't work. I need to know where to include my email info to get
>>>>>> this set
>>>>>> up
>>>>>> don't I? What do you suggest?
>>>>>> T
>>>>>> "Daniel Brown"  wrote in message
>>>>>> news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com...
>>>>>>> On Mon, Jan 26, 2009 at 15:57, Tom  wrote:
>>>>>>>> I am a new user of PHP, and am using Dreamweaver CS3 for the
>>>>>>>> webpages.
>>>>>>>> The
>>>>>>>> following page has my form but the submit button is not working
>>>>>>>> properly.
>>>>>>>> http://www.richlandmtg.com/contacts.html
>>>>>>>> What code is needed and where does it get placed in the page.? I
>>>>>>>> thought
>>>>>>>> CS3
>>>>>>>> took care of this.
>>>>>>>Tom,
>>>>>>>
>>>>>>>This issue has nothing at all to do with PHP.  This is all client
>>>>>>> side (JavaScript and HTML).
>>>>>>>
>>>>>>> -- 
>>>>>>> 
>>>>>>> daniel.br...@parasane.net || danbr...@php.net
>>>>>>> http://www.parasane.net/ || http://www.pilotpig.net/
>>>>>>> Unadvertised dedicated server deals, too low to print - email me
>>>>>>> to find
>>>>>>> out!
>>>>> What you have now is a form that when submitted sends the data to
>>>>> itself.  So you either need to include some php in this file to gather
>>>>> up the data and email it when submitted, or submit to another file
>>>>> that
>>>>> does that.
>>>>>
>>>>>
>>>>> -- 
>>>>> Thanks!
>>>>> -Shawn
>>>>> http://www.spidean.com
>>>> Shawn,
>>>> So would that look something like this:
>>>> >>> if ($_SERVER['REQUEST_METHOD'] == "POST") {
>>>>
>>>> // Just to be safe, I strip out HTML tags
>>>> $realname = strip_tags($realname);
>>>> $email = strip_tags($email);
>>>> $feedback = strip_tags($feedback);
>>>>
>>>> // set the variables
>>>> // replace $...@mysite.com with your email
>>>> $sendto = "$...@mysite.com";
>>>> $subject = "Sending Email Feedback From My Website";
>>>> $message = "$realname, $email\n\n$feedback";
>>>>
>>>> // send the email
>>>> mail($sendto, $subject, $message);
>>>>
>>>> }
>>>> ?>
>>>>
>>>>
>>>>
>>> Oh, you should also think about some other things, such as validation.
>>> Is realname only alpha characters?  Is email in the form of a real email
>>> address?  At a bare minimum, are they not empty:
>>>
>>> if (empty($_POST['email']) ||
>>> empty($_POST['realname']) ||
>>> empty($_POST['feedback']))
>>> {
>>>echo 'You must complete all required fields!';
>>> // show form again
>>> }
>>>
>>>
>>> -- 
>>> Thanks!
>>> -Shawn
>>> http://www.spidean.com
>> Ok. I have the validation part.
>> http://www.richlandmtg.com/index-5.html still working on the Send button.
>>
>> T
>>
>>
> Please reply all so this stays on the list.
> 
> 1.  In the source for your link I see that the JS is doing some validation.
> 2.  You have method="get" in your form.  This will work, but you'll have
> to change the PHP code to use $_GET instead of $_POST vars.  Or change
> to method="post" in the form.
> 3.  If you want to keep the .html extension for the page, then you'll
> probably need to send the post to another script with a .php extension. 
> Normally a file with a .html extension won't execute the PHP code.
> 
> Thanks!
> -Shawn
> 
> 
> 

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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Tom

"Daniel Brown"  wrote in message 
news:ab5568160901261347h1dab427bo29a1313494cd...@mail.gmail.com...
> On Mon, Jan 26, 2009 at 16:34, Tom  wrote:
>>
>> Shawn,
>> So would that look something like this:
>> > if ($_SERVER['REQUEST_METHOD'] == "POST") {
>>
>> // Just to be safe, I strip out HTML tags
>> $realname = strip_tags($realname);
>> $email = strip_tags($email);
>> $feedback = strip_tags($feedback);
>>
>> // set the variables
>> // replace $...@mysite.com with your email
>> $sendto = "$...@mysite.com";
>> $subject = "Sending Email Feedback From My Website";
>> $message = "$realname, $email\n\n$feedback";
>>
>> // send the email
>> mail($sendto, $subject, $message);
>>
>> }
>> ?>
>
>For processing once it reaches the server, yes - almost exactly.
> A few recommended changes though:
>
>* Change  different PHP configurations.
>* Change your if() to if($_POST['realname'])
>* DO NOT rely on register_globals - it's insecure and will
> soon be phased-out of PHP.  Instead, using your code:
>$realname = strip_tags($_POST['realname']);
>* Use explicit headers with mail().  For example:
>$headers  = "From: y...@example.com\r\n";
>$headers .= "X-Mailer: PHP/".phpversion()."\r\n";
>mail($sendto,$subject,$message,$headers);
>* Do something (exit, header("Location: otherpage.html")
> redirect, etc.) so that the form doesn't reappear.
>
>Then, either include that code at the top of the file in which
> your HTML resides, or place it in it's own file (for example:
> formproc.php) and change your form tag to:
> id="formName">
>
>
>NB: My original responses that this wasn't PHP-related was based
> on your original message, saying that your "submit button" wasn't
> working, and then including HTML and JavaScript code only.  It didn't
> appear as though it had anything to do with PHP.  Getting a good
> answer is best-achieved by asking a well-formed question.
>
> -- 
> 
> daniel.br...@parasane.net || danbr...@php.net
> http://www.parasane.net/ || http://www.pilotpig.net/
> Unadvertised dedicated server deals, too low to print - email me to find 
> out!

Us newbies don't always phrase the questions right but you & Shawn answered 
my question. Just have to try it out now.
Thanks
T 



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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Shawn McKenzie
Tom wrote:
> "Shawn McKenzie" <> wrote in message 
> news:a0.87.62571.3d92e...@pb1.pair.com...
>> Tom wrote:
>>> My Hosting site said that I needed to include the PHP otherwise the form
>>> won't work. I need to know where to include my email info to get this set 
>>> up
>>> don't I? What do you suggest?
>>> T
>>> "Daniel Brown"  wrote in message
>>> news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com...
 On Mon, Jan 26, 2009 at 15:57, Tom  wrote:
> I am a new user of PHP, and am using Dreamweaver CS3 for the webpages.
> The
> following page has my form but the submit button is not working 
> properly.
> http://www.richlandmtg.com/contacts.html
> What code is needed and where does it get placed in the page.? I 
> thought
> CS3
> took care of this.
Tom,

This issue has nothing at all to do with PHP.  This is all client
 side (JavaScript and HTML).

 -- 
 
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 Unadvertised dedicated server deals, too low to print - email me to find
 out!
>>>
>> What you have now is a form that when submitted sends the data to
>> itself.  So you either need to include some php in this file to gather
>> up the data and email it when submitted, or submit to another file that
>> does that.
>>
>>
>> -- 
>> Thanks!
>> -Shawn
>> http://www.spidean.com
> 
> Shawn,
> So would that look something like this:
>  if ($_SERVER['REQUEST_METHOD'] == "POST") {
> 
> // Just to be safe, I strip out HTML tags
> $realname = strip_tags($realname);
> $email = strip_tags($email);
> $feedback = strip_tags($feedback);
> 
> // set the variables
> // replace $...@mysite.com with your email
> $sendto = "$...@mysite.com";
> $subject = "Sending Email Feedback From My Website";
> $message = "$realname, $email\n\n$feedback";
> 
> // send the email
> mail($sendto, $subject, $message);
> 
> }
> ?>
> 
> 
> 
Oh, you should also think about some other things, such as validation.
Is realname only alpha characters?  Is email in the form of a real email
address?  At a bare minimum, are they not empty:

if (empty($_POST['email']) ||
empty($_POST['realname']) ||
empty($_POST['feedback']))
{
echo 'You must complete all required fields!';
// show form again
}


-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Daniel Brown
On Mon, Jan 26, 2009 at 16:34, Tom  wrote:
>
> Shawn,
> So would that look something like this:
>  if ($_SERVER['REQUEST_METHOD'] == "POST") {
>
> // Just to be safe, I strip out HTML tags
> $realname = strip_tags($realname);
> $email = strip_tags($email);
> $feedback = strip_tags($feedback);
>
> // set the variables
> // replace $...@mysite.com with your email
> $sendto = "$...@mysite.com";
> $subject = "Sending Email Feedback From My Website";
> $message = "$realname, $email\n\n$feedback";
>
> // send the email
> mail($sendto, $subject, $message);
>
> }
> ?>

For processing once it reaches the server, yes - almost exactly.
A few recommended changes though:

* Change 


NB: My original responses that this wasn't PHP-related was based
on your original message, saying that your "submit button" wasn't
working, and then including HTML and JavaScript code only.  It didn't
appear as though it had anything to do with PHP.  Getting a good
answer is best-achieved by asking a well-formed question.

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Shawn McKenzie
Tom wrote:
> "Shawn McKenzie" <> wrote in message 
> news:a0.87.62571.3d92e...@pb1.pair.com...
>> Tom wrote:
>>> My Hosting site said that I needed to include the PHP otherwise the form
>>> won't work. I need to know where to include my email info to get this set 
>>> up
>>> don't I? What do you suggest?
>>> T
>>> "Daniel Brown"  wrote in message
>>> news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com...
 On Mon, Jan 26, 2009 at 15:57, Tom  wrote:
> I am a new user of PHP, and am using Dreamweaver CS3 for the webpages.
> The
> following page has my form but the submit button is not working 
> properly.
> http://www.richlandmtg.com/contacts.html
> What code is needed and where does it get placed in the page.? I 
> thought
> CS3
> took care of this.
Tom,

This issue has nothing at all to do with PHP.  This is all client
 side (JavaScript and HTML).

 -- 
 
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 Unadvertised dedicated server deals, too low to print - email me to find
 out!
>>>
>> What you have now is a form that when submitted sends the data to
>> itself.  So you either need to include some php in this file to gather
>> up the data and email it when submitted, or submit to another file that
>> does that.
>>
>>
>> -- 
>> Thanks!
>> -Shawn
>> http://www.spidean.com
> 
> Shawn,
> So would that look something like this:
>  if ($_SERVER['REQUEST_METHOD'] == "POST") {
> 
> // Just to be safe, I strip out HTML tags
> $realname = strip_tags($realname);
> $email = strip_tags($email);
> $feedback = strip_tags($feedback);
> 
> // set the variables
> // replace $...@mysite.com with your email
> $sendto = "$...@mysite.com";
> $subject = "Sending Email Feedback From My Website";
> $message = "$realname, $email\n\n$feedback";
> 
> // send the email
> mail($sendto, $subject, $message);
> 
> }
> ?>
> 
> 
> 
That's a good start, however you should use $_POST['realname'] etc.
since they are coming from a post operation. $realname only exists if
register_globals is on, which is evil.

Also, you would probably do this before your form so that you can say
"Thanks for your feedback." and then exit or redirect and not display
the form again.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Tom

"Shawn McKenzie" <> wrote in message 
news:a0.87.62571.3d92e...@pb1.pair.com...
> Tom wrote:
>> My Hosting site said that I needed to include the PHP otherwise the form
>> won't work. I need to know where to include my email info to get this set 
>> up
>> don't I? What do you suggest?
>> T
>> "Daniel Brown"  wrote in message
>> news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com...
>>> On Mon, Jan 26, 2009 at 15:57, Tom  wrote:
 I am a new user of PHP, and am using Dreamweaver CS3 for the webpages.
 The
 following page has my form but the submit button is not working 
 properly.
 http://www.richlandmtg.com/contacts.html
 What code is needed and where does it get placed in the page.? I 
 thought
 CS3
 took care of this.
>>>Tom,
>>>
>>>This issue has nothing at all to do with PHP.  This is all client
>>> side (JavaScript and HTML).
>>>
>>> -- 
>>> 
>>> daniel.br...@parasane.net || danbr...@php.net
>>> http://www.parasane.net/ || http://www.pilotpig.net/
>>> Unadvertised dedicated server deals, too low to print - email me to find
>>> out!
>>
>>
>
> What you have now is a form that when submitted sends the data to
> itself.  So you either need to include some php in this file to gather
> up the data and email it when submitted, or submit to another file that
> does that.
>
>
> -- 
> Thanks!
> -Shawn
> http://www.spidean.com

Shawn,
So would that look something like this:





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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Shawn McKenzie
Tom wrote:
> My Hosting site said that I needed to include the PHP otherwise the form 
> won't work. I need to know where to include my email info to get this set up 
> don't I? What do you suggest?
> T
> "Daniel Brown"  wrote in message 
> news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com...
>> On Mon, Jan 26, 2009 at 15:57, Tom  wrote:
>>> I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. 
>>> The
>>> following page has my form but the submit button is not working properly.
>>> http://www.richlandmtg.com/contacts.html
>>> What code is needed and where does it get placed in the page.? I thought 
>>> CS3
>>> took care of this.
>>Tom,
>>
>>This issue has nothing at all to do with PHP.  This is all client
>> side (JavaScript and HTML).
>>
>> -- 
>> 
>> daniel.br...@parasane.net || danbr...@php.net
>> http://www.parasane.net/ || http://www.pilotpig.net/
>> Unadvertised dedicated server deals, too low to print - email me to find 
>> out! 
> 
> 

What you have now is a form that when submitted sends the data to
itself.  So you either need to include some php in this file to gather
up the data and email it when submitted, or submit to another file that
does that.


-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Tom
My Hosting site said that I needed to include the PHP otherwise the form 
won't work. I need to know where to include my email info to get this set up 
don't I? What do you suggest?
T
"Daniel Brown"  wrote in message 
news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com...
> On Mon, Jan 26, 2009 at 15:57, Tom  wrote:
>> I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. 
>> The
>> following page has my form but the submit button is not working properly.
>> http://www.richlandmtg.com/contacts.html
>> What code is needed and where does it get placed in the page.? I thought 
>> CS3
>> took care of this.
>
>Tom,
>
>This issue has nothing at all to do with PHP.  This is all client
> side (JavaScript and HTML).
>
> -- 
> 
> daniel.br...@parasane.net || danbr...@php.net
> http://www.parasane.net/ || http://www.pilotpig.net/
> Unadvertised dedicated server deals, too low to print - email me to find 
> out! 



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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Daniel Brown
On Mon, Jan 26, 2009 at 15:57, Tom  wrote:
> I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. The
> following page has my form but the submit button is not working properly.
> http://www.richlandmtg.com/contacts.html
> What code is needed and where does it get placed in the page.? I thought CS3
> took care of this.

Tom,

This issue has nothing at all to do with PHP.  This is all client
side (JavaScript and HTML).

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] coding MySQL error traps [WAS: mysql if empty]

2007-04-10 Thread Richard Lynch
On Tue, April 10, 2007 1:08 pm, Paul Novitski wrote:
> mysql_query() returns true.  This constitutes a hack because it
> depends entirely on the way the parser processes code rather than on
> explicit elements of the language.

The order of execution and boolean short-circuit is a Documented Feature.

This is no more a "hack" than relying on:

if ($foo || $bar){
}

to do the right thing.

That said, "or die..." is a shorthand for "you should replace this
with REAL error handling", so you're right, only for the wrong
reasons.

:-)

> define('bDebug', true);
> ...
> $bResult = mysql_query($sql);
>  if (!$bResult) return ReportSQLError('checking user name',
> mysql_errno(), mysql_error(), $sql);
> ...
> function ReportSQLError($context, $errno, $errorMsg, $sql)
> {
>  if (bDebug)
>  {
>  die("MYSQL ERROR $errno $context: />\n$errorMsg\n$sql");
>  }
>  else
>  {
>  return $generate_friendly_error_message;
>  }
> }

Personally, I wouldn't use this bDebug stuff...

It's too easy for a logic error in bDebug/non-bDebug to slip through
QA, and have the application working "differently" on the Production
server from the dev server.

This is particularly true if you don't have a test suite with 100% (or
close) code coverage.

Better to do something like:

$whatever = mysql_query($query, $connection);
if (!$whatever){
  $messages[] = "Something went wrong. Nice user error message here.";
  error_log(mysql_error($connection));
  error_log($query);
}

$messages can be dumped out en masse in the presentation layer in a
suitable div.

Some would argue that things could go very wrong and fill up your log
files...

Well, yeah, if you're so inept and dis-organized as to not have a
process in place to detect and deal with a problem that it happens
enough to fill up your log files, then, yes, it could be a problem...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] coding MySQL error traps [WAS: mysql if empty]

2007-04-10 Thread Jim Lucas

Paul Novitski wrote:



$sql = "SELECT Client FROM booked WHERE Name = 'larry'";

$result = mysql_query($sql) OR die('[MYSQL ERROR] - 
['.mysql_errno().']'.mysql_error());


while ( list($client) = mysql_fetch_row($result) ) {
echo "{$client}\n";
}



I agree with this logic overall.  The above is of course just 
oversimplified demo code, but I'd like to mention a few details I would 
change before putting this into practice.


The syntax "$result = mysql_query($sql) OR die();" is nicely compact but 
obfuscates the program logic.  PHP is not actually ORing two values, 
it's halting execution halfway through the statement if mysql_query() 
returns true.  This constitutes a hack because it depends entirely on 
the way the parser processes code rather than on explicit elements of 
the language.  To help keep legacy code from crashing with PHP version X 
I'd break this into two statements: run the query, then act on the 
result.  The parser won't care, and your code will be more easily 
readable by us humans.


Displaying mysql_error() is great for the developer but in a public 
application will expose the names of tables and fields to the public who 
shouldn't really see your wires and pipes.


mysql_error() doesn't usually contain the entire query and doesn't 
always contain the segment of the query that actually caused the error, 
so I always add the full query to the error message to save time in 
debugging.


Finally, die()ing on a mysql error is pretty harsh; a friendlier 
application would return the error state to parent layers, translate the 
error into advice a non-technical user can deal with, and display it in 
a way that doesn't crash the page.


Rather than trying to remember to go through the code later fixing these 
bits, I suggest adopting a convention early on that suits both 
development and publication, such as:

___

define('bDebug', true);
...
$bResult = mysql_query($sql);
if (!$bResult) return ReportSQLError('checking user name', 
mysql_errno(), mysql_error(), $sql);

...
function ReportSQLError($context, $errno, $errorMsg, $sql)
{
if (bDebug)
{
die("MYSQL ERROR $errno $context:\n$errorMsg/>\n$sql");

}
else
{
return $generate_friendly_error_message;
}
}
___

Regards,

Paul
__

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com


Yes, this was intended to only show the OP a very simple way to get done what 
they were wanting to do.


--
Enjoy,

Jim Lucas

Different eyes see different things. Different hearts beat on different strings. But there are times 
for you and me when all such things agree.


- Rush

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



Re: [PHP] Coding Standards Document

2006-11-22 Thread Børge Holen
On Wednesday 22 November 2006 16:31, tedd wrote:
> At 7:14 PM -0500 11/21/06, Robert Cummings wrote:
> >On Tue, 2006-11-21 at 16:19 -0500, tedd wrote:
> >>  It seems that every time I ask a security question, I find that I'm
> >>  currently practicing the answers to avoid the pit-falls.
> >
> >Except that one time when his site got defaced... that was news ;) ;)
> >
> >Cheers,
> >Rob.
>
> Rob:
>
> Good point, but that was a problem my host had and not something that
> was my fault. It seems that everyone who hosted with that company had
> every file that even contained the word" index" replaced. I keep a
> redirect index in every folder, so I had well over 200 indexes to
> replace -- joy, joy.
>
> Since then, that host has not answered any of my emails, but I can't
> complain too much because I use very inexpensive hosts for my test
> sites.
>
> You see, I'm at the other end of the spectrum than you guys. You can
> afford high-priced host, but I can't -- you probably can't guess as
> to how cheap I can buy hosting -- it's unbelievable.

Everyone can setup a cheapass old pentium to use as a testhost.
These crappy hostings sites never put in any finecrafted unix tools nor any 
ssh support.
Anyway, point is: Its free

>
> However, when it comes to providing a client with a host, that's a
> different matter and it's their cost,not mine -- for I can (and do)
> work with much less.
>
> Cheers,
>
> tedd
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com

-- 
---
Børge
Kennel Arivene 
http://www.arivene.net
---

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



Re: [PHP] Coding Standards Document

2006-11-22 Thread Robert Cummings
On Wed, 2006-11-22 at 10:31 -0500, tedd wrote:
> At 7:14 PM -0500 11/21/06, Robert Cummings wrote:
> >On Tue, 2006-11-21 at 16:19 -0500, tedd wrote:
> >>  It seems that every time I ask a security question, I find that I'm
> >>  currently practicing the answers to avoid the pit-falls.
> >
> >Except that one time when his site got defaced... that was news ;) ;)
> >
> >Cheers,
> >Rob.
> 
> Rob:
> 
> Good point,

Just some friendly ribbing :D

>  but that was a problem my host had and not something that 
> was my fault. It seems that everyone who hosted with that company had 
> every file that even contained the word" index" replaced. I keep a 
> redirect index in every folder, so I had well over 200 indexes to 
> replace -- joy, joy.

That took 10 seconds to replace right? If it took you an afternoon you
might be maintaining things wrong... but then I guess it depend son
whether your host gives you SSH access or just ftp. I would never go
with an ftp only host. If for some ungodly reason I did, you can be sure
I'd have an expect script to migrate the whole site hands free :)

> Since then, that host has not answered any of my emails, but I can't 
> complain too much because I use very inexpensive hosts for my test 
> sites.
> 
> You see, I'm at the other end of the spectrum than you guys. You can 
> afford high-priced host, but I can't -- you probably can't guess as 
> to how cheap I can buy hosting -- it's unbelievable.

Ummm, I'm no millionaire... yet... I host my InterJinn site from home.
If you ever wondered why it's so slow, it's not the code... it's this
crud 75k/s upload DSL with terrible latency.

> However, when it comes to providing a client with a host, that's a 
> different matter and it's their cost,not mine -- for I can (and do) 
> work with much less.

I hear ya :)

I have kids, if I don't need it, I don't buy it.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Coding Standards Document

2006-11-22 Thread tedd

At 7:14 PM -0500 11/21/06, Robert Cummings wrote:

On Tue, 2006-11-21 at 16:19 -0500, tedd wrote:

 It seems that every time I ask a security question, I find that I'm
 currently practicing the answers to avoid the pit-falls.


Except that one time when his site got defaced... that was news ;) ;)

Cheers,
Rob.


Rob:

Good point, but that was a problem my host had and not something that 
was my fault. It seems that everyone who hosted with that company had 
every file that even contained the word" index" replaced. I keep a 
redirect index in every folder, so I had well over 200 indexes to 
replace -- joy, joy.


Since then, that host has not answered any of my emails, but I can't 
complain too much because I use very inexpensive hosts for my test 
sites.


You see, I'm at the other end of the spectrum than you guys. You can 
afford high-priced host, but I can't -- you probably can't guess as 
to how cheap I can buy hosting -- it's unbelievable.


However, when it comes to providing a client with a host, that's a 
different matter and it's their cost,not mine -- for I can (and do) 
work with much less.


Cheers,

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

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



Re: [PHP] Coding...

2006-11-18 Thread [EMAIL PROTECTED]

There are a lot of good books to go by.  I suggest getting one that
incorporates both PHP & MySQL, not just php.

On 11/18/06, Jeff <[EMAIL PROTECTED]> wrote:


I am pretty new with PHP, but what I've learned in the last 3 weeks is
pretty good I think so far!

What I'm looking to do is create a login script, and have people being
able
to login.

Now, I have pulled scripts from sites, and everything is working okay.
But the problem I have with pulling scripts from other sites, is that the
mysql databases are all different.

How can I import from one database into the other, so basically all the
databases are merged into one main?

I also know that each PHP file has to be re-done and look for the new
database name, for instance if it was user_name, and the default (Main)
database is username .. That I Have to rename all the php files that have
user_name to simply username.

If anyone is willing to help out with the project I'm working on with
another programmer? Hopefully being very cost effective .. or free :) :)

Thanks,

Jeff

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





--
**
The content of this e-mail message and any attachments are confidential and
may be legally privileged, intended solely for the addressee. If you are not
the intended recipient, be advised that any use, dissemination,
distribution, or copying of this e-mail is strictly prohibited. If you
receive this message in error, please notify the sender immediately by reply
email and destroy the message and its attachments.
*


Re: [PHP] Coding...

2006-11-18 Thread John Meyer
I'd pick up a book "Web Database Applications with PHP and MySQL",
otherwise known as the Platypus Book, and use that.  That will teach you
a lot about logins, sessions, as well as using MySQL and PHP together.
As far as the database name goes, that has nothing to do with the PHP
file name.

Jeff wrote:
> I am pretty new with PHP, but what I've learned in the last 3 weeks is
> pretty good I think so far!
> 
> What I'm looking to do is create a login script, and have people being
> able to login.
> 
> Now, I have pulled scripts from sites, and everything is working okay.
> But the problem I have with pulling scripts from other sites, is that
> the mysql databases are all different.
> 
> How can I import from one database into the other, so basically all the
> databases are merged into one main?
> 
> I also know that each PHP file has to be re-done and look for the new
> database name, for instance if it was user_name, and the default (Main)
> database is username .. That I Have to rename all the php files that
> have user_name to simply username.
> 
> If anyone is willing to help out with the project I'm working on with
> another programmer? Hopefully being very cost effective .. or free :) :)
> 
> Thanks,
> 
> Jeff

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



Re: [PHP] Coding Style Question...

2006-10-03 Thread Richard Lynch
On Mon, October 2, 2006 7:32 pm, Tony Di Croce wrote:
> I am relatively new to PHP... I have about 1.5 years of light PHP work
> under
> my belt... Over the past year or so my PHP coding style has evolved
> significantly and I'm curious as to how experienced programmers write
> PHP...
>
> Basically, here is what I have evolved to:
>
> 1) ALL php code is at the top of the file.
> 2) ALL html code is in a here document at the bottom.
> 3) php code is run before 1 character is outputed (and hence, no
> headers are
> sent, leaving redirects open for possibilities)
> 4) I almost always following my require_once directives with a
> session_start() at the top of the file.
> 5) Often, my forms submit to the PHP page that generated them but do
> so with
> a hidden posted variable. If that variable is set, then I process the
> form
> submission.
>
> I think the most important part of all this is #1 & #2... I think I am
> using
> PHP a little like template engine this way...
>
> It seems to me that I most often see code snippets that try to
> intertwine
> HTML and PHP, but in my experience, except for trivial examples, this
> doesn't work so good...
>
> What do you think?

I do the same, but will mingle HTML/PHP for layout/formatting or User
Interface logic.

And I don't bother with a heredoc, since I find it easier to edit HTML
with the occasional  in it.

E.g., a popup menu of the years from "current" to 10 years into the
future for the credit card expiration is not exactly complex back-end
business logic.  A simple 'for' loop in my HTML to do that is vastly
superior to the "solution" of templates that require hours of
back-tracking through 7 PHP/template/HTML/whatever files to sort out
what the heck is going on here...

And, yes, I *did* once waste hours to find out how they were
generating a 10-year popup for the credit card expiration... Which
they had HARD-CODED the 'start' year in their business logic!!! 
Sheesh!  Back-tracking that through the files turned a 5-minute task
into hours wasted.  And folks wonder why I think PHP *is* a template
language and you shouldn't use another one on top of it...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Coding Style Question...

2006-10-03 Thread tedd

At 10:23 AM +0800 10/3/06, Glenn Richmond wrote:

I'll probably
get strong opposition for these comments, but in my opinion, there's
nothing worse than mixing two different lanuages in a single file, not
to mention mixing functional code with layout code.

Glenn.


Glenn:

I agree with the concepts of unobtrusive code and the separation of 
content, presentation, and behavior. However, I find it very 
difficult not to mix languages -- for example, trying to generate 
dynamic html from php/mysql without mixing all three languages is 
difficult, if not impossible.


Plus, when php can generate html, css, javascript, and content -- 
it's not possible (by definition) to create language-pure code under 
those conditions.


Also, sometimes mixing languages is preferable (with regard to 
readability) than trying to develop a scheme to separate them.


And lastly, what constitutes separation?  Is an include(), or date(), 
or any php function from within a html, or css, file acceptable? If 
not, what's the cost in readability or lines of additional code to 
obtain the same functionality?


I don't know about others, but the language line is blurred for me. I 
still believe in the "concepts" separation of content, presentation, 
and behavior, but php transcends the other languages in a different 
manner and provides the "glue" to hold them together and make them a 
cohesive functional solution. In my mind, the "concept of separation" 
does not fall clearly along language boundaries.


While this is not meant to demean php, I see php not only as a 
"stand-alone" language, but as an addition to html, css, and 
javascript, which can enhance their functionality. Clearly each of 
those languages can do more with php than without it.


That's my perspective.

tedd

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

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



Re: [PHP] Coding Style Question...

2006-10-02 Thread Larry Garfield
On Monday 02 October 2006 19:32, Tony Di Croce wrote:
> I am relatively new to PHP... I have about 1.5 years of light PHP work
> under my belt... Over the past year or so my PHP coding style has evolved
> significantly and I'm curious as to how experienced programmers write
> PHP...
>
> Basically, here is what I have evolved to:
>
> 1) ALL php code is at the top of the file.
> 2) ALL html code is in a here document at the bottom.
> 3) php code is run before 1 character is outputed (and hence, no headers
> are sent, leaving redirects open for possibilities)
> 4) I almost always following my require_once directives with a
> session_start() at the top of the file.
> 5) Often, my forms submit to the PHP page that generated them but do so
> with a hidden posted variable. If that variable is set, then I process the
> form submission.
>
> I think the most important part of all this is #1 & #2... I think I am
> using PHP a little like template engine this way...
>
> It seems to me that I most often see code snippets that try to intertwine
> HTML and PHP, but in my experience, except for trivial examples, this
> doesn't work so good...
>
> What do you think?

Good habits to form, overall.  Most examples and tutorials are trivial, which 
is why they do the intermingling thing.  To be fair, that was one of PHP's 
original strengths over its competition in the early days (vis, Perl and C), 
because it made doing simple stuff simple.  You didn't need to dynamically 
build the whole page if you only wanted a small bit to be dynamic.  Of 
course, once you get into anything interesting, you frequently DO want the 
whole page dynamic or else templated.  

In my case, I tend to use php-based templates and "theme functions", a style 
borrowed from Drupal.  To wit, I have a function like this (off the cuff, not 
tested):

function call_template($template, $args) {
  extract($args);
  ob_start();
  include($template);
  $output =  ob_get_contents();
  ob_end_clean();
  return $output;
}

$template is then the name of a mostly-HTML .php file where I can use PHP for 
display (mostly just echoing), making it easy to separate logic and 
presentation and build the page piecemeal.  It also means that I have all the 
power of PHP for my template "engine".

Then I also have functions like 

theme_table($header=array(), $rows=array(), $caption='', $attrib=array()) {}

or

theme_unorderedlist($items=array()) {}

So that I can just pass logical data structures and get back fully 
semantically useful HTML.  (Eg, theme_table automatically puts in even/odd 
classes on tr tags for me.)  

Again, credit here goes to the Drupal CMS, which uses a much more developed 
and refined version of this concept.  

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

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

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



Re: [PHP] Coding Style Question...

2006-10-02 Thread Glenn Richmond
Hi Tony,

Sounds like a good start. I have to admit that one that I prefer is that
HTML code should be completely separated from PHP via the use of a
templating engine of some sort (I'm a fan of XTemplate). I'll probably
get strong opposition for these comments, but in my opinion, there's
nothing worse than mixing two different lanuages in a single file, not
to mention mixing functional code with layout code.

Glenn.

Tony Di Croce wrote:
> I am relatively new to PHP... I have about 1.5 years of light PHP work
> under
> my belt... Over the past year or so my PHP coding style has evolved
> significantly and I'm curious as to how experienced programmers write
> PHP...
>
> Basically, here is what I have evolved to:
>
> 1) ALL php code is at the top of the file.
> 2) ALL html code is in a here document at the bottom.
> 3) php code is run before 1 character is outputed (and hence, no
> headers are
> sent, leaving redirects open for possibilities)
> 4) I almost always following my require_once directives with a
> session_start() at the top of the file.
> 5) Often, my forms submit to the PHP page that generated them but do
> so with
> a hidden posted variable. If that variable is set, then I process the
> form
> submission.
>
> I think the most important part of all this is #1 & #2... I think I am
> using
> PHP a little like template engine this way...
>
> It seems to me that I most often see code snippets that try to intertwine
> HTML and PHP, but in my experience, except for trivial examples, this
> doesn't work so good...
>
> What do you think?
>

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



RE: [PHP] Coding Style Question...

2006-10-02 Thread Jay Blanchard
[snip]
What do you think?
[/snip]

I think I'd like an ice cold beer.

I code PHP like I code C++, heavily commented with code designed to fit
the needs of the application. There is a thing in PEAR concerning style
(you can Google it pretty easily) and you will as many styles as you do
PHP developers. 

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



Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread Paul Scott
On Fri, 2006-03-03 at 16:19 -0500, tedd wrote:
> Perhaps I'm fortunate, but I usually find a way around using Globals. 
> And since I've been coding in PHP, I've never been forced to use them.
> 

Just my 2c...

In our framework, I use globals as well, although I do tend to agree
with Tedd regarding workarounds rather... :)

Something like so:

I create a global to hold the db object (in my case MDB2 or PEAR DB) and
then use a loadclass function to get the dbconfig from another module.
This creates a nice way to easily pick it up wherever its needed. I then
use the factory method to instantiate the db abstraction layer and pass
it, through my "engine class" to an "object class" where I further
abstract the db functions through a central db class. All of the modules
in the system that have database derived classes extend my dbTable
class, thereby keeping everything centralised.

In dbTable class, I evaluate if the db object exists, and if it *really*
doesn't, I create it through the engine. This makes for "lazy"
evaluation of the db object, so that it works kinda on demand, rather
than on every request.

Using this method, I can also use a global error callback method to
handle _all_ database errors gracefully, using PEAR_Error. I do think
that there may be a slight performance hit doing it this way, but in an
app with over 180 000 lines of code (so far) I find it works just
fine...

--Paul

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



Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread Rafael

Andreas Korthaus wrote:

Hi Gustav!

Gustav Wiberg wrote:

My oponion is that is insane to use global variables. The main 
drawback with global variables is that is very easy to mix up 
variables, and keep track of what variable belongs to what. So an 
advice: Don't use it!



Ok, so what's your recommendation to solve the problem with using a DB 
class in many other objects/methodes? Think of a DB class:


class DB {...}

And a lot of classes which want to use the DB class:

class Foo {
  function saveChangesInDb() {...}
}

class Bar {
  function saveChangesInDb() {...}
}

- You can use a global "$db = new DB..." and pass it to every 
class/methode,


- you can make $db "global" in each methode,

- you can create a new instance ("new DB") in every methode (but you 
usually only want a single DB-connection per script, and where do you 
pass config-data to access the DB?) or


- use a factory/singleton, which is not so much better than a global 
variable (and again, what about config-data?).



So what's the way you'd recommend and why?


	IMHO, the only way a global variable would have sense is in an 
environment where you can be assured there's a "DBClass" $db instance, 
and that it would never ever be a $db var that's not a DBClass instance 
nor will $db ever be missing.  So, can you guarantee this at the present 
and to the end of times? :)


	I think it would be better to create an instance of $db whatever the 
script you need it, and pass it to every class-constructor as a 
byref-parameter; i.e.


  $db =& new DBClass();
  ···
  $class1 =& new Class1($db);
  ···
  $class2 =& new Class2($db);

	Now, if you insist on using global vars, then maybe, just maybe, it 
would be better to let that byref-param be optional, and check in the 
constructor for a global DBClass instance $db if no DBClass instance was 
given, but then again the problem would be pretty much the same.  Try 
not to rely on global vars, bear in mind that global vars almost always 
give too little info and do not reflect themselves on the function 
prototype --well, if you have a smart IDE/editor that understand PHPDoc 
comments (or something like that) and you do document their existance, 
it might not be that bad, but still try to avoid them.

--
Atentamente,
J. Rafael Salazar Magaña
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
http://www.innox.com.mx

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



Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread tedd

So what's the way [using Globals] you'd recommend and why?

best regards
Andreas


Andreas:

I have to agree with Gustav on this -- I very seldom use Globals. I 
might use one for debugging, but not for finished code. Their use 
simply creates problems in porting code, keeping things modular, and 
maintenance.


Perhaps I'm fortunate, but I usually find a way around using Globals. 
And since I've been coding in PHP, I've never been forced to use them.


tedd

--

http://sperling.com

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



Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread Robert Cummings
On Fri, 2006-03-03 at 14:53, Andreas Korthaus wrote:
>
> - use a factory/singleton, which is not so much better than a global 
> variable (and again, what about config-data?).

I use a global configuration to register database connection params.
InterJinn uses something like the following:

$GLOBALS['interJinn']['databases'] = array
(
'carnageWeb' => array
(
'type' => 'mysql',
'host' => 'wocmud.org',
'user' => 'me',
'password' => 'noyou',
'db'   => 'carnage_web'
),

'carnage' => array
(
'host' => 'wocmud.org',
'user' => 'me',
'password' => 'notyouagain',
'db'   => 'carnage'
),

'carnageForum' => array
(
'host' => 'wocmud.org',
'user' => 'me',
'password' => 'notyouyetagain',
'db'   => 'carnage_forum'
),

'default'   => 'carnageWeb',
);

This is consumed by the database manager which is a singleton/factory
that uses connection pooling.

getServiceRef( 'dbManager' );

$db = &$mDb->getConnectionRef();
$db->query( 'blah blah blah' );

$db2 = &$mDb->getConnectionRef();
$db2->query( 'bleh bleh bleh' );

$db3 = &$mDb->getConnectionRef( 'carnageForum' );
$db3->query( 'bleh bleh bleh' );

$db->free();
$db2->free();
$db3->free();
?>

In this way all database connections are named such that if something
changes in the future, whether it be the name of the database, the type
of database server, the port, whatever, my code shouldn't need to change
-- only the configuration. Additionally since I retrieve from a pool, I
only ever use as many connections as I need at a time. Be that 1 or 3 or
5. Additionally I know that when I retrieve a second database instance
it's not going to clobber the query from the first request.

I advocate use of the $GLOBALS array for configuration information that
remains static and only when the purpose is clearly defined and well
named such that you can be very sure that you won't run into naming
conflicts in the near future. This is why I use an interJinn sub array
within the globals to segregate InterJinn specific configuration vars.
I'd advocate using constants but they don't support arrays, or at least
not as far back as I maintain compatibility. Why the PHP guys didn't
foresee constant array values is anyone's guess *lol*.

You'll also notice I retrieve the factory/singleton by means of named
service. This avoids most of that interface/inheritance bullshit that
Java gets mired in (and PHP5 has embraced *hahah*). As long as the
expected methods exist then any class can be dropped in as a replacement
via the service registry, whether it extends, implements, burps, or
farts the original class -- or not :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread Gustav Wiberg


- Original Message - 
From: "Andreas Korthaus" <[EMAIL PROTECTED]>

To: ; "Gustav Wiberg" <[EMAIL PROTECTED]>
Sent: Friday, March 03, 2006 8:53 PM
Subject: Re: [PHP] Coding Practice: Use global $var or pass in by refernce



Hi Gustav!

Gustav Wiberg wrote:

My oponion is that is insane to use global variables. The main drawback 
with global variables is that is very easy to mix up variables, and keep 
track of what variable belongs to what. So an advice: Don't use it!


Ok, so what's your recommendation to solve the problem with using a DB 
class in many other objects/methodes? Think of a DB class:


class DB {...}

And a lot of classes which want to use the DB class:

class Foo {
  function saveChangesInDb() {...}
}

class Bar {
  function saveChangesInDb() {...}
}

- You can use a global "$db = new DB..." and pass it to every 
class/methode,


- you can make $db "global" in each methode,

- you can create a new instance ("new DB") in every methode (but you 
usually only want a single DB-connection per script, and where do you pass 
config-data to access the DB?) or


- use a factory/singleton, which is not so much better than a global 
variable (and again, what about config-data?).



So what's the way you'd recommend and why?


best regards
Andreas

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


Hi Andreas!

I don't have that much experience with classes, but wouldn't it work to:

1. make a connection to the db like $db = , and then pass around 
this variable?


2. Extend the DB - class, so the saveChangesInDb()  - function in the 
Foo-class would be an extension from the DB-class

? (I think this works to extend a class in PHP right?)

3 . Use already existing classes for db...http://www.phpclasses.org/ PHP 
Scripts / Databases


I hope this'll help!

/G

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



Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread Luis Magaña

I would go for:

- you can create a new instance ("new DB") in every methode (but you
  usually only want a single DB-connection per script, and where do you
  pass config-data to access the DB?) or

This way the code keeps well organized and about the use of only one 
connection I wouldn't worry too much since usually one thread/process is 
created per script called, so if this is a multiuser application you end 
up with several connections anyway, besides I think PHP reuses the 
connections when possible so the performance of your application does 
not seem affected at all.


I use it, works perfectly with big databases and several users.

Regards.

Andreas Korthaus wrote:

Hi Gustav!

Gustav Wiberg wrote:

My oponion is that is insane to use global variables. The main 
drawback with global variables is that is very easy to mix up 
variables, and keep track of what variable belongs to what. So an 
advice: Don't use it!


Ok, so what's your recommendation to solve the problem with using a DB 
class in many other objects/methodes? Think of a DB class:


class DB {...}

And a lot of classes which want to use the DB class:

class Foo {
  function saveChangesInDb() {...}
}

class Bar {
  function saveChangesInDb() {...}
}

- You can use a global "$db = new DB..." and pass it to every 
class/methode,


- you can make $db "global" in each methode,

- you can create a new instance ("new DB") in every methode (but you 
usually only want a single DB-connection per script, and where do you 
pass config-data to access the DB?) or


- use a factory/singleton, which is not so much better than a global 
variable (and again, what about config-data?).



So what's the way you'd recommend and why?


best regards
Andreas



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



Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread Andreas Korthaus

Hi Gustav!

Gustav Wiberg wrote:

My oponion is that is insane to use global variables. The main drawback 
with global variables is that is very easy to mix up variables, and keep 
track of what variable belongs to what. So an advice: Don't use it!


Ok, so what's your recommendation to solve the problem with using a DB 
class in many other objects/methodes? Think of a DB class:


class DB {...}

And a lot of classes which want to use the DB class:

class Foo {
  function saveChangesInDb() {...}
}

class Bar {
  function saveChangesInDb() {...}
}

- You can use a global "$db = new DB..." and pass it to every class/methode,

- you can make $db "global" in each methode,

- you can create a new instance ("new DB") in every methode (but you 
usually only want a single DB-connection per script, and where do you 
pass config-data to access the DB?) or


- use a factory/singleton, which is not so much better than a global 
variable (and again, what about config-data?).



So what's the way you'd recommend and why?


best regards
Andreas

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



Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread Gustav Wiberg
- Original Message - 
From: "Mark Steudel" <[EMAIL PROTECTED]>

To: 
Sent: Friday, March 03, 2006 7:46 PM
Subject: [PHP] Coding Practice: Use global $var or pass in by refernce



I was wondering what the general rule on using the global driective versus
passing in a variable by reference, why you should or shouldn't, etc.

e.g.

function ()
{
   global $db;

   $res =& $db->query( "SQL");
}

or

function ( &$db )
{

   $res =& $db->query( "SQL");
}

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


Hi!

My oponion is that is insane to use global variables. The main drawback with 
global variables is that is very easy to mix up variables, and keep track of 
what variable belongs to what. So an advice: Don't use it!


/G

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



Re: [PHP] Coding Question

2004-12-13 Thread Justin French
On 07/12/2004, at 6:50 AM, Al wrote:
Jason Wong wrote:
On Monday 06 December 2004 14:19, Rory Browne wrote:
If I'm not mistaken Al wanted to return something if the thing 
failed,
without having to put it inside an if_block.

I'm watching this with curiosity, because return is a language
construct, and not a function, or anything that has a value.
You can have:
  ... OR $error = "Oh dear";
But the say I see it, eventually, somewhere in your code you need to 
test for it. Essentially you're just moving the test somewhere else.

Essentially, I'm creating warning reports for my users, not code 
errors.  The users can then email the warnings to our webmaster.
That's totally the wrong approach.  Dumping errors to the screen and 
asking the end user to create an email for the webmaster is just a 
fantasy.  99% of users will walk away and never return.  It's bad user 
experience, and it's a crisis point that you're handling badly.

A better plan would be to hide all the errors from the user, log them 
to and error log, automatically email the webmaster, and present a 
simple "something went wrong, sorry, we're working on it" to the user.

They don't need to know anything about mysql, tables, databases, etc -- 
the WEBMASTER does, but not the user.

---
Justin French, Indent.com.au
[EMAIL PROTECTED]
Web Application Development & Graphic Design
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Coding Question

2004-12-06 Thread Al
Richard Lynch wrote:
Al wrote:
Essentially, I'm creating warning reports for my users, not code errors.
 > The
users can then email the warnings to our webmaster.
Jason Wong wrote:
On Monday 06 December 2004 14:19, Rory Browne wrote:
$result = mysql_db_query($db,"select count(*) from $table")
OR $values['msg']= $values['msg'] . "Could not connect 
to mySQL
Table: $table";

//tech notes and db table stuff
The calling page echoes $values['msg'] in nice red text.

Here's what's wrong with this plan:
#1.
You are exposing the fact that you use MySQL to users.  So malicous users
don't need to figure out that you are using MySQL: They can just start
trying all the MySQL things to break into your server.
As a general rule, you do not want users to know what software/version you
are running.
While this does fall into the "security by obscurity" category, which is
generally not "good" there are compelling arguments for making it harder
for the bad guys to figure out what software you are using.
#2.
They won't.
Oh, sorry.
The USERS will *NOT* email your message to the webmaster.  Oh, some will. 
Most, however, will email your webmaster with oh-so-usefull messages like.
"I was on your website, and I got an error message, and it's broken.
HELP!"

Put the details you need to debug your software in a place where you
webmaster can read them, no matter what the user does to mangle, shorten,
or otherwise ruin the message.
http://php.net/error_log is good for this.
#3.
It's just Bad Form to tell users a bunch of crap they don't understand,
don't care about, and can only be puzzled by.  The message the users see
should be more like:  "Website down for maintenance.  Please try again
later."
The error messages you need to FIX the site are in the Apache log (or your
own logfile) where they belong.

There might be some exceptions to all this -- If you have only one or two
admin people, whom you trust to actually copy &paste the error messages
and send them to you, displaying them on those admin screens is not so
bad.  That user is probably your client who already knows what software is
in use (or can find out easily) and isn't likely to sabotage their own
site, and can maybe be trained to do the right thing...  OTOH, logging to
a file and giving them a message they understand ("Something broke.  Call
Rich and tell him what you were doing.") is probably better anyway.
I greatly appreciate your taking an interest in my question.
I didn't explain all the details since I was trying to keep my message short.
My users are not public.  They are a few selected individuals who only have 
access via an Apache authentication dialog.

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


Re: [PHP] Coding Question

2004-12-06 Thread Richard Lynch
Al wrote:
> Essentially, I'm creating warning reports for my users, not code errors.
 > The
> users can then email the warnings to our webmaster.
>
> Jason Wong wrote:
>> On Monday 06 December 2004 14:19, Rory Browne wrote:
>>
>>  $result = mysql_db_query($db,"select count(*) from $table")
>>  OR $values['msg']= $values['msg'] . "Could not connect 
>> to mySQL
>> Table: $table";

//tech notes and db table stuff
>
> The calling page echoes $values['msg'] in nice red text.

Here's what's wrong with this plan:

#1.
You are exposing the fact that you use MySQL to users.  So malicous users
don't need to figure out that you are using MySQL: They can just start
trying all the MySQL things to break into your server.

As a general rule, you do not want users to know what software/version you
are running.

While this does fall into the "security by obscurity" category, which is
generally not "good" there are compelling arguments for making it harder
for the bad guys to figure out what software you are using.

#2.
They won't.
Oh, sorry.
The USERS will *NOT* email your message to the webmaster.  Oh, some will. 
Most, however, will email your webmaster with oh-so-usefull messages like.
"I was on your website, and I got an error message, and it's broken.
HELP!"

Put the details you need to debug your software in a place where you
webmaster can read them, no matter what the user does to mangle, shorten,
or otherwise ruin the message.

http://php.net/error_log is good for this.

#3.
It's just Bad Form to tell users a bunch of crap they don't understand,
don't care about, and can only be puzzled by.  The message the users see
should be more like:  "Website down for maintenance.  Please try again
later."

The error messages you need to FIX the site are in the Apache log (or your
own logfile) where they belong.



There might be some exceptions to all this -- If you have only one or two
admin people, whom you trust to actually copy &paste the error messages
and send them to you, displaying them on those admin screens is not so
bad.  That user is probably your client who already knows what software is
in use (or can find out easily) and isn't likely to sabotage their own
site, and can maybe be trained to do the right thing...  OTOH, logging to
a file and giving them a message they understand ("Something broke.  Call
Rich and tell him what you were doing.") is probably better anyway.

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

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



Re: [PHP] Coding Question

2004-12-06 Thread Al
Jason Wong wrote:
On Monday 06 December 2004 14:19, Rory Browne wrote:
If I'm not mistaken Al wanted to return something if the thing failed,
without having to put it inside an if_block.
I'm watching this with curiosity, because return is a language
construct, and not a function, or anything that has a value.

You can have:
  ... OR $error = "Oh dear";
But the say I see it, eventually, somewhere in your code you need to test for 
it. Essentially you're just moving the test somewhere else.


Essentially, I'm creating warning reports for my users, not code errors.  The 
users can then email the warnings to our webmaster.

Here's what I ended up with:

@$host_link= mysql_connect($host, $user, $pw) 
		OR $values['msg']= $values['msg'] . "Could not connect to mySQL host ";
	   
	
	if($host_link){
		$db_link= mysql_select_db($db, $host_link)
			OR $values['msg']= $values['msg'] . "Could not connect to mySQL DB: $db";
	}
	
	if($host_link AND $db_link){
		$result = mysql_db_query($db,"select count(*) from $table")
			OR $values['msg']= $values['msg'] . "Could not connect to mySQL Table: $table";
	}
	if($host_link AND $db_link AND $result){
	
	$values['num_records'] = ($result>0) ? mysql_result($result,0,0) : 0;
		
	}//end if
		
	return $values;		//tech notes and db table stuff
The calling page echoes $values['msg'] in nice red text.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Coding Question

2004-12-06 Thread Richard Lynch
Al wrote:
> I've searched the PHP manual and can't find an answer for this question
>
> I'd like to use the "OR DIE" construct; but instead of "DIE" I'd like to
> use
> "RETURN FOO". I haven't found a way to do it.
>
>
> $string= file_get_contents($filename)
>   OR die("Could not read file");
>
> $db_link= mysql_connect($host, $user, $pw)
> OR die("Could not connect: " . mysql_error());
>
> Seems like it would be nice to not have to test first, e.g.,
> if(is_readable($filename)){ }

You may want to use:

or http://php.net/exit
or http://php.net/return

I will not guarantee that either will work, much less do what you want,
which I don't really understand in the first place.

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

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



Re: [PHP] Coding Question

2004-12-05 Thread Jason Wong
On Monday 06 December 2004 14:19, Rory Browne wrote:
> If I'm not mistaken Al wanted to return something if the thing failed,
> without having to put it inside an if_block.
>
> I'm watching this with curiosity, because return is a language
> construct, and not a function, or anything that has a value.

You can have:

  ... OR $error = "Oh dear";

But the say I see it, eventually, somewhere in your code you need to test for 
it. Essentially you're just moving the test somewhere else.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
There's a whole WORLD in a mud puddle!
  -- Doug Clifford
*/

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



Re: [PHP] Coding Question

2004-12-05 Thread Rory Browne
If I'm not mistaken Al wanted to return something if the thing failed,
without having to put it inside an if_block.

I'm watching this with curiosity, because return is a language
construct, and not a function, or anything that has a value.

I could probably have said that better sober, and not at 06:16am, but
hopefully  you get my drift.

On Mon, 06 Dec 2004 09:11:26 +1000, Ligaya Turmelle <[EMAIL PROTECTED]> wrote:
> 
>  > $db_link= mysql_connect($host, $user, $pw)
>  >OR die("Could not connect: " . mysql_error());
> 
> 
> try:
> $db_link= mysql_connect($host, $user, $pw);
> if (!$db_link){
> // do whatever if there is something wrong
> }
> 
> maybe try something like that with the file_get_contents also?
> 
> Respectfully,
> Ligaya Turmelle
> 
> ---
> Life is a game... so have fun.
> ---
> www.PHPCommunity.org
> Open Source, Open Community
> Visit for more information or to join the movement
> 
> 
> 
> 
> Al wrote:
> > I've searched the PHP manual and can't find an answer for this question
> >
> > I'd like to use the "OR DIE" construct; but instead of "DIE" I'd like to
> > use "RETURN FOO". I haven't found a way to do it.
> >
> >
> > $string= file_get_contents($filename)
> > OR die("Could not read file");
> >
> > $db_link= mysql_connect($host, $user, $pw)
> >OR die("Could not connect: " . mysql_error());
> >
> > Seems like it would be nice to not have to test first, e.g.,
> > if(is_readable($filename)){ }
> >
> > Thanks
> >
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

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



Re: [PHP] Coding Question

2004-12-05 Thread Ligaya Turmelle

> $db_link= mysql_connect($host, $user, $pw)
>OR die("Could not connect: " . mysql_error());

try:
$db_link= mysql_connect($host, $user, $pw);
if (!$db_link){
   // do whatever if there is something wrong
}
maybe try something like that with the file_get_contents also?
Respectfully,
Ligaya Turmelle
---
Life is a game... so have fun.
---
www.PHPCommunity.org
Open Source, Open Community
Visit for more information or to join the movement

Al wrote:
I've searched the PHP manual and can't find an answer for this question
I'd like to use the "OR DIE" construct; but instead of "DIE" I'd like to 
use "RETURN FOO". I haven't found a way to do it.

$string= file_get_contents($filename)
OR die("Could not read file");
$db_link= mysql_connect($host, $user, $pw)
   OR die("Could not connect: " . mysql_error());
Seems like it would be nice to not have to test first, e.g., 
if(is_readable($filename)){ }

Thanks

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

Re: [PHP] Coding Blues - Parse Error

2004-09-15 Thread Oliver Kurz
Hello Yusuf,

>  Class fl_SQL
> {
>  var $server;
>  var $user;
>  var $pass;
> 
>  var $connection;
>  var $db;
> 
>  var $query;
>  var $record;
>  var $tlist;
>  }

The bracket is wrong. Your class only has properties but no methods. 
 
> Function fl_SQL($server, $user, $pass, $db = NULL) {
>  $this->server = $server;
>  $this->user = $user;
>  $this->pass = $pass;
>  $this->db = $db;
> }
> 
> Function doconnect($db = $this->db){
>  $this->db = $db

Missing ;

>  $this->connection = mysql_connect($this->server, $this->user, 
> $this->pass);
>  if (!$this->connect) die ("Could not connect to server!");

$this->connect??? Do you mean $this->connection?

>  mysql_select_db($this->db,$this->connection) or die ("Could not 
> connect to database!");
> }
> 
> Function doquery($query, $db = $this->db){
>  $this->db = $db

Missing ;
>  $this->connect($this->db);

Do you mean $this->doconnect?

>  $this->query = $query
>  mysql_query($this->query,$this->connect)

And again: Do you mean $this->connection?

> }
> 
> }

Their is the right bracket for the class definition.
 
> ?>

Also your default-values for the method-parameters have to be constant. So ... try it 
like in your constructor. And check it with an if-statement. 
And also ... check the names of your properties and methods. It looks like there is a 
big mess.

So long,

Oliver


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

Re: [PHP] Coding Blues - Parse Error

2004-09-15 Thread John Holmes
Dan Joseph wrote:
	You don't have a ; at the end of the line.  You have $this->db =
$db and you should have $db;.  
Also, this:
> Function doquery($query, $db = $this->db){
is causing your error. The default value must be a constant expression, 
not a variable, function, method, etc...

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Coding Blues - Parse Error

2004-09-15 Thread Dan Joseph
Hi,

You don't have a ; at the end of the line.  You have $this->db =
$db and you should have $db;.  

-Dan Joseph

-Original Message-
From: Yusuf [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 15, 2004 11:19 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Coding Blues - Parse Error

Hello. I am writing some code, but though everything seems ok, I get the

same error:
"parse error, unexpected T_VARIABLE on line 23" .

Here is the code:

server = $server;
$this->user = $user;
$this->pass = $pass;
$this->db = $db;
}

Function doconnect($db = $this->db){
$this->db = $db
$this->connection = mysql_connect($this->server, $this->user, 
$this->pass);
if (!$this->connect) die ("Could not connect to server!");
mysql_select_db($this->db,$this->connection) or die ("Could not 
connect to database!");
}

Function doquery($query, $db = $this->db){
$this->db = $db
$this->connect($this->db);
$this->query = $query
mysql_query($this->query,$this->connect)
}

}

?>


Can anyone please help me?

Thanking you in anticipation,
Yusuf

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

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



Re: [PHP] Re: php coding software

2004-08-03 Thread Jordi Canals
Oliver John V. Tibi wrote:
in addition to brad's post, does anyone know of coding software that
supports team development environments and/or a versioning server for
windows?
I use Zend Studio wich provides CVS integration. But I'm sure you will 
find some others with CVS support. If not, I will recommend you to get 
WinCVS wich provides a nice and easy-to-use CVS interface. (And you can 
get CVSnt for a Windows based CVS server).

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


[PHP] Re: php coding software

2004-08-02 Thread Oliver John V. Tibi
in addition to brad's post, does anyone know of coding software that
supports team development environments and/or a versioning server for
windows?

TIA!

-- 

Running 'ojtibi' on '127.0.0.1' (BATCH_OPTIMISTIC mode).
"Live free() or die()."

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



RE: [PHP] Re: php coding software

2004-08-02 Thread Vail, Warren
For what it's worth, I use HTML-Kit as well.  Feature I like best is the
ability to seamlessly edit content of remote sites and local (folder based)
sites.

Warren Vail


-Original Message-
From: Harlequin [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 02, 2004 5:15 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: php coding software


Brad

I use HTML-Kit for HTML, ASP, Java, CSS, PHP and MySQL.

Free too :)

-- 
-
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-
"Brad Ciszewski" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Does anyone know any good software for PHP/mysql coding? I currently 
> use DreamWeaver MX, however it doesn't have much PHP support, and no 
> MySQL support. I just want an easy program to script in, and upload on 
> to my webserver. Please help! :o
>

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

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



[PHP] Re: php coding software

2004-08-02 Thread Harlequin
Brad

I use HTML-Kit for HTML, ASP, Java, CSS, PHP and MySQL.

Free too :)

-- 
-
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-
"Brad Ciszewski" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Does anyone know any good software for PHP/mysql coding? I currently use
> DreamWeaver MX, however it doesn't have much PHP support, and no MySQL
> support. I just want an easy program to script in, and upload on to my
> webserver. Please help! :o
>

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



[PHP] Re: php coding software

2004-08-02 Thread Chris Martin
Jordi Canals wrote:
Brad Ciszewski wrote:
Does anyone know any good software for PHP/mysql coding? I currently use
DreamWeaver MX, however it doesn't have much PHP support, and no MySQL
support. I just want an easy program to script in, and upload on to my
webserver. Please help! :o

Sorry, but you're wrong. Dreamweaver DOES have MySQL support and can 
connect to MySQL databases to help coding your scripts.

Yes. PHP and MySQL is supported in DWMX, no extensions required.
FTPEdit and HTMLKit are both free editors for Windows
Quanta and Bluefish are excellent on GNU/Linux
--
Chris Martin
Web Developer
Open Source & Web Standards Advocate
http://www.chriscodes.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Coding Advice

2004-07-21 Thread Matt M.
> I am writing an app and right now im working on code that will display x
> number of items on one page, and if there is overflow, provide a link to
> the next.  The url coming into the page looks something like:
> 
> projects.php?action=view&completed=no&start=0
> 
> My code so far, i just took the $_SERVER['REQUEST_URI'] and added
> start=newstart to the end.
> 
> The problem is, i will eventually get a string thats very long, ebcause
> start keeps appending onto the end.  What is the easiest way to preserve
> projects.php?action=view&completed=no and be able to add start=somenumber
> to the end?


if you only need to pass 2 other variables, why not just build the
query string from scratch each time?

you could always do a string replacement on start=whatever instead of
just appending it to the end each time.

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



Re: [PHP] Coding productivity benchmarks?

2004-06-07 Thread Derrick fogle
On Jun 7, 2004, at 11:39 AM, Tyler Replogle wrote:
I just did all of that and it took me 1 hour and 35 mins
Just for grins and giggles, why don't I post the exact assignment specs?
FYI, I've never really had to deal with file uploads and downloads 
before. It probably took me to an hour to research PHP file 
upload/download/MySQL storage, and get that part working. I could do it 
much faster next time ;-)

As for the layout issue, I suppose that's my big 'weak point' as a 
developer. The templates I started from have a basic interface 
structure already, so I went ahead and developed the code and the basic 
interface together. That took extra time beyond just puking out the 
bare minimum. I've spent so many years doing database development for 
customers that I view the real functionality of an application by how 
the interface looks and acts more than how the underlying code is 
written. I just can't see the forest for the trees, and I can't see a 
functional web app without an interface that matches the workflow.

Anyway, here's the actual assignment specs:

XXX Company is publishing an on-line journal and needs to provide a 
system for electronic manuscript management with the following 
features:
1. All submitted documents should be able to be uploaded and downloaded 
in word format.
2. There should be 3 user roles: Author, Reviewer and Editor
3. There should be a way for a new user to register as either one of 
the 3 roles. During registration, the new user should be able to enter 
first and last name, e-mail address and what kind of user he wishes to 
be (author, reviewer or editor).
4. When a user logs in to the system, he should be presented with a 
screen, depending on what role he has in the system.
  a. As an editor, the user should be able to delete a user, change 
registration information of any user, view the status of each submitted 
article, view reviewer suggestions, accept or decline an article for 
publication, or assign it to a reviewer for review.
  b. As a reviewer, the user should be able to download a submitted 
article to review and recommend the article for publication or not.
  c. As an author, the user should be able to submit a file.
5. An article can have one of these states:
  a. Submitted (after submission)
  b. In review (after reviewers are assigned)
  c. Accepted (if accepted by the editor)
  d. Declined (if declined by the editor)
6. A typical workflow should consist of the following states:
  a. An author submits an article. The article status becomes 
“submitted”. The editor may view the article (by downloading it) or 
assign it to a reviewer.
  b. An editor assigns an article to a reviewer. The article status 
becomes “in review”. The reviewer may now download the article and he 
may also suggest accepting it or declining it.
  c. A reviewer makes a suggestion. The article status remains “in 
review”. The editor may now view the suggestion of the reviewer and he 
may also accept or decline the article.
  d. An editor accepts or declines an article. The article status 
becomes “accepted” or “declined” accordingly.


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


RE: [PHP] Coding productivity benchmarks?

2004-06-07 Thread Tyler Replogle
hey,
I just did all of that and it took me 1 hour and 35 mins, but I edited the 
code that i had already made from site before. It didn't take my anywhere 
near 4 hours, but there is no way i could do it in 40 mins.



From: Derrick fogle <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> 
<[EMAIL PROTECTED]>
Subject: [PHP] Coding productivity benchmarks?
Date: Mon, 7 Jun 2004 09:51:20 -0500

I've been searching around for productivity benchmarks for PHP programming. 
The only references I can find for it are in for-pay publications.

I've ended up becoming a PHP developer more out of happenstance than 
anything. I've been doing it for a couple of years now, but... I don't 
really know how 'good' I am at it. The place I work has always had 
extremely unreasonable expectations for worker productivity, and I'm trying 
to fight that.

I've recently been called into another job interview, and part of the 
interview is a coding assignment. Some of the documentation suggests that 
this assignment should take about 40 minutes.  A rough overview of the 
'assignment' - a simple Document Management System - is:
 * new user registration and existing user login
 * admin-level user management
 * document upload and download
 * review and suggestion
 * a conditional matrix of 5 document conditions vs 3 user levels
 * 6 input forms
 * 2 listing layouts with fix sorting
 * conditional access to changing document conditions based on user levels

It took me about 4 hours to completely satisfy and debug the assignment 
specs with an OK interface. This was with plenty of code copy/modification 
from other web apps I've done before, or other online resources. I ended up 
spending nearly 4 more hours futzing around with the interface to get 
something really nice.

So, am I just a pretender? Are there people out there that can really bust 
out a basic DMS in 40 minutes?

If anyone does have some basic PHP programmer productivity benchmarks, or 
knows where I can get ahold of them, I'd sure appreciate it. This issue of 
productivity expectations has really gotten under my skin, and I need to 
know whether or not I should be doing this for a living.

Thanks,
-Derrick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_
MSN Toolbar provides one-click access to Hotmail from any Web page – FREE 
download! http://toolbar.msn.click-url.com/go/onm00200413ave/direct/01/

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


Re: [PHP] Coding productivity benchmarks?

2004-06-07 Thread Brent Baisley
Nothing in the specs you listed mentioned anything about a pretty, 
intuitive GUI interface.  Drop a nice interface requirement and that 
cuts your time considerably. Forget trying to design an "event driven" 
interface and drop back on the old mainframe menu driven interface with 
one option per screen. Then you just need to design some generic code 
that spits out some fields with labels and a continue/save or cancel 
button.
"Tests" like these are usually looking more for coding talent and 
technique (i.e. code reuse, object orientation, readability, MVC, etc.) 
rather than interface design talent. They're most likely trying to 
separate the web front end people from the back end people.

On Jun 7, 2004, at 10:51 AM, Derrick fogle wrote:
I've been searching around for productivity benchmarks for PHP 
programming. The only references I can find for it are in for-pay 
publications.

I've ended up becoming a PHP developer more out of happenstance than 
anything. I've been doing it for a couple of years now, but... I don't 
really know how 'good' I am at it. The place I work has always had 
extremely unreasonable expectations for worker productivity, and I'm 
trying to fight that.

I've recently been called into another job interview, and part of the 
interview is a coding assignment. Some of the documentation suggests 
that this assignment should take about 40 minutes.  A rough overview 
of the 'assignment' - a simple Document Management System - is:
 * new user registration and existing user login
 * admin-level user management
 * document upload and download
 * review and suggestion
 * a conditional matrix of 5 document conditions vs 3 user levels
 * 6 input forms
 * 2 listing layouts with fix sorting
 * conditional access to changing document conditions based on user 
levels

It took me about 4 hours to completely satisfy and debug the 
assignment specs with an OK interface. This was with plenty of code 
copy/modification from other web apps I've done before, or other 
online resources. I ended up spending nearly 4 more hours futzing 
around with the interface to get something really nice.

So, am I just a pretender? Are there people out there that can really 
bust out a basic DMS in 40 minutes?

If anyone does have some basic PHP programmer productivity benchmarks, 
or knows where I can get ahold of them, I'd sure appreciate it. This 
issue of productivity expectations has really gotten under my skin, 
and I need to know whether or not I should be doing this for a living.

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

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Coding productivity benchmarks?

2004-06-07 Thread Richard Davey
Hello Derrick,

Monday, June 7, 2004, 3:51:20 PM, you wrote:

Df> So, am I just a pretender? Are there people out there that can really
Df> bust out a basic DMS in 40 minutes?

I would say that there probably are - but you'd have to question how
robust and well designed their system would be after those 40 minutes
are up. Assuming you weren't allowed to use any external help by way
of PEAR/Smarty/ADOdb/etc then I would have said that building a
friendly system that met all of those criteria in 4 hours is nothing
to be ashamed of.

I'm sorry I don't have any benchmarks for you, but I'd love to know
how anyone could ever create an accurate benchmark for something as
subjective as this anyway. Having worked with PHP for years and
interviewed many people, I would have to say what you were required to
do was quite un-usual and ill thought-out. If they had given you 40
mins to write a document telling how you would approach the system -
that would have been more like it.

This reminded me of an incident where a company local to me was
holding interviews and getting the applicants to actually work on
sites they needed finishing off (basic html stuff) as part of the
interview! Never gave them the job of course, just got them to finish
the projects. Needless to say, they aren't trading any longer :)

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I am not young enough to know everything." - Oscar Wilde

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



Re: [PHP] Re: PHP Coding Standards

2004-06-02 Thread Justin French
On 02/06/2004, at 3:00 AM, Justin Patrin wrote:
And I'm one of them. :-) I like the K&R version because it saves 
verticaly space and most editors can't really handle correct tabbing 
when you put it after. IMHO it's just not necessary as ALL blocks 
should have braces, even those that are one-line. If you always use 
the braces,  you can looks for indenting as the open of the block and 
the end-brace (and un-indenting) as the close of the block.
I used to be a big fan of both versions, but honestly, I didn't care, 
as long as an app was consistent, so that one could become comfortable 
with it over time.  The reality is that good editors like BBEdit can 
help match braces, highlight code blocks, etc.

But recently, I've changed my tactic to whatever helps the code be as 
readable and clear as possible...

$file = 'a'; if(file_exists($file)) { include($file); }
$file = 'b'; if(file_exists($file)) { include($file); }
$file = 'c'; if(file_exists($file)) { include($file); } else { 
include('x'); }
$file = 'd'; if(file_exists($file)) { include($file); } else { 
include('x'); }
$file = 'e'; if(file_exists($file)) { include($file); }

is a lot clearer,line-efficient and faster to comprehend than...
$file = 'a';
if (file_exists($file)) {
include($file);
}
$file = 'b';
if (file_exists($file)) {
include($file);
}
$file = 'c';
if (file_exists($file)) {
include($file);
} else {
include('x');
}
$file = 'd';
if (file_exists($file)) {
include($file);
} else {
include('x');
}
$file = 'e';
if (file_exists($file)) {
include($file);
}
Of course, looping through an array of file names would be even 
clearer, but you get my point :)

---
Justin French
http://indent.com.au
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: PHP Coding Standards

2004-06-01 Thread Justin Patrin
Travis Low wrote:
Justin Patrin wrote:
Travis Low wrote:
 [I hate K&R indenting]

And I'm one of them. :-) I like the K&R version because it saves 
verticaly space and most editors can't really handle correct tabbing...

Arrggghh...TABS.  Don't even get me started on tabs...
cheers,
Travis
I meant indenting. I won't get into tabs vs. spaces here. ;-)
--
paperCrane 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Re: PHP Coding Standards

2004-06-01 Thread Jay Blanchard
[snip]
>>  [I hate K&R indenting]
> 
> And I'm one of them. :-) I like the K&R version because it saves 
> verticaly space and most editors can't really handle correct
tabbing...

Arrggghh...TABS.  Don't even get me started on tabs...
[/snip]

How many holy wars can be started in one thread legally?

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



Re: [PHP] Re: PHP Coding Standards

2004-06-01 Thread Travis Low
Justin Patrin wrote:
Travis Low wrote:
 [I hate K&R indenting]
And I'm one of them. :-) I like the K&R version because it saves 
verticaly space and most editors can't really handle correct tabbing...
Arrggghh...TABS.  Don't even get me started on tabs...
cheers,
Travis
--
Travis Low


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


Re: [PHP] Re: PHP Coding Standards

2004-06-01 Thread Justin Patrin
Travis Low wrote:
I have to say I like everything about the PEAR coding standards except 
for the K&R bracing style.  I much prefer:

  if( foo )
  {
 blah;
  }
to
  if( foo ) {
 blah;
  }
The latter form (K&R) conserves vertical space, but I find it a lot 
harder to follow.  Harder to move blocks of code around too.  I'm sure 
plenty of people disagree, so of course this is IMHO.
And I'm one of them. :-) I like the K&R version because it saves 
verticaly space and most editors can't really handle correct tabbing 
when you put it after. IMHO it's just not necessary as ALL blocks should 
have braces, even those that are one-line. If you always use the braces, 
 you can looks for indenting as the open of the block and the end-brace 
(and un-indenting) as the close of the block.

cheers,
Travis
Michael Nolan wrote:
charles kline wrote:
Hi all,
I was having a conversation with a friend and talking about coding 
standards in the open source community (focusing on PHP). I seem to 
remember there being a document out there that sort of laid it out 
pretty well.

Anyone know where I might find a copy?
PEAR has a page in their documentation about coding standards:
http://pear.php.net/manual/en/standards.php
HTH,
Mike


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


Re: [PHP] Re: PHP Coding Standards

2004-06-01 Thread Don Read

On 31-May-2004 Travis Low wrote:
> I have to say I like everything about the PEAR coding standards
> except for the 
> K&R bracing style.  I much prefer:
> 
>if( foo )
>{
>   blah;
>}
> 

Icky.

So ... Vee-Eye or Eighty Megs and Constantly Swapping ?
 ;->



-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Re: PHP Coding Standards

2004-05-31 Thread Torsten Roehr
"Travis Low" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have to say I like everything about the PEAR coding standards except for
the
> K&R bracing style.  I much prefer:
>
>if( foo )
>{
>   blah;
>}
>
> to
>
>if( foo ) {
>   blah;
>}
>
>
> The latter form (K&R) conserves vertical space, but I find it a lot harder
to
> follow.  Harder to move blocks of code around too.  I'm sure plenty of
people
> disagree, so of course this is IMHO.

Hi Travis,

I totally agree with you. I'm coding this way:

if (foo)
   {
   // code
   }

elseif (bar)
   {
   // code
   }

else   {
   // code
   }

This makes it very easy to follow if/elseif/else structures in code. But the
PEAR style is the one usually used in Java as well so I guess it's the style
most people use.

Regards, Torsten

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



Re: [PHP] Re: PHP Coding Standards

2004-05-30 Thread Travis Low
I have to say I like everything about the PEAR coding standards except for the 
K&R bracing style.  I much prefer:

  if( foo )
  {
 blah;
  }
to
  if( foo ) {
 blah;
  }
The latter form (K&R) conserves vertical space, but I find it a lot harder to 
follow.  Harder to move blocks of code around too.  I'm sure plenty of people 
disagree, so of course this is IMHO.

cheers,
Travis
Michael Nolan wrote:
charles kline wrote:
Hi all,
I was having a conversation with a friend and talking about coding 
standards in the open source community (focusing on PHP). I seem to 
remember there being a document out there that sort of laid it out 
pretty well.

Anyone know where I might find a copy?
PEAR has a page in their documentation about coding standards:
http://pear.php.net/manual/en/standards.php
HTH,
Mike
--
Travis Low


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


[PHP] Re: PHP Coding Standards

2004-05-29 Thread Michael Nolan
charles kline wrote:
Hi all,
I was having a conversation with a friend and talking about coding 
standards in the open source community (focusing on PHP). I seem to 
remember there being a document out there that sort of laid it out 
pretty well.

Anyone know where I might find a copy?
PEAR has a page in their documentation about coding standards:
http://pear.php.net/manual/en/standards.php
HTH,
Mike
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Coding Style Guide Neded

2004-03-20 Thread Michal Migurski
>I am looking for "Coding Style Guide" for PHP?

PEAR has a good one, http://pear.php.net/manual/en/standards.php

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Coding Question

2003-07-20 Thread Justin French
Retrieving the results can be LIMITed to X results starting at row Y 
using mysql's LIMIT function.

Check the MySQL manual, but basically, this will limit the result to 10 
rows, starting with row 5.

SELECT name FROM customers LIMIT 5,10

By taking your values for the starting point and row count from 
variables from within the url, a posted form, session, cookie, etc, you 
can build dynamic queries, eg:

$sql = "SELECT name FROM customers LIMIT {$start},{$perPage}";

You can also build next and previous links by adding and subtracting 
the $perPage to the $start.

Make sense?

There's plenty of tutorials -- just do a google search.

Justin



On Sunday, July 20, 2003, at 05:55  PM, Aaron Axelsen wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Hello,

I am currently trying to think of how I want to solve an issue, and
im looking for some input.
I have a page that will query information from a database and then
properly display it on the screen.  Now the thing I want to set up is
the option to split the information over 2,3 or more pages.
For example, the user can set a value in the config file for how many
results to display for page, then on each page ill have something
that says results 25-50 here and what not.
The only thing that comes to my mind, is somehow setting up some
tests, and then altering the sql statement with the list option.  Is
this the best way to do this?  Does anyone else have any other
suggestions??
Thanks in advance for the assistance.

- ---
Aaron Axelsen
AIM: AAAK2
Email: [EMAIL PROTECTED]
Want reliable web hosting at affordable prices?
www.modevia.com
Web Dev/Design Community/Zine
www.developercube.com
-BEGIN PGP SIGNATURE-
Version: PGPfreeware 7.0.3 for non-commercial use 
iQA/AwUBPxpK1brnDjSLw9ADEQK0cQCgmFLBwO/IeqIYZIJUhR2j23Na5/sAniYv
nXehy/vKSs6AE8/yI3O9BixJ
=s7G2
-END PGP SIGNATURE-


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
---
[This E-mail scanned for viruses]



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


RE: [PHP] coding special characters in html

2002-11-17 Thread John W. Holmes
> I'm cooking tothether a tiny php html editor right now, (textarea kind
> of thing). To treat the text properly I need to encode characters like
> '"', '<', '>', and friends into something that doesn't confuse the
> browser.

Htmlentities() or htmlspecialchars()
 
> By the way, do you think encoding and decoding special characters like
> this may replace addslashes() and stripslashes()? The html pages will
> be stored in a MySQL database.

No. There is no HTML entity for the single quote, so those will remain
unchanged. If you use all double quotes for string delimiters in your
queries, then you could skip addslashes(). 
 
> Also, addslashes() will reduce the chance of bad stuff being passed to
> MySQL. But is there a function which stops client-side scripts in
> whatever is entered by the user?

No, not really. Using strip_tags() or htmlentities() is the best way to
go on user data. It will prevent the HTML or JS that's in the input from
being evaluated.

---John Holmes...



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




Re: [PHP] coding special characters in html

2002-11-17 Thread Marco Tabini
Sure, its htmlentities(), combined (possibly) with nb2br()

http://www.php.net/manual/en/function.htmlentities.php


Marco


On Sun, 2002-11-17 at 17:34, Børge Strand wrote:
> 
> Hi all,
> 
> I'm cooking tothether a tiny php html editor right now, (textarea kind
> of thing). To treat the text properly I need to encode characters like
> '"', '<', '>', and friends into something that doesn't confuse the
> browser. 
> 
> I got it to work with regexps, you can see a part of the decoder
> below. But I believe there must be some automatic stuff in php which
> does this. Anybody out there knowing about such a function?
> 
> $pattern = "/"/";
> $replacement = "\""; 
> $string = preg_replace($pattern ,$replacement, $string);
> 
> By the way, do you think encoding and decoding special characters like
> this may replace addslashes() and stripslashes()? The html pages will
> be stored in a MySQL database. 
> 
> Also, addslashes() will reduce the chance of bad stuff being passed to
> MySQL. But is there a function which stops client-side scripts in
> whatever is entered by the user?
> 
> 
> Regards, 
> 
> Børge
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



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




Re: [PHP] coding standards - control structures

2002-09-27 Thread Bill Farrell

LOL! Right!  I figure that _I'm_ the one who has to
look at my code the most.  May as well leave it where
I put it, how I put it.

Thanks for the chuckle!
B

--- Kevin Stone <[EMAIL PROTECTED]> wrote:
> I believe the standards are for coding PEAR modules
> so all code is presented
> in the same style.  It really has no influence on
> the language or community
> at large.  I say code the way you feel most
> comfortable with and damb to
> anyone who complains.  :)
> -Kevin
> 
> - Original Message -
> From: "ed" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, September 27, 2002 2:16 PM
> Subject: [PHP] coding standards - control structures
> 
> 
> > Hey all.  I've read the pear coding standards.
> > I assume that if php has any official coding
> standards
> >
> > then the pear standards would be them, correct?
> >
> > Anyways, the pear docs on coding standards show
> > examples of using controls structures like
> > the following:
> >
> > if ( !$var ) {
> > do_something();
> > }
> > else {
> > do_something_else();
> > }
> >
> > ---
> > But I really don't like putting the opening brace
> > on the same line as the control statement.
> >
> > I really prefer doing this:
> >
> > if ( $var )
> > {   do_something();
> > }
> >
> >
> > or
> >
> > if( $var )
> > {   do_something();
> > }
> > else
> > {   do_something_else();
> > }
> >
> > ---
> > Putting the opening brace one line down on the
> same
> > column that the control statement starts on seems
> to
> > give me a much better visual cue, especially when
> > dealing with nested control statements.
> >
> > Is doing it my preferred way acceptable?
> > Will my code be looked down on?
> >
> > thanks,
> > --ed
> >
> >
> > __
> > Do you Yahoo!?
> > New DSL Internet Access from SBC & Yahoo!
> > http://sbc.yahoo.com
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit:
> http://www.php.net/unsub.php
> >
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


=
Bill Farrell
Multivalue and *nix Support Specialist

Phone: (828) 667-2245
Fax:   (928) 563-5189
Web:   http://www.jwfarrell.com

__
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

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




Re: [PHP] coding standards - control structures

2002-09-27 Thread Kevin Stone

No I totaly agree.  That's exactly the way I code!  *ROTFLMAO*
-Kevin

- Original Message -
From: "Robert Cummings" <[EMAIL PROTECTED]>
To: "Kevin Stone" <[EMAIL PROTECTED]>
Cc: "ed" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, September 27, 2002 2:40 PM
Subject: Re: [PHP] coding standards - control structures


> Kevin Stone wrote:
> >
> > I believe the standards are for coding PEAR modules so all code is
presented
> > in the same style.  It really has no influence on the language or
community
> > at large.  I say code the way you feel most comfortable with and damb to
> > anyone who complains.  :)
> > -Kevin
>
> The best way for sure as I stand before God (if you believe in that) is as
> follows:
>
> if( $foo )
> {
> // Do something.
> }
> else
> {
> // Do something else.
> }
>
> Of course you're welcome to disagree ;)
>
> Cheers,
> Rob.
> --
> .-.
> | Robert Cummings |
> :-`.
> | Webdeployer - Chief PHP and Java Programmer  |
> :--:
> | Mail  : mailto:[EMAIL PROTECTED] |
> | Phone : (613) 731-4046 x.109 |
> :--:
> | Website : http://www.webmotion.com   |
> | Fax : (613) 260-9545 |
> `--'
>


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




Re: [PHP] coding standards - control structures

2002-09-27 Thread Robert Cummings

Kevin Stone wrote:
> 
> I believe the standards are for coding PEAR modules so all code is presented
> in the same style.  It really has no influence on the language or community
> at large.  I say code the way you feel most comfortable with and damb to
> anyone who complains.  :)
> -Kevin

The best way for sure as I stand before God (if you believe in that) is as
follows:

if( $foo )
{
// Do something.
}
else
{
// Do something else.
}

Of course you're welcome to disagree ;)

Cheers,
Rob.
-- 
.-.
| Robert Cummings |
:-`.
| Webdeployer - Chief PHP and Java Programmer  |
:--:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109 |
:--:
| Website : http://www.webmotion.com   |
| Fax : (613) 260-9545 |
`--'

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




Re: [PHP] coding standards - control structures

2002-09-27 Thread Kevin Stone

I believe the standards are for coding PEAR modules so all code is presented
in the same style.  It really has no influence on the language or community
at large.  I say code the way you feel most comfortable with and damb to
anyone who complains.  :)
-Kevin

- Original Message -
From: "ed" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 27, 2002 2:16 PM
Subject: [PHP] coding standards - control structures


> Hey all.  I've read the pear coding standards.
> I assume that if php has any official coding standards
>
> then the pear standards would be them, correct?
>
> Anyways, the pear docs on coding standards show
> examples of using controls structures like
> the following:
>
> if ( !$var ) {
> do_something();
> }
> else {
> do_something_else();
> }
>
> ---
> But I really don't like putting the opening brace
> on the same line as the control statement.
>
> I really prefer doing this:
>
> if ( $var )
> {   do_something();
> }
>
>
> or
>
> if( $var )
> {   do_something();
> }
> else
> {   do_something_else();
> }
>
> ---
> Putting the opening brace one line down on the same
> column that the control statement starts on seems to
> give me a much better visual cue, especially when
> dealing with nested control statements.
>
> Is doing it my preferred way acceptable?
> Will my code be looked down on?
>
> thanks,
> --ed
>
>
> __
> Do you Yahoo!?
> New DSL Internet Access from SBC & Yahoo!
> http://sbc.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


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




RE: [PHP] Coding methods (was RE: [PHP-DB] gzip image files)

2001-11-27 Thread Jon Haworth

I use the latter style, because otherwise my syntax highlighting doesn't
kick in.

$filename = "this $varname that";   # $filename is in blue, the
rest is in green

$filename = "this". $varname. "that";   # $filename and $varname are in
blue, the rest is in green

I've done it so much now it's burned into a finger macro, takes 0.01
seconds longer to type (approx)

Cheers
Jon



-Original Message-
From: Boget, Chris [mailto:[EMAIL PROTECTED]]
Sent: 27 November 2001 15:29
To: [EMAIL PROTECTED]; '[EMAIL PROTECTED]'
Subject: [PHP] Coding methods (was RE: [PHP-DB] gzip image files)


> $filename = 'kunden/'.$name.'.png';

I see this all the time and I'm curious:  what takes more
computing power (granted, either would be incredibly little
I'm sure, just curious which requires more work by PHP)?

this:

$filename = "this " . $varname . " that";

or this:

$filename = "this $varname that";

I would think the latter example but am not sure.

Another question, but this is more about personal style:

I almost always use the latter method in my coding practices.  It 
looks cleaner and, IMO, is easier to follow especially when there 
are a number of variables involved.  For those that use the former 
method, why do you?  I'm not trying to be judgemental, just curious
why people do what they do.  In asking, I may actually learn some-
thing. :p

Chris



**
'The information included in this Email is of a confidential nature and is 
intended only for the addressee. If you are not the intended addressee, 
any disclosure, copying or distribution by you is prohibited and may be 
unlawful. Disclosure to any party other than the addressee, whether 
inadvertent or otherwise is not intended to waive privilege or confidentiality'

**

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] coding practices

2001-09-15 Thread Julio Nobrega Trabalhando

  I am the type of guy that sits and code. But now I am working on a company
where we sell systems to large financial entities. So, I have now to make
'prettier' stuff for high executives understand.

--

Julio Nobrega

A hora está chegando:
http://toca.sourceforge.net
"Ninety-Nine Ways To Die" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I generally was just diving in immediately... because I was using it for
smaller projects less than 1k lines of code... but now that I am building
everything in PHP and becoming more proficient, and writing programs with 5k
+ lines of code, I am discovering a need to write at least a basic plan
ahead of time, jotting the code as I go if I get an idea, but planning
slightly ahead of time... that is. ONLY if it's a big project... I am
working on one now that when finished will most likely be 15-30k  lines of
code by the time I am done, big project... I did just delve in... now I am
discovering that may not have been the smartest thing.. I have a piece done,
but will wind up trying to integrate all the other pieces around that,
instead of thinking in the grand scheme from the beginning
>
>
> --
>
> On Sat, 15 Sep 2001 10:03:29
>  Scott Parks wrote:
> >Hello-
> >
> >This may sound like an odd question, but I am curious about everyone's
coding
> >techniques when it comes to web projects.  Do you still down and plan
> >everything
> >out, database connectivity, tables, etc or do you just dive in and do
> >it?  I am more
> >of a guy who just drives in and goes to work.  Do you use spread sheets,
a
> >project
> >program, etc?  Or just screen captures to the clients?
> >
> >Thanks,
> >
> >-Scott
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> Make a difference, help support the relief efforts in the U.S.
> http://clubs.lycos.com/live/events/september11.asp



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] coding practices

2001-09-15 Thread Ninety-Nine Ways To Die

I generally was just diving in immediately... because I was using it for smaller 
projects less than 1k lines of code... but now that I am building everything in PHP 
and becoming more proficient, and writing programs with 5k + lines of code, I am 
discovering a need to write at least a basic plan ahead of time, jotting the code as I 
go if I get an idea, but planning slightly ahead of time... that is. ONLY if it's a 
big project... I am working on one now that when finished will most likely be 15-30k  
lines of code by the time I am done, big project... I did just delve in... now I am 
discovering that may not have been the smartest thing.. I have a piece done, but will 
wind up trying to integrate all the other pieces around that, instead of thinking in 
the grand scheme from the beginning


--

On Sat, 15 Sep 2001 10:03:29  
 Scott Parks wrote:
>Hello-
>
>This may sound like an odd question, but I am curious about everyone's coding
>techniques when it comes to web projects.  Do you still down and plan 
>everything
>out, database connectivity, tables, etc or do you just dive in and do 
>it?  I am more
>of a guy who just drives in and goes to work.  Do you use spread sheets, a 
>project
>program, etc?  Or just screen captures to the clients?
>
>Thanks,
>
>-Scott
>
>
>-- 
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


Make a difference, help support the relief efforts in the U.S.
http://clubs.lycos.com/live/events/september11.asp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] ->>coding help

2001-06-25 Thread Richard Lynch

Oh yeah:  I forgot:

*AFTER* the loop, you need to add another spurious .

You'll have an empty row with no TD's in it, and the browser won't even put
in a blank line or anything.

Just spew out an extra  at the end and call it done.

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
- Original Message -
From: "McShen" <[EMAIL PROTECTED]>
Newsgroups: php.general
Sent: Saturday, June 23, 2001 10:13 PM
Subject: [PHP] ->>coding help


> Hi
>
> I have a script which queries mySQL and outputs 32 links at once. Here is
my
> scipt
> 
> 
> $connection = mysql_connect("***","","");
> if ($connection==false)
>{
> echo mysql_errno().":".mysql_error()."";
> exit;
>}
>
> $end = $list + 16;
>
> $query = "SELECT * FROM refer ORDER BY hits desc LIMIT $list, $end";
> $result = mysql_db_query ("celebzone", $query);
>
> $num = mysql_num_rows($result);
>
> $j=0;
> $i=0;
> echo "\n";
> echo "\n";
> while ($j!=$num)
> {
> @$r = mysql_fetch_array($result);
> @$id = $r[id];
> @$title = $r[title];
>
>   echo "\n";
>   echo "$title";
>   echo "\n";
> // new row in table every other link
> $i++;
>  if (($i % 2) < 1)
>   {
>   echo "\n\n";
>   }
>
> $j++;
> }
> echo "";
>
> echo "\n";
>
>
> ?>
> ---
> And here is the link to see it in action
> http://www.celebritieszones.com/ln.php?list=0
>
> If you check my HTML source, at the end, right before , you will
see
> an extra . I know the cause of this. It's because of this
> ---
> "
> $i++;
>  if (($i % 2) < 1)
>   {
>   echo "\n\n";
>   }
> "
> -
>
> I don't know how to fix the problem. Please help me re-write the script a
> bit so that it doesn't add the extra .
>
> Thanks in advance.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] ->>coding help

2001-06-24 Thread Hugh Bothwell

""McShen"" <[EMAIL PROTECTED]> wrote in message
9h3lrv$dn$[EMAIL PROTECTED]">news:9h3lrv$dn$[EMAIL PROTECTED]...
> Hi
>
> I have a script which queries mySQL and outputs 32 links at once.

How 'bout this?

===
define("PER_ROW", 2);

$row = Array();
$in_row = 0;

// accepts nothing, returns nothing
function ClearRow() {
global $in_row;
$in_row = 0;
}

// accepts text string, returns true if row is full
function AddToRow($val) {
global $row, $in_row;
$row[$in_row++] = $val;
return($in_row >= PER_ROW);
}

// accepts nothing, returns row string
function MakeRow() {
global $row, $in_row;

$str = "";
for ($i = 0; $i < PER_ROW; $i++)
$str .= "\n\t\t".($i < $in_row ? $row[$i] : "")."";

ClearRow();
return "\n\t$str\n\t";
}

// accepts database result handle, returns table string
function MakeTable($result) {
$str = "";
while($row = mysql_fetch_array($result))
if (AddToRow($row["title"]))
$str .= MakeRow();

return "\n$str\n";
}

$query = "SELECT * FROM refer ORDER BY hits, desc LIMIT $list, $end";
$result = mysql_db_query ("celebzone", $query);

ClearTable();
echo MakeTable($result);



This separates things out so you can see that each pair of tags matches; it
also doesn't leave incomplete rows in your table (ie if there is an odd
number of links returned) and makes it easy to change the number of columns
and rows.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] ->>coding help

2001-06-24 Thread Jason Lotito

Oops..was overwriting the $result variable...heheits fixed.

\n";

for ($j = 0; $j < $num; $j++)
{
echo '\n';
for ($i = 0; $i <= 1; $i++)
{
@$data = mysql_fetch_array($result);
@$id = $data[id];
@$title = $data[title];
  
echo "\n";
echo "$title";
echo "\n";
}
echo "\n";
}

echo "";
echo "\n";


?>


Jason Lotito
www.NewbieNetwork.net
PHP Newsletter: http://www.newbienetwork.net/ciao.php
PHP, MySQL, PostgreSQL Tutorials, Code Snippets, and so much more

> -Original Message-
> From: McShen [mailto:[EMAIL PROTECTED]] 
> Sent: Sunday, June 24, 2001 10:45 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] ->>coding help
> 
> 
> Jason, your scripts works prefectly in creating a table. But, 
> It only ouputs the first query from the databse. Others are 
> not shown. ""Jason Lotito"" <[EMAIL PROTECTED]> wrote in 
> message 000f01c0fc67$abfe3a90$72003bd0@genric">news:000f01c0fc67$abfe3a90$72003bd0@genric...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] ->>coding help

2001-06-24 Thread McShen

Jason, your scripts works prefectly in creating a table. But, It only ouputs
the first query from the databse. Others are not shown.
""Jason Lotito"" <[EMAIL PROTECTED]> wrote in message
000f01c0fc67$abfe3a90$72003bd0@genric">news:000f01c0fc67$abfe3a90$72003bd0@genric...
> This should work...
>
> 
> $connection = mysql_connect("***","","");
> if ($connection==false)
>{
> echo mysql_errno().":".mysql_error()."";
> exit;
>}
>
> $end = $list + 16;
>
> $query = "SELECT * FROM refer ORDER BY hits desc LIMIT $list, $end";
> $result = mysql_db_query ("celebzone", $query);
>
> $num = mysql_num_rows($result);
>
> $j=0;
> $i=0;
> echo "\n";
>
> for ($j = 0; $j < $num; $j++)
> {
> echo '\n';
> for ($i = 0; $i <= 1; $i++)
> {
> @$result = mysql_fetch_array($result);
> @$id = $result[id];
> @$title = $result[title];
>
> echo "\n";
> echo "$title";
> echo "\n";
> }
> echo "\n";
> }
>
> echo "";
> echo "\n";
>
>
> ?>
>
> Jason Lotito
> www.NewbieNetwork.net
> PHP Newsletter: http://www.newbienetwork.net/ciao.php
> PHP, MySQL, PostgreSQL Tutorials, Code Snippets, and so much more
>
>
> > -Original Message-
> > From: McShen [mailto:[EMAIL PROTECTED]]
> > Sent: Saturday, June 23, 2001 11:22 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] ->>coding help
> >
> >
> > Hi
> >
> > I have a script which queries mySQL and outputs 32 links at
> > once. Here is my scipt
> > 
> >  >
> > $connection = mysql_connect("***","","");
> > if ($connection==false)
> >{
> > echo mysql_errno().":".mysql_error()."";
> > exit;
> >}
> >
> > $end = $list + 16;
> >
> > $query = "SELECT * FROM refer ORDER BY hits desc LIMIT $list,
> > $end"; $result = mysql_db_query ("celebzone", $query);
> >
> > $num = mysql_num_rows($result);
> >
> > $j=0;
> > $i=0;
> > echo "\n";
> > echo "\n";
> > while ($j!=$num)
> > {
> > @$r = mysql_fetch_array($result);
> > @$id = $r[id];
> > @$title = $r[title];
> >
> >   echo "\n";
> >   echo "$title";
> >   echo "\n";
> > // new row in table every other link
> > $i++;
> >  if (($i % 2) < 1)
> >   {
> >   echo "\n\n";
> >   }
> >
> > $j++;
> > }
> > echo "";
> >
> > echo "\n";
> >
> >
> > ?>
> > ---
> > And here is the link to see it in action
> > http://www.celebritieszones.com/ln.php?list=0
> >
> > If you check
> > my HTML source, at the end, right before , you will
> > see an extra . I know the cause of this. It's because of this
> > ---
> > "
> > $i++;
> >  if (($i % 2) < 1)
> >   {
> >   echo "\n\n";
> >   }
> > "
> > -
> >
> > I don't know how to fix the problem. Please help me re-write
> > the script a bit so that it doesn't add the extra .
> >
> > Thanks in advance.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] ->>coding help

2001-06-23 Thread Jason Lotito

This should work...

\n";

for ($j = 0; $j < $num; $j++)
{
echo '\n';
for ($i = 0; $i <= 1; $i++)
{
@$result = mysql_fetch_array($result);
@$id = $result[id];
@$title = $result[title];
  
echo "\n";
echo "$title";
echo "\n";
}
echo "\n";
}

echo "";
echo "\n";


?>

Jason Lotito
www.NewbieNetwork.net
PHP Newsletter: http://www.newbienetwork.net/ciao.php
PHP, MySQL, PostgreSQL Tutorials, Code Snippets, and so much more


> -Original Message-
> From: McShen [mailto:[EMAIL PROTECTED]] 
> Sent: Saturday, June 23, 2001 11:22 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] ->>coding help
> 
> 
> Hi
> 
> I have a script which queries mySQL and outputs 32 links at 
> once. Here is my scipt
> 
>  
> $connection = mysql_connect("***","","");
> if ($connection==false)
>{
> echo mysql_errno().":".mysql_error()."";
> exit;
>}
> 
> $end = $list + 16;
> 
> $query = "SELECT * FROM refer ORDER BY hits desc LIMIT $list, 
> $end"; $result = mysql_db_query ("celebzone", $query);
> 
> $num = mysql_num_rows($result);
> 
> $j=0;
> $i=0;
> echo "\n";
> echo "\n";
> while ($j!=$num)
> {
> @$r = mysql_fetch_array($result);
> @$id = $r[id];
> @$title = $r[title];
> 
>   echo "\n";
>   echo "$title";
>   echo "\n";
> // new row in table every other link
> $i++;
>  if (($i % 2) < 1)
>   {
>   echo "\n\n";
>   }
> 
> $j++;
> }
> echo "";
> 
> echo "\n";
> 
> 
> ?>
> ---
> And here is the link to see it in action 
> http://www.celebritieszones.com/ln.php?list=0
> 
> If you check 
> my HTML source, at the end, right before , you will 
> see an extra . I know the cause of this. It's because of this
> ---
> "
> $i++;
>  if (($i % 2) < 1)
>   {
>   echo "\n\n";
>   }
> "
> -
> 
> I don't know how to fix the problem. Please help me re-write 
> the script a bit so that it doesn't add the extra .
> 
> Thanks in advance.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] ->>coding help

2001-06-23 Thread Carmen & Gene

McShen wrote:

> Hi
>
> I have a script which queries mySQL and outputs 32 links at once. Here is my
> scipt
> 
> 
> $connection = mysql_connect("***","","");
> if ($connection==false)
>{
> echo mysql_errno().":".mysql_error()."";
> exit;
>}
>
> $end = $list + 16;
>
> $query = "SELECT * FROM refer ORDER BY hits desc LIMIT $list, $end";
> $result = mysql_db_query ("celebzone", $query);
>
> $num = mysql_num_rows($result);
>
> $j=0;
> $i=0;
> echo "\n";
> echo "\n";
> while ($j!=$num)
> {
> @$r = mysql_fetch_array($result);
> @$id = $r[id];
> @$title = $r[title];
>
>   echo "\n";
>   echo "$title";
>   echo "\n";
> // new row in table every other link
> $i++;
>  if (($i % 2) < 1)
>   {
>   echo "\n\n";
>   }
>
> $j++;
> }
> echo "";
>
> echo "\n";
>
> ?>
> ---
> And here is the link to see it in action
> http://www.celebritieszones.com/ln.php?list=0
>
> If you check my HTML source, at the end, right before , you will see
> an extra . I know the cause of this. It's because of this
> ---
> "
> $i++;
>  if (($i % 2) < 1)
>   {
>   echo "\n\n";
>   }
> "
> -
>
> I don't know how to fix the problem. Please help me re-write the script a
> bit so that it doesn't add the extra .
>
> Thanks in advance.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

Try adding a ; after the \n


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] coding for 'no match found'

2001-05-15 Thread James, Yz

Or, try count() in the sql statement..



I think that's faster than:



Can't be sure where I read it, but still :)

Ack! 1.20am.  Bedtime.

James.

""Johnson, Kirk"" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> See http://www.php.net/manual/en/function.mysql-num-rows.php
>
> Kirk
>
> > -Original Message-
> > From: midget2000x [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, May 15, 2001 3:00 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] coding for 'no match found'
> >
> >
> > This is a simple yet fundamental programming question I am
> > hoping somebody will
> > have the patience to explain...
> >
> > I have a mysql database with the "email" field as the key.
> > Before inserting an
> > new record to it I want to check if there is already a record
> > with that e-mail.
> >  This I can do fine.  But this script needs to also handle
> > delete requests,
> > which I can also do fine, but I need to code for the instance
> > that there is a
> > delete request for an e-mail record that does not exist.  How
> > can I figure out
> > if after my 'while' loop is finished checking the database it
> > has not found a
> > match (so i can inform the requester as such)?
> >
> > Here's the code I have so far...
> >
> > $email_check_query = "SELECT email FROM
> > $tablename WHERE email = '$email'";
> > $email_check_result = mysql_query($email_check_query);
> > while($email_query_data =
> > mysql_fetch_array($email_check_result)) {
> > $db_email = $email_query_data["email"];
> > //if match, it's an update or delete
> >  if ($email==$db_email) {
> > if ($op=="delete") {
> > $action="del";
> > echo "delete
> > request";
> > }
> > else {
> > $action = "upd";
> > echo "update
> > request";
> > }
> > }
> > } //end while loop
> >
> >  ---
> > providing the finest in midget technology
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail:
> > [EMAIL PROTECTED]
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] coding for 'no match found'

2001-05-15 Thread Johnson, Kirk

See http://www.php.net/manual/en/function.mysql-num-rows.php

Kirk

> -Original Message-
> From: midget2000x [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 15, 2001 3:00 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] coding for 'no match found'
> 
> 
> This is a simple yet fundamental programming question I am 
> hoping somebody will
> have the patience to explain...
> 
> I have a mysql database with the "email" field as the key.  
> Before inserting an
> new record to it I want to check if there is already a record 
> with that e-mail.
>  This I can do fine.  But this script needs to also handle 
> delete requests,
> which I can also do fine, but I need to code for the instance 
> that there is a
> delete request for an e-mail record that does not exist.  How 
> can I figure out
> if after my 'while' loop is finished checking the database it 
> has not found a
> match (so i can inform the requester as such)?
> 
> Here's the code I have so far...
> 
>   $email_check_query = "SELECT email FROM 
> $tablename WHERE email = '$email'";
>   $email_check_result = mysql_query($email_check_query);
>   while($email_query_data = 
> mysql_fetch_array($email_check_result)) { 
>   $db_email = $email_query_data["email"];
>   //if match, it's an update or delete
>   if ($email==$db_email) {
>   if ($op=="delete") {
>   $action="del";
>   echo "delete 
> request";
>   } 
>   else {
>   $action = "upd";
>   echo "update 
> request";
>   }
>   } 
>   } //end while loop
> 
>  ---
> providing the finest in midget technology
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: 
> [EMAIL PROTECTED]
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]