Re: [PHP] new lines in textareas?

2008-03-30 Thread jeffry s
On Mon, Mar 31, 2008 at 12:40 AM, Paul Scott <[EMAIL PROTECTED]> wrote:

>
> On Sun, 2008-03-30 at 12:29 -0400, tedd wrote:
> > At 9:26 PM -0700 3/29/08, Mary Anderson wrote:
> > >Hi all,
> > >I have a php script which produces text which is to be displayed
> > >in a textarea.  I have the wrap for the text area set to 'hard'.  I
> > >need to have newlines inserted in the text.
> > > "\n" and "" don't work.  They just get quoted literally in
> > >the text.  I suspect I need to use htmlspecialchars , but don't know
> > >what special character to feed it.
> > >
>
> Only getting to this now, but doesn't nl2br() do what you 
> want?


well, i don't think nl2br() is  a solution here because nl2br() only replace
the '\n' with
 html tags which is displayed inside the textarea. the textarea will
display a new
line with '\n'..

$str = "hello\nworld";
will display

hello
world

in text area. but

$st = 'hello\nworld'.

will be display as

hello\nworld

just like what TG trying to say..


Re: [PHP] new lines in textareas?

2008-03-30 Thread jeffry s
On Sun, Mar 30, 2008 at 2:07 PM, TG <[EMAIL PROTECTED]> wrote:

>
> Is \n included literally because you're using single quotes for the
> variable?
>
> $textdata = 'This is a test\nThis is the second line';
>
> vs...
>
> $textarea = "This is a test\nThis is the second line";
>
> I would guess a lot of the pages you find are talking about what to do
> with
> the text after submitting through the textarea, not re-displaying with
> proper breaks when loading a page containing a text area that should have
> data.
>
> -TG
>
> - Original Message -
> From: Mary Anderson <[EMAIL PROTECTED]>
> To: php-general@lists.php.net
> Date: Sat, 29 Mar 2008 21:26:24 -0700
> Subject: [PHP] new lines in textareas?
>
> > Hi all,
> > I have a php script which produces text which is to be displayed in
> > a textarea.  I have the wrap for the text area set to 'hard'.  I need to
> > have newlines inserted in the text.
> >  "\n" and "" don't work.  They just get quoted literally in the
> > text.  I suspect I need to use htmlspecialchars , but don't know what
> > special character to feed it.
> >
> >  Apologies if this should go to an HTML forum.  I checked several
> > archives and did not find anything useful.  (They tended to tell me to
> > put in \n or !)
> >
> >  Thanks
> >
> > Mary Anderson
>

my client ask me about this problem 2 weeks ago. he want the text to
automatically
go to new line after user type until the end of the line. The only possible
solutions so
far is using wrap='hard' or wrap='soft'
eg: 
but wrap only work on IE & Netscape browser. Not working in firefox.
i guess i want to use javascript to do the text formatting. trigger the
javascript event
every time the user using the onchange event (i never try)..
i is quite complicated & i dont have much time working on it.
so i decided to tell him, it cannot be done :)


Re: [PHP] Re: optimilize web page loading

2008-03-27 Thread jeffry s
On Thu, Mar 27, 2008 at 7:28 AM, Al <[EMAIL PROTECTED]> wrote:

> Depends on the server and it's load.  I've strung together some rather
> large html strings and they
> aways take far less time than the transient time on the internet. I used
> to use OB extensively until
> one day I took the time to measure the difference. I don't recall the
> numbers; but, I do recall it
> was not worth the slight extra trouble to use OB.
>
> Now, I simple assemble by html strings with $report .= "foo"; And then
> echo $report at the end. It
> also makes the code very easy to read and follow.
>
> Andrew Ballard wrote:
> > On Wed, Mar 26, 2008 at 1:18 PM, Al <[EMAIL PROTECTED]> wrote:
> >> You are really asking an HTML question, if you think about it.
> >>
> >>  At the PHP level, either use output buffering or assemble all your
> html string as a variable and
> >>  then echo it.  The goal is to compress the string into the minimum
> number of packets.
> >
> > Yes, but do so smartly. Excessive string concatenation can slow things
> > down as well. On most pages you probably won't notice much difference,
> > but I have seen instances where the difference was painfully obvious.
> >
> > Andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

