|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 7 May 2003 20:26:26 -0000 Issue 2043
php-general-digest-help
lists.php.net
Date: Wed May 07 2003 - 15:26:26 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 7 May 2003 20:26:26 -0000 Issue 2043
Topics (messages 146627 through 146732):
Session data-files not removed?
146627 by: Vek, Marvin (RW-NL)
146672 by: Johnson, Kirk
Re: hot to use perg_match with multi strign patern
146628 by: Ernest E Vogelsinger
146629 by: SLanger.spirit21.de
146634 by: qt
146639 by: qt
146640 by: qt
146641 by: Jason k Larson
146646 by: qt
146648 by: Jason k Larson
146686 by: Wendell Brown
Cobalt RAQ4 and apache
146630 by: Tristan.Pretty.risk.sungard.com
146632 by: Jason k Larson
146635 by: Tristan.Pretty.risk.sungard.com
Displaying progress in php script
146631 by: GMane
146633 by: Jason k Larson
146705 by: Greg Beaver
146706 by: Greg Beaver
Call to undefined function: html_entity_decode
146636 by: Haseeb Iqbal
146638 by: Jason Wong
Re: Call to undefined function: html_entity_decode[Scanned]
146637 by: Michael Egan
Re: OOP vs procedural
146642 by: Ford, Mike [LSS]
146677 by: Hardik Doshi
146680 by: Ernest E Vogelsinger
146732 by: Hardik Doshi
Re: array_merge on 2d-arrays
146643 by: Ford, Mike [LSS]
146644 by: David T-G
Re: Sloppy coding?
146645 by: Ford, Mike [LSS]
Copyright over images
146647 by: Dario
146663 by: J Wynia
146666 by: Dario
banner rotator
146649 by: Adagilson Batista Bispo da Silva
146650 by: Ernest E Vogelsinger
146651 by: Tom Rogers
146653 by: Mat Harris
146654 by: Jason k Larson
146679 by: Adagilson Batista Bispo da Silva
146682 by: Bernhard Döbler
146683 by: Jason k Larson
146698 by: Adagilson Batista Bispo da Silva
146702 by: Jason k Larson
patch implementing picoSQL support available
146652 by: bk
limit form input digits
146655 by: Malcolm
146656 by: Jason k Larson
146657 by: Gavin Nouwens
146658 by: Marek Kilimajer
146659 by: Jason k Larson
146662 by: Justin French
146724 by: Malcolm
get object by class name
146660 by: Stefan Textor
146665 by: Marek Kilimajer
Re: Redirect command in PHP ???
146661 by: Marek Kilimajer
Re: Forms
146664 by: C.R.
146699 by: Morgan Doocy
Re: linux, apache, mssql
146667 by: Jason Sheets
146674 by: H M Kunzmann
Errors Compiling PHP 4.3.1 with Apache 2
146668 by: Jeremy N.E. Proffitt
session_start() question
146669 by: C.R.
sendmail_from in php.ini
146670 by: news://news.php.net
Re: PHP and dynamic menus
146671 by: Geoff
146730 by: Frank Keessen
Links to dynamic pages
146673 by: Steven M
Problems to compile PHP with MySQL
146675 by: fernando-passos
XML & XSLT
146676 by: Hardik Doshi
146688 by: luis
Re: Links to dynamic pages[Scanned]
146678 by: Michael Egan
146691 by: Steven M
Page Tracking - Newbie Question
146681 by: bob pilly
146684 by: Henrik Hudson
Include Problem... (was Listing Declared Variables)
146685 by: Dan Tappin
Version Conflict
146687 by: Max Wunderer
mail() problem
146689 by: Matthias Redl
146703 by: Jason Wong
146710 by: Chris Hewitt
Re: linking
146690 by: Ryan Holowaychuk
Re: NEWBIE.. Major problems with fopen() ??
146692 by: Matthias Redl
Undefined index
146693 by: caspar kennerdale
146694 by: Adam Voigt
146695 by: caspar kennerdale
146697 by: Adam Voigt
146700 by: caspar kennerdale
Free Live support chat script in PHP
146696 by: luis
Re: php and js variables
146701 by: Morgan Doocy
My first script is not working.
146704 by: Grant
Newbie question about variable scope in Apache 2.0 & PHP
146707 by: Steve Henderson
146709 by: Wendell Brown
146711 by: Steve Henderson
146713 by: Wendell Brown
PHP_SELF defined or not
146708 by: caspar kennerdale
146722 by: Philip Olson
file() problems [newbie]
146712 by: MVCS
MySQL Query help?
146714 by: Steven M
html mail
146715 by: paul marinas
146716 by: paul marinas
146731 by: Ernest E Vogelsinger
Largest INT val?
146717 by: Jason Caldwell
146718 by: Jennifer Goodie
how can go to new url
146719 by: buttoz
146720 by: buttoz
146721 by: luis
146723 by: Dan Tappin
header verification...
146725 by: Dan Joseph
146726 by: Philip Olson
146727 by: Dan Joseph
146728 by: Wendell Brown
146729 by: Dan Joseph
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Now i'm a little confused. I made a script, which starts with
session_start(); and shows the session_id(); on the page and gives you a
form to input something in a text field which will be stored in the session
($_SESSION['name']=$_POST['name']).
Then, i copied the session id displayed on the page, to the url-field (for
example /index.php?PHPSESSID=63et3e9g9dg2d90gd82dg8) and this works, even
when i close the browser, start a new browser and go directly to that url
with PHPSESSID. The session-data with it's name var still exists.
Browser closed, 12 hours later i call that page with that PHPSESSID again
and the session-data still exists.
(BTW, it's PHP4.1.1 on PWS ON NT4)
(THE QUESTION)
This way, the server keeps storing all the session data-files and never
removes them!?!?!?
Here's the most important code of php.ini..
[Session]
; Handler used to store/retrieve data.
session.save_handler = files
; Whether to use cookies.
session.use_cookies = 1
; Name of the session (used as cookie name).
session.name = PHPSESSID
; Initialize session on request startup.
session.auto_start = 0
; Lifetime in seconds of cookie or, if 0, until browser is
restarted.
session.cookie_lifetime = 0
; Handler used to serialize data. php is the standard serializer of
PHP.
session.serialize_handler = php
; Percentual probability that the 'garbage collection' process is
started
; on every session initialization.
session.gc_probability = 1
; After this number of seconds, stored data will be seen as
'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440
; Check HTTP Referer to invalidate externally stored URLs containing
ids.
; HTTP_REFERER has to contain this substring for the session to be
; considered as valid.
session.referer_check =
; How many bytes to read from the file.
session.entropy_length = 0
; Specified here to create the session id.
session.entropy_file =
;session.entropy_length = 16
;session.entropy_file = /dev/urandom
; Set to {nocache,private,public} to determine HTTP caching aspects.
session.cache_limiter = nocache
; Document expires after n minutes.
session.cache_expire = 180
; trans sid support is disabled by default.
; Use of trans sid may risk your users security. It may not be
; feasible to use this option for some sites. Use this option with
caution.
session.use_trans_sid = 0
Is there an advisable way to write code so this doesn't happen, or do i
really need to make some changes to php.ini for that.. or what?
Thanks,
M. Vek
attached mail follows:
> The session-data with it's name var still exists.
> Browser closed, 12 hours later i call that page with that
> PHPSESSID again
> and the session-data still exists.
> session.gc_probability = 1
The gc_probability means there is a 1% chance *on each request to the
server* that the garbage collection process will be launched. Garbage
collection is what effectively destroys the session data. So, if your server
is not getting many requests, the session file can sit there a long time. If
that is a problem, increase the value of the gc setting.
Kirk
attached mail follows:
At 19:59 07.05.2003, qt said:
--------------------[snip]--------------------
>I want search more than one words in the string. I am trying to use
>preg_match with following script but it is finding only last one. I wan to
>find either yes or no. But it is finding only "no" not "yes". Actally I want
>to check bad words in the string such as spelling.
>
>Where is my problem?
>
>if (preg_match("/(yes)?(no)/i", $mesage, $matches)) {
--------------------[snip]--------------------
This expression will only match if there is a "no", optionally immediately
preceded by "yes" (which renders useless - will always match a "no").
You want to use this:
'/(yes|no)/i'
Better yet add a "word boundary" before and after so you only match "Hey
yes dear" and "Hey no dear", but not "Yesterday I had pizza" or "Nowadays
it's a mess":
'/\b(yes|no)\b/i'
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/
attached mail follows:
Hello
Your problem is the pattern itself.
>if (preg_match("/(yes)?(no)/i", $mesage, $matches)) {
> print "refusee - $matches[0]";
>} else {
> print "negative";
>};
Your pattern tells the regex to find any 'no' in a text. Since the yes is
optional the regex will never check for it. In other words the ()? part is
skipped and the no part is tested since the pattern can only match if a no
is in the text. The regex will see this and simply ignore the (yes)?.
What you probably want is to use alternatives making your pattern look
like /(?:yes|no)/i. This way either yes or no is found. Beaware that if
you do want to do this it will probably faster to use a string function to
find literal occurences.
Regards
Stefan Langer
attached mail follows:
Dear Sirs,
I want search more than one words in the string. I am trying to use
preg_match with following script but it is finding only last one. I wan to
find either yes or no. But it is finding only "no" not "yes". Actally I want
to check bad words in the string such as spelling.
Where is my problem?
if (preg_match("/(yes)?(no)/i", $mesage, $matches)) {
print "refusee - $matches[0]";
} else {
print "negative";
};
Best Regards
attached mail follows:
Dear Ernes,
Thanks for help, it is working very good with preg_match.
But when I try same thing with eregi, it is not working any idea why?
if (eregi("/\b(got|am)\b", $mesage, $matches))
"Ernest E Vogelsinger" <ernest
vogelsinger.at> wrote in message
news:5.1.1.6.2.20030507100347.033298e0
mail.vogelsinger.at...
> At 19:59 07.05.2003, qt said:
> --------------------[snip]--------------------
> >I want search more than one words in the string. I am trying to use
> >preg_match with following script but it is finding only last one. I wan
to
> >find either yes or no. But it is finding only "no" not "yes". Actally I
want
> >to check bad words in the string such as spelling.
> >
> >Where is my problem?
> >
> >if (preg_match("/(yes)?(no)/i", $mesage, $matches)) {
> --------------------[snip]--------------------
>
> This expression will only match if there is a "no", optionally immediately
> preceded by "yes" (which renders useless - will always match a "no").
>
> You want to use this:
> '/(yes|no)/i'
>
> Better yet add a "word boundary" before and after so you only match "Hey
> yes dear" and "Hey no dear", but not "Yesterday I had pizza" or "Nowadays
> it's a mess":
> '/\b(yes|no)\b/i'
>
>
> --
> >O Ernest E. Vogelsinger
> (\) ICQ #13394035
> ^ http://www.vogelsinger.at/
>
>
attached mail follows:
Dear Stefan,
Thank you for your advise I try strpos as this;
$pos = strpos($mesage, "/(?:yes|no)/i");
but it returns nothing, do I need different patern design for strpos?
<SLanger
spirit21.de> wrote in message
news:OF74814AF1.117DE5CA-ONC1256D1F.00316CA7-41256D1F.003744CC
spirit21.de..
.
> Hello
>
> Your problem is the pattern itself.
>
> >if (preg_match("/(yes)?(no)/i", $mesage, $matches)) {
> > print "refusee - $matches[0]";
> >} else {
> > print "negative";
> >};
>
> Your pattern tells the regex to find any 'no' in a text. Since the yes is
> optional the regex will never check for it. In other words the ()? part is
> skipped and the no part is tested since the pattern can only match if a no
> is in the text. The regex will see this and simply ignore the (yes)?.
>
> What you probably want is to use alternatives making your pattern look
> like /(?:yes|no)/i. This way either yes or no is found. Beaware that if
> you do want to do this it will probably faster to use a string function to
> find literal occurences.
>
> Regards
> Stefan Langer
attached mail follows:
Shouldn't it be:
if (eregi('/\b(got|am)\b/', $mesage, $matches)) { }
^ end slash
--
Jason k Larson
qt wrote:
> Dear Ernes,
>
> Thanks for help, it is working very good with preg_match.
>
> But when I try same thing with eregi, it is not working any idea why?
>
> if (eregi("/\b(got|am)\b", $mesage, $matches))
attached mail follows:
It is not working to
> > if (eregi("/\b(got|am)\b", $mesage, $matches))
"Jason K Larson" <jlarson
candlefire.org> wrote in message
news:3EB8DC6D.3050102
candlefire.org...
> Shouldn't it be:
>
> if (eregi('/\b(got|am)\b/', $mesage, $matches)) { }
> ^ end slash
>
> --
> Jason k Larson
>
>
> qt wrote:
> > Dear Ernes,
> >
> > Thanks for help, it is working very good with preg_match.
> >
> > But when I try same thing with eregi, it is not working any idea why?
> >
> > if (eregi("/\b(got|am)\b", $mesage, $matches))
>
>
attached mail follows:
Sure enough ... I wasn't looking that closely. The syntax in the match is specific to
perl regular expressions. Don't use eregi use preg_match. If you need the
case-insensitive matching use the trailing i.
if (preg_match('/\b(got|am)\b/i', $mesage, $matches))
Of course, Ernest already gave you this example.
The preg_* functions are 99% of the time faster and more efficient than the ereg* functions.
--
Jason k Larson
qt wrote:
> It is not working to
>
>
>>>if (eregi("/\b(got|am)\b", $mesage, $matches))
attached mail follows:
On Wed, 7 May 2003 10:59:38 -0700, qt wrote:
>Where is my problem?
>
>if (preg_match("/(yes)?(no)/i", $mesage, $matches)) {
> print "refusee - $matches[0]";
>} else {
> print "negative";
>};
Try "|" (perl or) instead of "?" --- like this:
if (preg_match("/(yes)|(no)/i", $mesage, $matches)) {
print "refusee - $matches[0]";
} else {
print "negative";
};
You aren't using Perl Regular Expressions. ;)
attached mail follows:
Hi guys...
I have an off topic question, but I really don't know where else to
turn...
I have a dedicated server hosted at NetBenefit.com
It is a cobalt RAQ4.
I am responsible for patching, maintaining etc, the server.
I'm not that savy with it all, but I've found several excellent tutorials on line, that have poitned me in the right direction.
Anyway, my last tinkering was 6 months ago, when netbenefit added the
'mod_auth_mysql' module. (I was charged Ł150+VAT for their trouble)
3 months later, I added a new URL via the control panel, and all was
well...
However, yesterday, I tried to add another URL, and was greeted by a
server error page.
I called netbenefit, and told them that the admin tools no longer worked.
I was told that as I'd not added patches regulally, the site would be
filled with errors.
The guy down the phone gave a fairly logical reason that things change,
and bugs creep in etc...
But I'm of the view that it worked 6 months ago, it worked 3 months ago,
and this week it's stopped, through no fault of my own.
Am I being so naive here? I really suspect that I'm being taken for a ride by people who simply want to extort extra cash from me.
They claim to have changed nothing too, so in my mind, it should still
work, yet it doesn't.
So...
Can an unpatched server, simply stop working? Either entirely, or certain functions?
i really hope that someone can help me... Im pulling my hair out and about to scream.
Cheers.
Tris...
***********************************************************************
The information contained in this e-mail message is intended only for
the personal and confidential use of the recipient(s) named above.
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is
strictly prohibited. If you have received this communication in error,
please notify us immediately by e-mail, and delete the original message.
************************************************************************
attached mail follows:
> Can an unpatched server, simply stop working? Either entirely, or certain functions?
Simply yes. I know of several Coblat RAQ4 and RAQ4Rs that have been either hacked and
taken over, or hacked and destroyed. If you didn't change something, and the NetBenefit
folks didn't change anything, and things that used to work don't ... well I'd suggest
making sure you've got a recent back-up while you've still got access to your data. Then
explore securing your server. But those RAQs usually run sendmail don't they, hope that
isn't open to the outside world. If you want some real answers, give us some real errors
... can't help troubleshoot a vague problem.
This is *way* off-topic though.
--
Jason k Larson
/* Build a man a fire and he is warm for a day.
Light a man on fire and he is warm for the rest of his life. */
attached mail follows:
Cheers for that...
Sadly, I can't access the control panel via work (firewall).
So I'll have to wait til I pop home to get teh specifics of the error.
I appreciate your candid responce.
I have all the web sites backed up locally, so a fresh install of the
server software will be a viable option
I'll be back...
Jason k Larson <jlarson
candlefire.org>
07/05/2003 10:30
To: Tristan.Pretty
risk.sungard.com
cc: php-general
lists.php.net
Subject: Re: [PHP] Cobalt RAQ4 and apache
> Can an unpatched server, simply stop working? Either entirely, or
certain functions?
Simply yes. I know of several Coblat RAQ4 and RAQ4Rs that have been
either hacked and
taken over, or hacked and destroyed. If you didn't change something, and
the NetBenefit
folks didn't change anything, and things that used to work don't ... well
I'd suggest
making sure you've got a recent back-up while you've still got access to
your data. Then
explore securing your server. But those RAQs usually run sendmail don't
they, hope that
isn't open to the outside world. If you want some real answers, give us
some real errors
... can't help troubleshoot a vague problem.
This is *way* off-topic though.
--
Jason k Larson
/* Build a man a fire and he is warm for a day.
Light a man on fire and he is warm for the rest of his life. */
***********************************************************************
The information contained in this e-mail message is intended only for
the personal and confidential use of the recipient(s) named above.
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is
strictly prohibited. If you have received this communication in error,
please notify us immediately by e-mail, and delete the original message.
************************************************************************
attached mail follows:
I'm writing a php script which takes a long time to do its stuff (producing
thumbnails from movies). Is it possible to display the progress of what's
going on. If I do this
<convert file>
print "converting file $file<br>"
it only prints the string when the entire page has finished.
Is there a way around this?
attached mail follows:
First, if you are doing any output buffering, you'll need to end and flush the buffer.
Second, browsers have a receive buffer of their own, IE has a 4k buffer that has to be
filled before it will display data, and even then will only render when it has all the
structure it's waiting for, like tables must be completed etc.
Then you can try the flush function:
http://www.php.net/manual/en/function.flush.php
When I was doing this sort of this I used JavaScript to toggle visibility of DIV
containers with text labels, for a cool effect. But you'll have to write 4k of hidden
comment data or the like to flush the browsers buffers.
--
Jason k Larson
GMane wrote:
> I'm writing a php script which takes a long time to do its stuff (producing
> thumbnails from movies). Is it possible to display the progress of what's
> going on. If I do this
>
> <convert file>
> print "converting file $file<br>"
>
> it only prints the string when the entire page has finished.
>
> Is there a way around this?
>
>
>
>
attached mail follows:
You'll have to put progress output in the <convert file> section for it
to be displayed while converting.
Regards,
Greg
--
phpDocumentor
http://www.phpdoc.org
Gmane wrote:
> I'm writing a php script which takes a long time to do its stuff (producing
> thumbnails from movies). Is it possible to display the progress of what's
> going on. If I do this
>
> <convert file>
> print "converting file $file<br>"
>
> it only prints the string when the entire page has finished.
>
> Is there a way around this?
>
>
>
attached mail follows:
You'll have to put progress output in the <convert file> section for it
to be displayed while converting.
Regards,
Greg
--
phpDocumentor
http://www.phpdoc.org
Gmane wrote:
> I'm writing a php script which takes a long time to do its stuff (producing
> thumbnails from movies). Is it possible to display the progress of what's
> going on. If I do this
>
> <convert file>
> print "converting file $file<br>"
>
> it only prints the string when the entire page has finished.
>
> Is there a way around this?
>
>
>
attached mail follows:
hi all,
i am using php 4.2.2 on linux.and i am getting this error Call to undefined
function: html_entity_decode().
i read in the manual thats string functions are part of the core.so why i am
getting this error. while on my testing server its php 4.3.0 and there isn't
any error?
any idea are welcome
Creativity is inventing, experimenting, growing, taking risks, breaking
rules, making mistakes, and having fun.
Haseeb Iqbal
attached mail follows:
On Thursday 08 May 2003 06:40, Haseeb Iqbal wrote:
You have started a new thread by taking an existing posting and replying to
it while you changed the subject.
That is bad, because it breaks threading. Whenever you reply to a message,
your mail client generates a "References:" header that tells all recipients
which posting(s) your posting refers to. A mail client uses this information
to build a threaded view ("tree view") of the postings.
With your posting style you successfully torpedoed this useful feature; your
posting shows up within an existing thread it has nothing to do with.
Always do a fresh post when you want to start a new thread. To achieve this,
click on "New message" instead of "Reply" within your mail client, and enter
the list address as the recipient. You can save the list address in your
address book for convenience.
> i am using php 4.2.2 on linux.and i am getting this error Call to undefined
> function: html_entity_decode().
> i read in the manual thats string functions are part of the core.so why i
> am getting this error. while on my testing server its php 4.3.0 and there
> isn't any error?
RTFM > PHP 4 >= 4.3.0
--
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 is very little future in being right when your boss is wrong.
*/
attached mail follows:
Haseeb,
Looking at the manual this function was only introduced in 4.3. That would explain the error message on the earlier version:
http://www.php.net/manual/en/function.html-entity-decode.php
HTH
Regards,
Michael Egan
-----Original Message-----
From: Haseeb Iqbal [mailto:webcodder
hotmail.com]
Sent: 07 May 2003 23:41
To: PHP General list
Subject: [PHP] Call to undefined function: html_entity_decode[Scanned]
hi all,
i am using php 4.2.2 on linux.and i am getting this error Call to undefined
function: html_entity_decode().
i read in the manual thats string functions are part of the core.so why i am
getting this error. while on my testing server its php 4.3.0 and there isn't
any error?
any idea are welcome
Creativity is inventing, experimenting, growing, taking risks, breaking
rules, making mistakes, and having fun.
Haseeb Iqbal
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
> -----Original Message-----
> From: Vania Smrkovski [mailto:vania
pandorasdream.com]
> Sent: 07 May 2003 00:33
>
> Personally,
> I hope PHP continues to develop its OOP flavorings.
>
> I don't know if anyone else agrees, but if the PHP
> developers are
> interested where PHP 5 might go, my hope is that it will
> allow for more of
> the OOP support.
Don't worry, they're way ahead of you! Take a look at http://www.zend.com/zend/future.php to see where PHP5 is heading.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford
lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
attached mail follows:
I have a question on OOP.
What you guys are using for calling functions withing
class? I am putting functions in class and calling it
by classname::function name (place where there is no
need to create an object). Is it the correct way to
calling it? I thought there is no need to allocate
memory for the object of class.
Please give your thoughts.
Thanks
Hardik
--- Martin Towell <martin.towell
world.net> wrote:
> I've seen only one reply to the original message, so
> here's my 2c worth
>
> I use OO to prevent too many global variables
> floating around the place. In
> this company, there's 1,000's of globals, and very
> often they interfere with
> each other. I am (with the help with someone else)
> trying to move all the
> core code to use OO so we don't have this problem.
>
> I think that there's a place for both styles.
> Self-contained functions can
> stay by themselves, functions that interact with
> each other naturally lend
> themselves to objects...
>
> -----Original Message-----
> From: Info
Best-IT [mailto:info
best-it.biz]
> Sent: Wednesday, May 07, 2003 1:59 AM
> To: PHP general
> Subject: [PHP] OOP vs procedural
>
>
> Between these 2 styles of writing PHP which is
> better usually:
>
> C-style, using include files containing paths to
> libraries?
>
> Object Oriented: everything is structures with class
> files?
>
> Thanks,
> /T
>
>
> --
> 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
>
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
attached mail follows:
At 16:49 07.05.2003, Hardik Doshi spoke out and said:
--------------------[snip]--------------------
>I have a question on OOP.
>
>What you guys are using for calling functions withing
>class? I am putting functions in class and calling it
>by classname::function name (place where there is no
>need to create an object). Is it the correct way to
>calling it? I thought there is no need to allocate
>memory for the object of class.
>
>Please give your thoughts.
--------------------[snip]--------------------
This is a valid method and used widely in other oop languages as well.
Class methods that do not necessarily need an object instance (they lack a
valid $this object) are called static methods. You can always call a static
methods as classname::methodname(params).
Differing to "real" OOP languages, PHP doesn't have the capability of
declaring static class methods, you need to work this out yourself. You may
always check for the $this variable; usually when it exists (isset) then
the object has been called non-static.
I say "usually" because if any object instance calls another class method
in a static way, the $this variable will propagate into the static method -
unfortunately. Hope this will change with PHP5.
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/
attached mail follows:
Thanks for your feedback.
Hardik
--- Ernest E Vogelsinger <ernest
vogelsinger.at>
wrote:
> At 16:49 07.05.2003, Hardik Doshi spoke out and
> said:
> --------------------[snip]--------------------
> >I have a question on OOP.
> >
> >What you guys are using for calling functions
> withing
> >class? I am putting functions in class and calling
> it
> >by classname::function name (place where there is
> no
> >need to create an object). Is it the correct way to
> >calling it? I thought there is no need to allocate
> >memory for the object of class.
> >
> >Please give your thoughts.
> --------------------[snip]--------------------
>
> This is a valid method and used widely in other oop
> languages as well.
> Class methods that do not necessarily need an object
> instance (they lack a
> valid $this object) are called static methods. You
> can always call a static
> methods as classname::methodname(params).
>
> Differing to "real" OOP languages, PHP doesn't have
> the capability of
> declaring static class methods, you need to work
> this out yourself. You may
> always check for the $this variable; usually when it
> exists (isset) then
> the object has been called non-static.
>
> I say "usually" because if any object instance calls
> another class method
> in a static way, the $this variable will propagate
> into the static method -
> unfortunately. Hope this will change with PHP5.
>
>
> --
> >O Ernest E. Vogelsinger
> (\) ICQ #13394035
> ^ http://www.vogelsinger.at/
>
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
attached mail follows:
> -----Original Message-----
> From: David T-G [mailto:davidtg-php
justpickone.org]
> Sent: 07 May 2003 03:35
>
> Hi, all --
>
> Given the snippet of code
>
> $a1 = array ( 'aa' => array ( 'a' => "aye", 'b' => "bee",
> 'c' => "see" ) , 'bb' => array ( 'd' => 'dee' ) ) ;
> $a2 = array ( 'aa' => array ( 'e' => "eee", 'f' => "efh" ) ) ;
> $m1 = array_merge($a1,$a2) ;
> $m2 = array ( 'aa' => array_merge ($a1[aa],$a2[aa]) , 'bb'
> => $a1[bb]) ;
>
> and a quick
>
> print "<pre>\n" ;
> print "a1 : \n" ; print_r($a1) ;
> print "a2 : \n" ; print_r($a2) ;
> print "m1 : \n" ; print_r($m1) ;
> print "m2 : \n" ; print_r($m2) ;
> print "</pre>\n" ;
>
> we can see that $m1 simply steps on the 'aa' array from $a1
> and that $m2
> gives me what I'd naturally want. Is there a recursive
> array_merge that
> will handle multi-dimensional arrays so that I don't have to write
> something like this from scratch?
Uh, well at the bottom of the manual page for array_merge()
(http://www.php.net/array-merge) it says "See also array_merge_recursive()"
-- seems like a clue to me.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford
lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
attached mail follows:
Mike, et al --
...and then Ford, Mike [LSS] said...
%
% > -----Original Message-----
% > From: David T-G [mailto:davidtg-php
justpickone.org]
...
% > gives me what I'd naturally want. Is there a recursive
% > array_merge that
% > will handle multi-dimensional arrays so that I don't have to write
% > something like this from scratch?
%
% Uh, well at the bottom of the manual page for array_merge()
% (http://www.php.net/array-merge) it says "See also array_merge_recursive()"
% -- seems like a clue to me.
D'oh! You're right; I should have seen that! I was so busy working on
the a_m() examples, thinking I had successfully read the entire section,
that I missed the a_m_r() pointer. And it wasn't even late yet :-(
Sorry!
%
% Cheers!
%
% Mike
Thanks & HAND
:-D
--
David T-G * There is too much animal courage in
(play) davidtg
justpickone.org * society and not sufficient moral courage.
(work) davidtgwork
justpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)
iD8DBQE+uN8YGb7uCXufRwARAoRbAKDi02WCzbu4QNZ9vZzTeuyjB297IwCgvJaC
6wjCqhl6BLIYCy6nkkF4Bwo=
=cypd
-----END PGP SIGNATURE-----
attached mail follows:
> -----Original Message-----
> From: Shawn McKenzie [mailto:nospam
mckenzies.net]
> Sent: 07 May 2003 05:21
>
> I want to sidestep any pitfalls and try to be a good coder.
> So what is the
> difference between these two:
>
> if(!$somevar){
> ...do stuff
> }
This will "do stuff" if $somevar is undefined, NULL, FALSE, zero (integer 0 or float 0.0), "", "0", or an empty array. It will also issue a notice if $somevar is undefined -- and although you will only see this if you have error_reporting set to E_ALL, it's better practice to write code that won't issue any messages even at the highest level of reporting.
If you want to do this test without the possibility of generating a message, use if(empty($somevar)).
>
> if(!isset($somevar)){
> ...do stuff
> }
This will "do stuff" only if $somevar is undefined or NULL, and will not issue any messages.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford
lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
attached mail follows:
Hi,
I need to write over some images uploaded on my site, automatically with
php, a string for the copyright.
The string should be a few transparent, and the result should be like this:
http://64.29.17.110/members/demo/watermarks/pic3.jpg
Can I do it with ImageMagick? If so, can you give me an example of the
command I have to use?
Otherwise, what can I use and how? (I'd prefer ImageMagick because I've
already have it)
Thank you very much in advantage (and sorry for my english :D ).
Bye
Dario
attached mail follows:
I wrote an article a while back on doing this with PHP/GD2 at:
http://www.phpgeek.com/articles.php?content_id=6
Dario wrote:
> Hi,
>
> I need to write over some images uploaded on my site, automatically with
> php, a string for the copyright.
> The string should be a few transparent, and the result should be like this:
> http://64.29.17.110/members/demo/watermarks/pic3.jpg
> Can I do it with ImageMagick? If so, can you give me an example of the
> command I have to use?
> Otherwise, what can I use and how? (I'd prefer ImageMagick because I've
> already have it)
>
> Thank you very much in advantage (and sorry for my english :D ).
>
> Bye
> Dario
>
attached mail follows:
Thank you very very much! :)
J Wynia wrote:
> I wrote an article a while back on doing this with PHP/GD2 at:
> http://www.phpgeek.com/articles.php?content_id=6
>
> Dario wrote:
> > Hi,
> >
> > I need to write over some images uploaded on my site, automatically with
> > php, a string for the copyright.
> > The string should be a few transparent, and the result should be like this:
> > http://64.29.17.110/members/demo/watermarks/pic3.jpg
> > Can I do it with ImageMagick? If so, can you give me an example of the
> > command I have to use?
> > Otherwise, what can I use and how? (I'd prefer ImageMagick because I've
> > already have it)
> >
> > Thank you very much in advantage (and sorry for my english :D ).
> >
> > Bye
> > Dario
> >
attached mail follows:
is something wrong with this script?
Message from the server:
Parse error: parse error, unexpected T_SWITCH in C:\Arquivos de
programas\Apache Group\Apache2\htdocs\testads.html on line 34
a.
THE SCRIPT:
<?php
srand( microtime * 1000000);
$num = rand(1,4)
switch($num)
{
case 1 : $img="ad-panashop.gif"
$url="http://www.panashop.com.br/files/pags/ShoWDetail.asp?Coditprod=11277&CodProd=9869&Precode=699&Precopor=699&titulo=DVD%20FOTO-CD%20E%20KARAOKE%20PHILIPS%20DVD616&CodDf=DVD616&setor=14&cv=14";
break;
case 1 : $img="ad-vw.gif"
$url="http://www.volkswagen.com.br/default.asp"; break;
case 1 : $img="ad-panashop.gif"
$url="http://www.panashop.com.br/files/pags/ShoWDetail.asp?Coditprod=11277&CodProd=9869&Precode=699&Precopor=699&titulo=DVD%20FOTO-CD%20E%20KARAOKE%20PHILIPS%20DVD616&CodDf=DVD616&setor=14&cv=14";
break;
case 1 : $img="ad-vw.gif"
$url="http://www.volkswagen.com.br/default.asp"; break;
}
$banner = "<a href=\"$url\"> ";
$banner = "<img src=\"$img\"> ";
$banner = "</a>";
echo($banner);
?>
attached mail follows:
At 13:38 07.05.2003, Adagilson Batista Bispo da Silva said:
--------------------[snip]--------------------
>is something wrong with this script?
>Message from the server:
>
> Parse error: parse error, unexpected T_SWITCH in C:\Arquivos de
> programas\Apache Group\Apache2\htdocs\testads.html on line 34
>
>a.
>
>THE SCRIPT:
><?php
>
>srand( microtime * 1000000);
>
>$num = rand(1,4)
>switch($num)
--------------------[snip]--------------------
You're missing a semicolon after the rand() function, before the switch
statement.
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/
attached mail follows:
Hi,
Wednesday, May 7, 2003, 9:38:52 PM, you wrote:
ABBdS> is something wrong with this script?
ABBdS> Message from the server:
ABBdS> Parse error: parse error, unexpected T_SWITCH in C:\Arquivos de
ABBdS> programas\Apache Group\Apache2\htdocs\testads.html on line 34
ABBdS> a.
ABBdS> THE SCRIPT:
ABBdS> <?php
ABBdS> srand( microtime * 1000000);
ABBdS> $num = rand(1,4)
ABBdS> switch($num)
ABBdS> {
ABBdS> case 1 : $img="ad-panashop.gif"
ABBdS> $url="http://www.panashop.com.br/files/pags/ShoWDetail.asp?Coditprod=11277&CodProd=9869&Precode=699&Precopor=699&titulo=DVD%20FOTO-CD%20E%20KARAOKE%20PHILIPS%20DVD616&CodDf=DVD616&setor=14&cv=14";
ABBdS> break;
ABBdS> case 1 : $img="ad-vw.gif"
ABBdS> $url="http://www.volkswagen.com.br/default.asp"; break;
ABBdS> case 1 : $img="ad-panashop.gif"
ABBdS> $url="http://www.panashop.com.br/files/pags/ShoWDetail.asp?Coditprod=11277&CodProd=9869&Precode=699&Precopor=699&titulo=DVD%20FOTO-CD%20E%20KARAOKE%20PHILIPS%20DVD616&CodDf=DVD616&setor=14&cv=14";
ABBdS> break;
ABBdS> case 1 : $img="ad-vw.gif"
ABBdS> $url="http://www.volkswagen.com.br/default.asp"; break;
ABBdS> }
ABBdS> $banner = "<a href=\"$url\"> ";
ABBdS> $banner = "<img src=\"$img\"> ";
ABBdS> $banner = "</a>";
ABBdS> echo($banner);
?>>
This line needs terminating with a ;
$num = rand(1,4) <<<<<
--
regards,
Tom
attached mail follows:
> $banner = "<a href=\"$url\"> ";
>
> $banner = "<img src=\"$img\"> ";
>
> $banner = "</a>";
>
> echo($banner);
also i think you mean to use '.=' instead of '='.
when you print banner you will just get '</a>'
$banner = "<a href=\"$url\"> ";
$banner .= "<img src=\"$img\"> ";
$banner .= "</a>";
echo($banner);
attached mail follows:
With the rand() like properly ending with a ';' it also looks like you meant to increment
your case values as well, you example shows all are 1.
case 1:
case 2:
case 3:
case 4:
--
Jason k Larson
attached mail follows:
Ok, thansk Jason, Mat, Tom and Ernest, for replying.
Now there's an error in this line:
case 1 : $img="ad-panashop.gif"
$url="http://www.panashop.com.br/files/pags/ShoWDetail.asp?Coditprod=11277&CodProd=9869&Precode=699&Precopor=699&titulo=DVD%20FOTO-CD%20E%20KARAOKE%20PHILIPS%20DVD616&CodDf=DVD616&setor=14&cv=14";
break;
The server:
Parse error: parse error, unexpected T_VARIABLE in C:\Arquivos de
programas\Apache Group\Apache2\htdocs\testads.html on line 38
Thanks again
a.
Jason k Larson escreveu:
> With the rand() like properly ending with a ';' it also looks like you
> meant to increment your case values as well, you example shows all are 1.
>
> case 1:
> case 2:
> case 3:
> case 4:
>
> --
> Jason k Larson
>
>
attached mail follows:
another ;
You have to end nearly EVERY line with an ;
Bernhard
----- Original Message -----
From: "Adagilson Batista Bispo da Silva" <adagilson
cpqam.fiocruz.br>
To: <php-general
lists.php.net>
Sent: Wednesday, May 07, 2003 5:01 PM
Subject: [PHP] Re: banner rotator
> Ok, thansk Jason, Mat, Tom and Ernest, for replying.
> Now there's an error in this line:
>
> case 1 : $img="ad-panashop.gif" <<<<----------
> $url="http://www.panashop.com.br/files/pags/ShoWDetail.asp?Coditprod=11277&CodProd=9869&Precode=699&Precopor=699&titulo=DVD%20FOTO-CD%20E%20KARAOKE%20PHILIPS%20DVD616&CodDf=DVD616&setor=14&cv=14";
> break;
>
>
> The server:
>
> Parse error: parse error, unexpected T_VARIABLE in C:\Arquivos de
> programas\Apache Group\Apache2\htdocs\testads.html on line 38
>
attached mail follows:
Looks like another missing semicolon
case 1 : $img="ad-panashop.gif";
$url="http://www.panashop.com.br/files/pags/ShoWDetail.asp?Coditprod=11277&CodProd=9869&Precode=699&Precopor=699&titulo=DVD%20FOTO-CD%20E%20KARAOKE%20PHILIPS%20DVD616&CodDf=DVD616&setor=14&cv=14";
break;
--
Jason k Larson
attached mail follows:
Ok, one banner is being displayed very well. Thanks
Another problem: just *one banner* of four is being displayed. Reloading
the page the same will appear; it's not rotatory, is it?
I would like to have a new banner each time the page is reloaded.
look the script again:
> srand( microtime * 1000000);
>
> $num = rand(1,4);
>
>
>
> switch($num)
>
> {
>
> case 1 : $img="ad-panashop.gif";
> $url="http://www.panashop.com.br/files/pags/ShoWDetail.asp?Coditprod=11277&CodProd=9869&Precode=699&Precopor=699&titulo=DVD%20FOTO-CD%20E%20KARAOKE%20PHILIPS%20DVD616&CodDf=DVD616&setor=14&cv=14";
> break;
>
> case 2 : $img="ad-vw.gif";
> $url="http://www.volkswagen.com.br/default.asp"; break;
>
> case 3 : $img="ad-philips.gif";
> $url="http://www.panashop.com.br/files/pags/ShoWDetail.asp?Coditprod=11277&CodProd=9869&Precode=699&Precopor=699&titulo=DVD%20FOTO-CD%20E%20KARAOKE%20PHILIPS%20DVD616&CodDf=DVD616&setor=14&cv=14";
> break;
>
> case 4 : $img="ad-casseta.gif";
> $url="http://www.volkswagen.com.br/default.asp"; break;
>
> }
so long
a.
Jason k Larson escreveu:
> Looks like another missing semicolon
>
> case 1 : $img="ad-panashop.gif";
> $url="http://www.panashop.com.br/files/pags/ShoWDetail.asp?Coditprod=11277&CodProd=9869&Precode=699&Precopor=699&titulo=DVD%20FOTO-CD%20E%20KARAOKE%20PHILIPS%20DVD616&CodDf=DVD616&setor=14&cv=14";
>
> break;
>
> --
> Jason k Larson
>
>
attached mail follows:
The only other error I see if the use of 'microtime'. I think you mean to call the function.
So it should read:
srand(microtime() * 1000000);
"In older versions of PHP, you had to seed the random number generator before use with
srand(). Since 4.2.0 this is no longer necessary."
Otherwise it all works for me just fine.
--
Jason k Larson
attached mail follows:
picoSQL (http://www.picosoft.it/picosql) is a free (GPL/LGPL licensed)
sql server: it is extremely light (runs on the zaurus pda, too) but
rather complete (UNION, VIEW, subquery, ...).
picoSQL guys have provided a very small patch to PHP to provide
support to their sql server:
http://www.picosoft.it/picosql/php_en.html
It is against the 4.3.1 sources and just adds a very few lines to
php-4.3.1/ext/odbc/config.m4 and php-4.3.1/ext/odbc/php_odbc_includes.h
A test php script is available in the binary/src tarballs.
attached mail follows:
Hello All,
I'm trying to limit to 99 the amount of times this prints ;
if (ereg ("([^0-9]{2})", $incre)) {
echo "bad input";
} else {
echo "Printing now ...<br>";
}
Reading the manual and the comments I thought the {2} would do that,
but it doesn't. I have set the form field size to two but that isn't
working
either, you can still put more than two numbers in the field even though
they don't show. The {2} does keep letters out but how can I limit the
input to two digits ?
attached mail follows:
a few ways, one I like is:
// grab the first to characters
$incre = substr ($incre,0,2);
--
Jason k Larson
attached mail follows:
In the HTML form did you set the size to 2 or the maxlength?
Maxlength is the one that limits the number of chars for a field.
-gav.
| -----Original Message-----
| From: Malcolm [mailto:malcolm
mbrownell.com]
| Sent: Wednesday, 7 May 2003 10:17 PM
| To: php-general
lists.php.net
| Subject: [PHP] limit form input digits
|
|
|
|
| Hello All,
|
| I'm trying to limit to 99 the amount of times this prints ;
|
| if (ereg ("([^0-9]{2})", $incre)) {
| echo "bad input";
| } else {
| echo "Printing now ...<br>";
| }
|
| Reading the manual and the comments I thought the {2} would do that,
| but it doesn't. I have set the form field size to two but that isn't
| working
| either, you can still put more than two numbers in the field
| even though
| they don't show. The {2} does keep letters out but how can I
| limit the
| input to two digits ?
|
| --
| PHP General Mailing List (http://www.php.net/)
| To unsubscribe, visit: http://www.php.net/unsub.php
|
attached mail follows:
The regex returns true if there are at least 2 nondigits next to each
other. If you want to limit the number of digits to 2, use
if (ereg ("([0-9]{3})", $incre)) {
echo "bad input";
} else {
echo "Printing now ...<br>";
}
or more simple
if ($incre > 99)
in html use
<input type="text" maxlength="2" size="2" .... >
Malcolm wrote:
>
>
> Hello All,
>
> I'm trying to limit to 99 the amount of times this prints ;
>
> if (ereg ("([^0-9]{2})", $incre)) {
> echo "bad input";
> } else {
> echo "Printing now ...<br>";
> }
>
> Reading the manual and the comments I thought the {2} would do that,
> but it doesn't. I have set the form field size to two but that isn't
> working
> either, you can still put more than two numbers in the field even
> though they don't show. The {2} does keep letters out but how can I
> limit the input to two digits ?
attached mail follows:
Also, the HTML fix for this would be something like:
<INPUT TYPE="text" NAME="incre" VALUE="" MAXLENGTH="2">
--
Jason k Larson
P.S. I misspelled two with to in my previous comment line, my apologies.
attached mail follows:
on 07/05/03 11:37 PM, Gavin Nouwens (gnouwens
zip.com.au) wrote:
> In the HTML form did you set the size to 2 or the maxlength?
>
> Maxlength is the one that limits the number of chars for a field.
Yes, that's a good start, but it doesn't prevent me from creating my own
form, with unlimited characters, which submits to the same PHP script :)
Justin
attached mail follows:
Thanks to all who answered. This is for the list;
I got two solutions either maxlength on the html field or
(my favorite) if ($incre > 99) KIS,S !
On Wed, 07 May 2003 08:17:06 -0400, Malcolm <malcolm
mbrownell.com> wrote:
>
>
> Hello All,
>
> I'm trying to limit to 99 the amount of times this prints ;
>
> if (ereg ("([^0-9]{2})", $incre)) {
> echo "bad input";
> } else {
> echo "Printing now ...<br>";
> }
>
> Reading the manual and the comments I thought the {2} would do that,
> but it doesn't. I have set the form field size to two but that isn't
> working
> either, you can still put more than two numbers in the field even though
> they don't show. The {2} does keep letters out but how can I limit the
> input to two digits ?
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
attached mail follows:
Hi,
is there any possibility to get an object by its class name?
Thank you very much in advantage.
Stefan
attached mail follows:
The only way I can think of is to loop $GLOBALS and do this check:
foreach($GLOBALS as $key => $val) {
if(is_object($val) && get_class($val) == 'YourClassName' ){
// $GLOBALS[$key] is your desired object
}
}
Stefan Textor wrote:
> Hi,
>
> is there any possibility to get an object by its class name?
>
> Thank you very much in advantage.
>
> Stefan
>
>
attached mail follows:
Andrei Verovski (aka MacGuru) wrote:
> Hi, George,
>
> I have implemented header("Location: script.php) and everything seem
> to be OK until I have to continue current session.
>
>
> There is a class MyApp which does certain jobs, and instance of this
> class (not shown here). In function OpenMainPage() I have started
> session, assigned name to it and registered certain variables.
> file: MyApp.php
>
> class MyApp {
>
> // --- MORE STUFF HERE
>
> function OpenMainPage()
> {
put here
global $aaa;
or use $_SESSION['aaa'] instead
>
> $res = $this -> mDb -> Execute('SELECT * FROM contacts');
> if ($res -> RecordCount() == 0)
> $this -> SetupDefaultDBRecords();
>
> session_start();
> session_name('MyApplicationSession');
changing session name must be done before session_start()
>
>
> $aaa = "blah blah blah";
> if (! session_register("aaa"))
> echo "failed to register variable";
>
> header("Location:StartupPage.php?".SID);
> }
> }
>
> ----------------------------------------------
>
> Then I would like to pass the control to script called StartupPage.php
> using header("Location:StartupPage.php?".SID).
>
> file StartupPage.php
>
> session_start();
>
> echo session_name(); // prints PHPSESSION or something like this
>
> echo $_SESSION["aaa"]; // prints nothing
>
> ----------------------------------------------
>
> However, session seem to be terminated, although I have used SID. I
> have tried to move session_start();
> session_name('MyApplicationSession') to the first script where the
> instance of MyApp class have been created and used, but the result is
> the same. I have checked PHP options (default install of PHP 4.2.3 and
> Apache2 on SuSE Linux 8.2), enable-trans-sid and track-vars options
> are on, so it should work. Quite strange, but {echo SID} prints
> nothing, although { echo session_ID() } prints long cryptic string. I
> have some other PHP programs installed on my server, but they working
> without problem header("Location:script.php?".SID) without cookies (my
> app should work without cookies enabled in browser).
>
> Any have an idea what I did wrong?
>
> Thanks in advance for any suggestion.
>
>
> On Tuesday, May 6, 2003, at 04:04 PM, George Whiffen wrote:
>
>> Andrei,
>>
>> Why is header() a problem?
>>
>> If it is just that you cannot use it after having sent output then
>> there are two solutions:
>>
>> 1. The proper solution
>> Change your code so that you check if you want a "redirect" before
>> generating any output. In general you should only generate actual
>> "output" at the end of your php script after executing any logic not
>> directly associated with output. In particular anything that could
>> cause an error or a change in the page you want to go should be
>> handled before worrying about to output. This separation of
>> processing and representation, (output), should make your php much
>> easier to understand and change.
>>
>> 2. The quick fix
>> If you switch output buffering on, then the restriction on
>> redirecting before generating output does not apply. See ob_start()
>> in the PHP manual.
>
>
>
>
> *********************************************
> * Best Regards --- Andrei Verovski
> *
> * Personal Home Page
> * http://snow.prohosting.com/guru4mac
> * Mac, Linux, DTP, Development, IT WEB Site
> *********************************************
>
>
attached mail follows:
> How are you doing validation? With PHP or Javascript?
PHP
> There's nothing wrong with your method, but it's harder to maintain as a
> change in one area must be supported with a change in another.
As does your method - the difference being that my method requires 2 changes
and yours requires 3, which makes mine easier to maintain and update, and is
why I wrote it this way.
> For instance, if you add a field to your form, you must now add it to your
> database or you must strip out the value before you "create" your SQL. So
> your presentation affects your logic, instead of the two being separate.
Since the whole purpose of the form is to gather data to input into a
database, my method is much easier to maintain. I just add the field to the
form and add the field to the database. I never have to touch the query as
it will automatically pick up the new form input. There will never be a
field in this form that isn't entered into the database.
> If you explicity wrote out your query, then changes in your form or
> presentation wouldn't affect the PHP code with your query.
This method adds one more step. Now I have to write out a seperate query for
the newly added form input, making my method more efficient to maintain.
Which is what I am talking about when I say efficiency.
> Either way, as long as your validating everything prior to this on the
> server side, use whatever method you want.
>
> I always place all of my validated variables into another array. You could
> then use your method on this new array. The reason I do this is so that I
> only use validated variables in queries, output, and links later in the
> code. I don't use the $_GET, $_POST variables directly as they may be
> tainted.
> ---John Holmes...
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
If I remember my elementary CS properly, a loop is ALWAYS less
efficient than a series of iterative statements. To illustrate, for the
array:
<? $ARRAY = array("a" => 1, "b" => 2, "c" => 3); ?>
...an example loop would look like this:
<?
foreach ($ARRAY as $key=>$val)
{
echo "$key: $val\n";
}
?>
Now, the same code expanded into a series of statements:
<?
echo "a: " . $ARRAY["a"] . "\n";
echo "b: " . $ARRAY["a"] . "\n";
echo "c: " . $ARRAY["a"] . "\n";
?>
At runtime, code is broken down into smaller statements, optimized, and
then executed sequentially. If we break down the loop into a series of
PHP statements, we come up with the following:
<?
while ()
{
$key = key($ARRAY); // Statement 1
$val = current($ARRAY); // Statement 2
echo "$key: $val\n"; // Statement 3
$next = next($ARRAY); // Statement 4
if ($next == "") break; // Statement 5
}
?>
Compare these 5 statements, which make up one iteration, to one
iteration written by hand:
<?
echo "a: " . $ARRAY["a"] . "\n";
?>
In other words, by writing the loop out by hand, you eliminate
everything but Statement 3. MUCH less overhead.
Granted, internal optimizations make it very unlikely that the simple
loop at the top of this email would be equivalent to the 5 statements
above in terms of efficiency, but the point is that loops add at least
two or three statements per iteration. Add that up over thousands of
iterations, and you will start to notice a difference in execution time.
The main drawback to expanding loops, however, is that it increases the
size of your code. So there's a tradeoff between the extra statement
overhead during runtime and the extra disk space overhead simply for
storing the file.
Morgan
On Wednesday, May 7, 2003, at 07:00 AM, C.R. wrote:
> "And the solution is... Don't try be so lazy/cute! Specify the mysql
> fields explicitly i.e."
>
> How about efficient!. This may be a point of view, but I think the way
> I
> have it is more efficient and easier to understand than having to sift
> through a whole list of queries - and why not share forms if they are
> the
> same - seems like a more efficient way of doing things to me. However,
> I
> have found with PHP that efficient is not in it's vocabulary. (how
> will you
> ever do field-specific validation?). I'm not sure about this comment
> as all
> my forms validate fine and is done before it ever gets to this point
> in the
> script.
>
> Anyway, thanks for the input. At least I know the problem and can now
> try to
> figure a way around it. If I have to type them all in, I guess I'll
> have
> to - but this really seems to be a waste of time and effort.
>
>
> ----- Original Message -----
> From: "George Whiffen" <george
whiffen.net>
> To: <php-general
lists.php.net>
> Sent: Tuesday, May 06, 2003 8:12 AM
> Subject: [PHP] Re: Forms
>
>
>>
>>
>> C.R. wrote:
>>> I'm trying to use an image as a submit button in a form and getting
>>> some
>>> stupid error I just can't figure out. I have four seperate forms on
>>> my
> site
>>> and 3 of them work and one doesn't. I have copied and pasted the
>>> input
> line
>>> so they are the same in all four, so I am at a loss.
>>>
>>> This is the line....
>>>
>>> <INPUT TYPE="image" src="images/arrow-r.gif" width="56" height="24"
>>> border="0">
>>>
>>
>> You are specifying an image map, not just an image button. That means
>> that the x,y coordinates of the mouse in "images/arrow-r.gif" when it
>> is
>> clicked are being sent as part of the form.
>>
>> Normally, you would specify a name for the image map e.g. <INPUT
>> TYPE="image" NAME="myname", in which case the coordinates would be in
>> $mynamex and $mynamey. As you have no name, the coordinates are just
>> in
>> $x and $y.
>>
>> Your script is trying to store these variables in your mysql table
>> which
>> is complaining that it doesn't have a field called x or y.
>>
>> And the solution is... Don't try be so lazy/cute! Specify the mysql
>> fields explicitly i.e.
>>
>> replace
>>
>>
>>> $query = "UPDATE $userinfotable SET ";
>>> foreach($_POST as $field=>$value) {
>>> $upfields[] = "$field='$value'";
>>> }
>>> $sqlfields = implode($upfields,",");
>>> $query .= $sqlfields. " WHERE userid = '$userid'";
>>>
>>
>> with
>>
>> $query = "UPDATE $userinfotable set
>> myfield1 = '$myfield1'
>> ,myfield2='$myfield2'
>> ...
>> WHERE userid = '$userid'";
>>
>> etc.
>>
>> I guess you wanted to only have to change your form and table when you
>> add extra fields and leave the code to automatically generate the
>> query
>> from the fields specified. The problem is that you have created a
>> restriction on your form i.e. it must only ever submit fields in the
>> database, so you can't use TYPE="image" or extra hidden variables or
>> indeed anything except fields that are definitely in your table.
>>
>> This is a bad idea in principle since you are creating a potentially
>> fatal code/representation dependency.
>>
>> It really doesn't take much extra work to actually TYPE the names of
>> the
>> fields, and since you already have to change the table and the form
>> for
>> new fields it doesn't add much maintenance overhead.
>>
>> Or perhaps you were trying to share the php code between several
>> forms/tables. Sounds pretty iffy to me, (how will you ever do
>> field-specific validation?). But if you really, really want this kind
>> of general technique then you should use the mysql table definition to
>> cross-check the list of fields to update rather than just the list of
>> POSTed variables.
>>
>> i.e. something like this
>>
>> $fieldpointer = mysql_list_fields($database,$userinfotable);
>>
>> while ($fieldname = mysql_fieldname($fieldpointer))
>> {
>> $dbfields[] = $fieldname;
>> }
>> and then
>>
>> $query = "UPDATE $userinfotable SET ";
>> foreach($_POST as $field=>$value) {
>>
>> if (in_array($field,$dbfields)
>> {
>> $upfields[] = "$field='$value'";
>> }
>>
>> }
>> $sqlfields = implode($upfields,",");
>> $query .= $sqlfields. " WHERE userid = '$userid'";
>>
>> This would work, although it will be slightly slower because of the
>> overhead of picking up the mysql field list.
>>
>> It removes the immediate problem of image maps, but it still leaves
>> representation/code dependencies. For example, you can't use your
>> code
>> to process "GET" update requests or command line (environment
>> variable)
>> requests automatically for you, since you are dependent on data
>> coming
>> via the "POST". If you try to get round that by you skipping the
>> foreach ($_POST... and just using the mysql field list, you will
>> probably update too much since you will be updating every field
>> including userid and any timestamps or fields not in the form.
>>
>> So my advice is to keep it simple, and just name the fields in the
>> query. In that case, your php doesn't have to know or care where the
>> data came from, POST, GET, Environment, whatever. It will also be much
>> easier for someone else to understand and maintain your code; more
>> flexible, (you can easily add field specific processing e.g. myfield =
>> '".strtoupper($myfield1."'), and less likely to break with "stupid
>> errors you can't work out".
>>
>> Good luck,
>>
>>
>> George
>>
>>
>>
>>> but .....this will work.
>>>
>>> <INPUT TYPE="submit" value="Submit">
>>>
>>> This is being sent to a PHP script which will then write the form
>>> info
> to a
>>> MySQL database - the error I am getting is this:
>>>
>>> Unknown column 'x' in 'field list'.
>>>
>>> So where is it getting the column 'x' from?
>>>
>>> This is the top of the form on all four forms (other than the ACTION
>>> =
> and
>>> FORM NAME).
>>>
>>> <FORM NAME="Update Profile" Target"contentFrame"
>>> ACTION="editcheck.php"
>>> METHOD="POST" CLASS="formstyle">
>>>
>>> The only thing I can think of that is causing the problem is the
> following,
>>> but I have no idea why. Any help is appreciated.
>>>
>>> $query = "UPDATE $userinfotable SET ";
>>> foreach($_POST as $field=>$value) {
>>> $upfields[] = "$field='$value'";
>>> }
>>> $sqlfields = implode($upfields,",");
>>> $query .= $sqlfields. " WHERE userid = '$userid'";
>>>
>>>
>>
>>
>> --
>> 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
>
attached mail follows:
I just accomplished this with FreeTDS, note that I had to use
--with-sybase and not --with-mssql (when --with-mssql was used the
connect functions did not return a valid mssql connection). After I
compiled with --with-sybase=/path/to/freetds I was able to use the mssql
functions and the sybase functions.
Take a look at the user contributed notes on
http://www.php.net/manual/en/ref.sybase.php.
The first thing you need to do is get freetds compiled and installed
(FreeTDS's manual covers this pretty well). After you install FreeTDS
make sure you can use the FreeTDS client to connect to your server,
after that it's pretty much in the bag..
Jason
H M Kunzmann wrote:
>Hi all.
>
>If this question has featured on the list before, I
>do apologize. I've just joined the list out of desperation.
>
>I need to have access to mmsql from php/linux.
>
>Previously I used to us freetds with php, but since
>redhat 9 I just can't get the stuff to compile/work.
>I keep on getting sybase compile errors from php.
>
>Does anyone have another way to do it (odbc?) or can
>anyone help me with getting it up and running with freetds.
>
>Thanks in advance.
>
>
>
attached mail follows:
On Wed, 2003-05-07 at 15:23, Jason Sheets wrote:
> I just accomplished this with FreeTDS, note that I had to use
> --with-sybase and not --with-mssql (when --with-mssql was used the
> connect functions did not return a valid mssql connection). After I
> compiled with --with-sybase=/path/to/freetds I was able to use the mssql
> functions and the sybase functions.
>
> Take a look at the user contributed notes on
> http://www.php.net/manual/en/ref.sybase.php.
>
> The first thing you need to do is get freetds compiled and installed
> (FreeTDS's manual covers this pretty well). After you install FreeTDS
> make sure you can use the FreeTDS client to connect to your server,
> after that it's pretty much in the bag..
I've got a freetds rpm, that installs the freetds libraries
into /usr/lib
I've tried compiling php with --with-sybase=/usr/lib, but I
get loads of errors along the line of the following:
-c php_sybase_db.c && touch php_sybase_db.lo
php_sybase_db.c:38:22: sybfront.h: No such file or directory
It gets these errors when it tries to compile the /ext/sybase
directory.
Do you have any sybase libraries other than freetds installed ?
Any ideas ? Thanks for any help you can offer
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQA+uRZA6+7+TmiwxEkRArCCAKC7O5M5TmlOMFnGf5pbdu7VDb2zmQCZATmu
dqjroYy7WyASMfiHvkjmIQU=
=1/o7
-----END PGP SIGNATURE-----
attached mail follows:
I have just installed Red hat Linux 9 (Shike). I removed the php and httpd (apache) rpm packages with rpm -e. I have compiled and built Apache httpd version 2.0.45 without problems. I followed the instructions from the php documentation:
..snip..
10. ./configure --with-apxs2=/usr/local/apache2/bin/apxs
11. make
And get this error message (compiling php 4.3.1) :
/home/mysql/php-4.3.1/ext/mysql/libmysql/my_lib.c:588: undefined reference to `errno'
ext/mysql/libmysql/my_malloc.lo(.text+0xde): In function `my_malloc':
/home/mysql/php-4.3.1/ext/mysql/libmysql/my_malloc.c:24: undefined reference to `errno'
ext/mysql/libmysql/my_realloc.lo(.text+0xd5): In function `my_realloc':
/home/mysql/php-4.3.1/ext/mysql/libmysql/my_realloc.c:44: undefined reference to `errno'
ext/mysql/libmysql/my_delete.lo(.text+0x86): In function `my_delete':
/home/mysql/php-4.3.1/ext/mysql/libmysql/my_delete.c:16: undefined reference to `errno'
ext/mysql/libmysql/my_tempnam.lo(.text+0x89):/home/mysql/php-4.3.1/ext/mysql/libmysql/my_tempnam.c:108: more undefined references to `errno' follow
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
Any ideas?
Thanks
Jeremy
attached mail follows:
Can someone explain session_start() as I am still don't have a full grasp of
sessions. In the following example I have to use session_start() on both of
the pages below, but once a session is started why would I need to do this -
does it not carry from page to page? - confused.
page-a.php example:
session_start(};
if($_SESSION['loggedin']) { echo "You are already logged in"; }
else {
*** the login form appears here ***
<FORM NAME="Login" ACTION="page-b.php" METHOD="post">
.....etc....
}
page-b.php example;
*** code to validate input ***
if input is correct....
session_start();
$_SESSION['loggedin'] = "True";
$_SESSION['email'] = $row['email'];
$_SESSION['names'] = $row['firstname']." ".$row['lastname'];
attached mail follows:
Hi,
Need some help:
Something is wrong in my configuration.{PHP4.3.1, Apache}
After processing a form, this is the error message given:
Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or
custom "From:" header missing in ...
As from echo-testing, I can see all parameters needed to send mail, so it
isn't the From Header.
Also the function mail() is used correctly: mail($recipient, $finalSubject,
$content, $addlHeaders);
Rob
attached mail follows:
Try this article:
http://www.devshed.com/Server_Side/PHP/ExtensibleMenuClass/page1.html
I think you mean menus such as the ones done at
http://www.palm.com/products/ (on left side navigation)
These are done with javascript, but you could use php load in the values
of the menus from a database query or file or xml document, etc...
On Tue, 2003-05-06 at 15:56, Denis L. Menezes wrote:
> Hello friends.
>
> Can anyone guide me to some tutorials on making dynamic menu/trees using PHP?
>
> Thanks
> Denis
attached mail follows:
Hi Denis,
This is also a good site for dynamic menu's and PHP
http://phplayersmenu.sourceforge.net/
Regards,
Frank
----- Original Message -----
From: "Denis L. Menezes" <menezesd
singnet.com.sg>
To: "PHP general list" <php-general
lists.php.net>
Sent: Tuesday, May 06, 2003 9:56 PM
Subject: [PHP] PHP and dynamic menus
Hello friends.
Can anyone guide me to some tutorials on making dynamic menu/trees using
PHP?
Thanks
Denis
attached mail follows:
Hi,
I am new to PHP and MySQL and iw as wondering if anyone could suggest how to
do the following. I am successfully pulling data from my database and
presenting it in alternately coloured rows with the code below. I want the
data in the sdate field to have links which pass data to a template page so
it is populated by the info in that database row. I hope that makes sense.
If anyone can help i would be most grateful. The code i have is below.
mysql_select_db("mydata") or die("Unable to select database");
$query = "SELECT * FROM speech1999 ORDER BY userid";
$result = mysql_query($query) or die ("Query failed");
//let's get the number of rows in our result so we can use it in a for loop
$numofrows = mysql_num_rows($result);
?>
<?PHP
echo "<TABLE WIDTH=\"100%\" BORDER=\"1\">\n";
echo "<TR bgcolor=\"#47106E\"><TD><font color=\"#FFFFFF\"><b>Speech
Date</b></font></TD><TD><font
color=\"#FFFFFF\"><b>Topic</b></font></TD></TR>\n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($result); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo "<TR bgcolor=\"#FFF2CE\">\n";
} else { //if there isn't a remainder we will do the else
echo "<TR bgcolor=\"white\">\n";
}
echo "<TD>".$row['sdate']."</TD><TD>&q