I am  also doing the same way. assemble the string and echo it at the end


Re: [PHP] Re: algorithm of pages beaking

2008-03-19 Thread jeffry s
On Thu, Mar 20, 2008 at 7:35 AM, George J <[EMAIL PROTECTED]>
wrote:

> Hi,
>
> I'm trying to resolve an issue with a pagination routine. Sounds like
> we're
> working on a similar routine. I have a query returning products from a
> database and then display the results in a defined number of products per
> page.
>
> Checkout - 'Newbie question, Which way is best?' in this newsgroup.
>
> George
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> i  have spent some time to figure it out last time. i did create a simple
function to do it
total - is the total record. can be output of SELECT COUNT(*) FROM table
offset - is the current offset.

//display pages
function pages($total, $offset, $perpage)
   {
   if($total == 0) return;

   $total_pages = floor($total / $perpage);
   $current_page = floor($offset / $perpage);

   $pg = '';
   for($i = 0; $i <= $total_pages; $i++)
   {
   $pg .= "".($i + 1)."";
}

return $pg;
}

i am afraid this one look too simple. but you can see how the basis work.
this one simply print 1, 2, 3 etc..


Re: [PHP] Re: selling gpl software?

2008-03-19 Thread jeffry s
On Thu, Mar 20, 2008 at 1:19 AM, Daniel Brown <[EMAIL PROTECTED]> wrote:

> On Wed, Mar 19, 2008 at 1:13 PM, jeffry s <[EMAIL PROTECTED]> wrote:
> >
> > forgive me for my stupidness. i am quite confuse with law thing
> > and gpl, gplv2 and gplv3 or gnu proven hard for me to understand.
> > anyone can point me a comparison between all this?
>
> GPL is the (GNU) General Public License.
>
>GPLv2/GPLv3 are the second/third versions, containing
> modifications, ratifications, and clarifications.  There may be some
> other ifications in there that I'm forgetting as well.
>
>GNU is a recursive acronym (as PHP now is for PHP Hypertext
> Preprocessor).  It stands for GNU's Not Unix, and is an operating
> system.  It's often confused with the organization from which it
> receives primary focus (and shares the founder: Richard Stallman),
> known as the FSF - the Free Software Foundation.
>
> > a simple explanation easy for baby to digest.. :)
>
> Now go get burped and have Mommy change your diaper.  ;-P
>
> --
> 
> Forensic Services, Senior Unix Engineer
> 1+ (570-) 362-0283
>

what is the difference between gpl, gplv2 and gplv3 ?

actually.. baby is a name of a monkey. sure it doesnt need a diaper... :p


Re: [PHP] Re: selling gpl software?

2008-03-19 Thread jeffry s
On Thu, Mar 20, 2008 at 1:02 AM, Daniel Brown <[EMAIL PROTECTED]> wrote:

> On Wed, Mar 19, 2008 at 12:55 PM, Colin Guthrie <[EMAIL PROTECTED]>
> wrote:
> >
> >  IANAL so apologies if I've gotten anything wrong here.
>
> Yes, we know you're anal.  ;-P
>
>In all seriousness, looks like you got it all right.  +1 for you
> (and a gold star)!
>
> --
> 
> Forensic Services, Senior Unix Engineer
> 1+ (570-) 362-0283
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

well, i am quite surprised with you all feedback.
then it is ok to remove all the link as part of modification then as long
as the source code available to the client (it is php script anyway)

forgive me for my stupidness. i am quite confuse with law thing
and gpl, gplv2 and gplv3 or gnu proven hard for me to understand.
anyone can point me a comparison between all this?

a simple explanation easy for baby to digest.. :)


[PHP] selling gpl software?

2008-03-19 Thread jeffry s
i know it is forbidden to sell open source software.

let say i have costumer want me to modified an open source php script.
i have the right to charge him the service to modified  the software.

but this costumer ask me to do one thing against the gpl software.
he want me to remove all the link and powered by link (anything visible to
the end user)

what should i do to satisfy my costumer without making myself against
the spirit of open source community?


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

2008-03-19 Thread jeffry s
On Wed, Mar 19, 2008 at 10:57 PM, Andrew Ballard <[EMAIL PROTECTED]> wrote:

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


Re: [PHP] General use of rewrite / redirect

2008-03-18 Thread jeffry s
On Tue, Mar 18, 2008 at 9:22 PM, Aschwin Wesselius <[EMAIL PROTECTED]>
wrote:

> Per Jessen wrote:
> > Yes, that's a very typical setup.  When the form is processed, you send
> > a 303 redirect to the "Thank you" page.  That way, if the user hits
> > the "back" arrow, he's taken back to the form URL, not the post URL.
> > (which would then warn him about re-submitting etc.)
> >
> Ok, fine. But why do a real redirect when a header with 303 could be
> sufficient? If you model good enough, there would not be a need for
> header(location) redirects. Or am I wrong?
> >> What is your opinion about (ab)using rewrites / redirects? Do you use
> >> it quick and dirty, or is it some elegant way of controlling flow?
> >>
> > I think there are plenty of perfectly valid reasons for using a
> > redirect, whether dynamically from php or via an apache config.
> > And undoubtedly there equally many poor reason for using redirect and/or
> > rewrite.  (they're very different things, by the way).
> I know they're different things. I only want to start a discussion so
> people do understand other techniques instead of just using whatever
> 'works' as a solution to their problem with flow. Redirects do solve
> some issues, but they should be avoided whenever possible.
>
> header(location) mechanisms do come with a very huge disadvantage if you
> don't use them with caution. Requests are reinitialised, libraries
> loaded (again), DB connections setup/checked again, session lookups are
> being done, log write for another request etc. That's quite an impact
> for just not knowing what to do with flow. So, if you know what you want
> to handle (control) and what you want the user to see (view), one should
> be able to model it without the use of redirects unless it really is
> needed.
>
> Or is it OK, to redirect and 'simplify' the flow?
> --
>
> Aschwin Wesselius
>
> /'What you would like to be done to you, do that to the other'/
>
>
i am sorry.. but i don't get what u really want to say. honestly, i don't
see any other way
(better alternative) to avoid people to simply refresh the browser to submit
the form
many time.

>Requests are reinitialised, libraries
>loaded (again), DB connections setup/checked again, session lookups are
>being done, log write for another request etc.

i don't see anything wrong with this since that is the way it is. whether
you redirect or
not, the script will do DB connection, session lookup anyway. i simply
called exit;
to stop execution after the header redirect..

sorry.. if i misunderstand your point. but that is just my opinion..


Re: [PHP] save image in database vs folder

2008-03-11 Thread jeffry s
thanks Richard ..
sorry dev.. i don't know this subject is quite sensitive here :(

> I think I'm gonna dive into the archives then. To see for myself what
> left such a scars upon that subject.

i guess, i have to prepare my oxygen tank to dive into the archives.
i am quite curious to find out what  happen about this..


On Tue, Mar 11, 2008 at 7:18 PM, Richard Heyes <[EMAIL PROTECTED]> wrote:

> > some friend of mine ague about this matter, this morning. they say,
> saving
> > image in
> > database is more professional. I am not really agree with that,since i
> am
> > just a novice programmer.
>
> Well, bearing in mind I only have experience of MySQL, the general
> consensus is to save it to a file on you hard drive and store the file
> name in the database. If for whatever reason you can't or don't want to
> do that, then at least store it in a separate table that only gets
> touched when the image is requested.
>
> --
> Richard Heyes
> Employ me:
> http://www.phpguru.org/cv
>


[PHP] save image in database vs folder

2008-03-11 Thread jeffry s
some friend of mine ague about this matter, this morning. they say, saving
image in
database is more professional. I am not really agree with that,since i am
just a novice programmer. i am asking
senior php programmer what you opinion about this?

which one is better. save in database or in folder?


Re: [PHP] Sending SMS via PHP

2008-02-26 Thread jeffry s
i wonder how kannel.org work?
do i need the specific device. i need the sim card form the phone company
provider right?

On Thu, Feb 21, 2008 at 4:18 PM, Per Jessen <[EMAIL PROTECTED]> wrote:

> Paul Scott wrote:
>
> > What you need to do is ask yourself whether you are going to do high
> > volume SMS or not, and look at when do the commercial providers become
> > more economical? What a lot of people do, is sign up for an account
> > and end up sending only 50 or so SMS a month, which is silly, when for
> > the same price as a month or two's subscription, you could buy your
> > own GSM modem and a prepaid SIM card and do it for half the price
> > yourself.
>
> Or use sms_client and only pay per individual SMS.  No subscription
> needed.
>
>
> /Per Jessen, Zürich
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Re: insert text with no specific format into database table

2008-02-26 Thread jeffry s
thank you all.
it is a great help..

On Tue, Feb 26, 2008 at 1:15 AM, Shawn McKenzie <[EMAIL PROTECTED]>
wrote:

> Shawn McKenzie wrote:
> > jeffry s wrote:
> >> i have text file and a table created with
> >>
> >> create table word(
> >> id int not null auto_increment primary key,
> >> word varchar(50),
> >> definition text
> >> )
> >>
> >> the text contain list of words but not really in specific format
> >>
> >> word, some text definition
> >> word, some text definition, some text definition, etc
> >>
> >>
> >> i want to read the file line by line,
> >> take the first word before comma (,) and insert into the word column in
> the
> >> database
> >> whatever after follow the first comma(,) will be inserted into the
> >> definition column in the word table database.
> >>
> >> i am not sure how to read the file line by line in php.
> >> and how to separate the line of  text into two. divided by the 1st
> comma (,)
> >> ..
> >> my idea is using the explode(',' $text) function. but this one will
> separate
> >> everything between a comma(,) into an array.
> >> i wan't to know if there is another better way to do it..
> >>
> >>
> >> any idea?
> >> thank you!
> >>
> >
> > Read about the file() function and also read about the explode()
> > function's limit parameter.
> >
> > -Shawn
> >
> >
> > if(($lines = file("file.txt"))) {
> > foreach($lines as $line) {
> > list($word, $definition) = explode($line, ',', 1);
> > //insert word and definition SQL stuff here
> > }
> > }
>
> Maybe I should read up on the limit parameter also :-0
>
> list($word, $definition) = explode($line, ',', 2);
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] insert text with no specific format into database table

2008-02-25 Thread jeffry s
i have text file and a table created with

create table word(
id int not null auto_increment primary key,
word varchar(50),
definition text
)

the text contain list of words but not really in specific format

word, some text definition
word, some text definition, some text definition, etc


i want to read the file line by line,
take the first word before comma (,) and insert into the word column in the
database
whatever after follow the first comma(,) will be inserted into the
definition column in the word table database.

i am not sure how to read the file line by line in php.
and how to separate the line of  text into two. divided by the 1st comma (,)
..
my idea is using the explode(',' $text) function. but this one will separate
everything between a comma(,) into an array.
i wan't to know if there is another better way to do it..


any idea?
thank you!


Re: [PHP] how to make multiple website on one host

2008-02-03 Thread jeffry s
can you tell me more about mod_rewrite?


On Feb 4, 2008 10:52 AM, Richard Lynch <[EMAIL PROTECTED]> wrote:

>
>
> On Sun, February 3, 2008 1:20 am, jeffry s wrote:
> > i am wondering whether this can be done. i know it can.
> > is it possible to make one website with the ability to host multiple
> > website.
> > it is something like website generator. eg: www.shopify.org
> >
> > let say for example i have a website www.example.org.
> > i can point a domain name (www.example1.org) to the server where
> > www.example.org hosted,
> > and when user visit www.example1.org, it execute the same scripts as
> > www.example.org with
> > with different themes and website configuration.
>
> switch($_SERVER['HTTP_HOST'])){
>  case 'example1.org': load('example1'); break;
>  case 'example.org': load('example'); break;
> }
>
> You should also consider playing games with Apache mod_rewrite
>
> --
> 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/from/lynch
> Yeah, I get a buck. So?
>
>


Re: [PHP] how to make multiple website on one host

2008-02-03 Thread jeffry s
On Feb 4, 2008 3:33 AM, Feris Thia C. <[EMAIL PROTECTED]> wrote:

> Yes you can.
>
> Just mirror the additional domains and in your PHP app check the
> $_SERVER["HTTP_HOST"] variable.
>
> Hope this helps !
>
> Regards,
>
> Feris
> http://top-10.bigspacehosting.com
>
>
> On Feb 3, 2008 2:20 PM, jeffry s <[EMAIL PROTECTED]> wrote:
>
> > i am wondering whether this can be done. i know it can.
> > is it possible to make one website with the ability to host multiple
> > website.
> > it is something like website generator. eg: www.shopify.org
> >
> > let say for example i have a website www.example.org.
> > i can point a domain name (www.example1.org) to the server where
> > www.example.org hosted,
> > and when user visit www.example1.org, it execute the same scripts as
> > www.example.org with
> > with different themes and website configuration.
> >
> > anyone have the idea?
> >
> > thanks
> >
>

great help, thanks you all.. =)


[PHP] how to make multiple website on one host

2008-02-02 Thread jeffry s
i am wondering whether this can be done. i know it can.
is it possible to make one website with the ability to host multiple
website.
it is something like website generator. eg: www.shopify.org

let say for example i have a website www.example.org.
i can point a domain name (www.example1.org) to the server where
www.example.org hosted,
and when user visit www.example1.org, it execute the same scripts as
www.example.org with
with different themes and website configuration.

anyone have the idea?

thanks


[PHP] how to display photos of the day?

2008-01-29 Thread jeffry s
sorry if this question sound stupid.
i need a good, simple and efficient function to display lets say photo of
the day.

i have a mysql table contain data about 1000 rows. i want to display any of
the photos randomly
and it is fixed for one day.

anyone know how to write the function that return a fixed table id for the
day?


[PHP] generate letter combination..

2007-06-26 Thread jeffry s

i made a mistake when i say i can solve this problem to a friend.
finally i realize it is not as simple as i appear to be.

what he ask me to do is write a simple script that, given a word.. the
script will generate a list of words combinaton
from the each character in in that word. i am tired thinking.

to make it clear. i give a simple scenario. i don't have an idea what i
should name my baby.
so, i took my wife  name and me and input to the script.(i want a name that
is from our name combination).

later the output will present many words that i can choose.

the input string can be of any length.

anyone have an idea?


[PHP] weird. iceweasel crash my laptop after i use costum sessions

2007-06-11 Thread jeffry s

i am using my laptop with PHP 4+ and mysql 5+, everything start to be weird
after i implement my costume sessions (storing in database).
i only use one database connection for the whole website.
what i mean is, the session and every query connect to mysqlserver using the
same user.

I am not sure if it is because of the sessions. but it happen after i use
costume sessions.

if i make a SQL query with non existant column name eg: noe

SELECT * FROM test WHERE noe=1;

Suddenly, if i use top to monitor process on my laptop i saw the processor
usage for the mysqld and firefox-bin(iceweasel) increasing.
Icewasel will continue to consume processor usage to 100% and memory up to
80% all the time.

Worst still, the mouse, keyboard do not work anymore. My laptop very-very
slow until i cannot move my mouse cursor at all..

there is no way i can go except turn off the laptop power.

I don't know what the problem is this. but, i think there is something to do
with the sessions. And it related to PHP or may be problem with Iceweasel.
I will try to ask debian mailing list for this.

In case anyone experience the same thing. please let me know how you fix it.