OSEC

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-help_at_lists.php.net
Date: Fri Jan 10 2003 - 05:45:23 CST

  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

    php-general Digest 10 Jan 2003 11:45:23 -0000 Issue 1814

    Topics (messages 131016 through 131090):

    Re: flash and php (using the varibles)
            131016 by: rolf vreijdenberger

    Re: php stored in mysql
            131017 by: Timothy Hitchens \(HiTCHO\)

    HEEELP...please
            131018 by: pippo.bellnet.ca
            131019 by: Timothy Hitchens \(HiTCHO\)
            131020 by: Greg Beaver
            131021 by: Philip Hallstrom

    Re: How can I redirect to another php page
            131022 by: Tommy Jensehaugen
            131025 by: Jason Sheets

    Re: checkboxes, radio buttons and $_POST['<name>']
            131023 by: Tom Rogers

    Posting data using fsockopen() causes session problem
            131024 by: Max Davy

    mysql_num_rows() error
            131026 by: Phil Powell
            131028 by: Jay \(PHP List\)
            131029 by: Sean Malloy
            131042 by: Mark Charette

    Session Expiration?
            131027 by: Matias Silva
            131040 by: Jason Sheets

    Re: Connection pool extension?
            131030 by: michael kimsal

    Medium to Large PHP Application Design
            131031 by: Nick Oostveen
            131035 by: michael kimsal
            131038 by: Timothy Hitchens \(HiTCHO\)
            131057 by: rush

    Converting Excel Spreadsheet to MySQL table ...
            131032 by: Adam Ferguson
            131039 by: Timothy Hitchens \(HiTCHO\)
            131085 by: Maxim Maletsky
            131089 by: rblack.datavisibility.co.uk

    Re: newbee
            131033 by: Larry Brown

    something annoying about includes/relative paths.
            131034 by: Sean Malloy
            131036 by: michael kimsal
            131088 by: Maxim Maletsky

    func_get_args...
            131037 by: Sean Malloy
            131044 by: Sean Malloy

    PostgreSQL/PHP: transactions: how-to abstract out?
            131041 by: Jean-Christian Imbeault
            131043 by: Jason Sheets
            131048 by: Jean-Christian Imbeault
            131049 by: Ray Hunter
            131050 by: Ray Hunter
            131054 by: Jean-Christian Imbeault

    searching for string inside document
            131045 by: Martin Hudec
            131046 by: Timothy Hitchens \(HiTCHO\)
            131047 by: Timothy Hitchens \(HiTCHO\)
            131086 by: Maxim Maletsky

    Is this possible with php?
            131051 by: try.neasys.com
            131052 by: Timothy Hitchens \(HiTCHO\)
            131055 by: Tom Rogers
            131084 by: Maxim Maletsky

    Re: apache and php
            131053 by: Submission.org.ru Team

    Re: session not set, server configuration?
            131056 by: James Tan

    fsockopen() to remote URL: what if remote URL "times out"?
            131058 by: Phil Powell
            131082 by: Maxim Maletsky

    Re: calculate the traffic size with php(like the apache access_log)
            131059 by: Torsten Rosenberger

    Re: calculate the traffic size with php(like the apache
            131060 by: Jean-Christian Imbeault

    Re: how to passing two dimension array
            131061 by: Noel Wade
            131065 by: - Edwin

    checking status of a HTML checkbox
            131062 by: Shams
            131063 by: - Edwin
            131067 by: Shams

    Re: building web album - design questions
            131064 by: Daevid Vincent

    Column size, user input and htmlspecialchars
            131066 by: Jim
            131070 by: - Edwin

    Re: undefined variable notice - how to furn of
            131068 by: Philippe Saladin

    how can I use an external 'template' file and still use PHP variables?
            131069 by: Daevid Vincent
            131071 by: Benjamin Niemann
            131073 by: - Edwin
            131078 by: Noel Wade
            131080 by: Maxim Maletsky

    version switch problem
            131072 by: Christian Stalberg
            131074 by: Jean-Christian Imbeault
            131081 by: Maxim Maletsky

    Too many open files
            131075 by: Macrosoft
            131076 by: Rus Foster

    Re: how to make server response to emails
            131077 by: See kok Boon

    gd library
            131079 by: Jorge Miguel Fonseca Martins

    Re: fletcher's checksum
            131083 by: Ford, Mike [LSS]

    Re: Auto Include a Function
            131087 by: Justin French

    Re: Databases vs. File Access
            131090 by: Justin French

    Administrivia:

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

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

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

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

    attached mail follows:


    in flash:

    ----
    result=null;
    URL=" myscript.php"
    loadVariables(URL, myobject, "POST")//flash 5, MX has better capabilities
    gotoAndPlay("checkframe")
    ----
    well, you get a name/value pair from the script.
    the script ran some queries on the database.
    teh output from the script to flash is:
    &mynumber=123&result=true&
    Ok, in flash, in the "checkFrame" you check for a result variable
    ---
    if(result=="true"){
    //watch out, true is a string in flash, even if it is a boolean in php
    //take some action
    }elseif(result=="false"){
    //ooops, error, output error message
    }
    

    capiche?

    > Hi guys i hope there is someone in here that use flsah along with php to > help with this :) > > Anyway i will make it simple. > > mysql returns a number say 123 i want flash to take this number to animate a > progress bar, but here the problem it does work but the progress bar dosn't > animate it just sets to the hieght of the numbers sent back from mysql. How > can i slow down the animation of the progress bar > > Anyone > >

    attached mail follows:


    Please be aware that eval code is extremely hard to debug!!

    Timothy Hitchens (HiTCHO) Open Platform Consulting e-mail: timhitcho.com.au

    > -----Original Message----- > From: Paul Roberts [mailto:mailpaul-roberts.com] > Sent: Friday, 10 January 2003 9:33 AM > To: php-generallists.php.net > Subject: Re: [PHP] php stored in mysql > > > I should have used > > return($price = $price - ($price *.1)); in the db > > and eval($str); > > Best Wishes & Happy New Year > > Paul Roberts > mailpaul-roberts.com > ++++++++++++++++++++++++ > > ----- Original Message ----- > From: "Paul Roberts" <mailpaul-roberts.com> > To: <php-generallists.php.net> > Sent: Thursday, January 09, 2003 10:29 PM > Subject: [PHP] php stored in mysql > > > Hi > > I want to store some discount codes in mysql, i was thinking > of putting > > $price = $price - ($price *.i); > > in a mysql field that can be looked up via the coupon number > > what's the best way to do this and return $price with the > discount applied. > > Thanks > > Best Wishes & Happy New Year > > Paul Roberts > mailpaul-roberts.com > ++++++++++++++++++++++++ > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    I absolutely cannot understand the include_path directive. Can somebody, please, explain this? I have a situation that I find absolutely incomprehensible: I moved my experimental web-site from FreeBSD 4.5 running php4 v. 4.0 (or something), apache 1.13 where thesite worked just fine to another box with FreeBSD 4.7 running php4 v. 4.2.3, apache 1.13.27_1. All of a sudden, I get the message: Warning: Failed opening '/../lib/somefile.conf' for inclusion (include_path='.:/usr/local/lib/php') in /usr/local/www/html/index.php on line 6

    I can find nothing in the httpd.conf files that could account for this; there is no configuration in them for include_path.

    Obviously, the php file is being parsed correctly, but there is a problem with the line : include "$DOCUMENT_ROOT/../lib/somefile.conf".

    It works on one machine, but not on the latest version of php4 an apache.

    I see there are others on the net who have had this problem, but I have not yet found an explanation or a cure.

    HEEEEELP.... please,

    PJ

    attached mail follows:


    You can get away without a include path set by ensuring that the path is absolute eg:

    If you have your data for your website as with FreeBSD in /usr/local/www/data/ you then do the following to include:

    ** assume you have a "lib" directory in the /data/ area ** moving from platform to platform always has some impact on includes!!

    include('/usr/local/www/data/lib/somefile.conf');

    I hope this helps... the other way is to set the include paths etc!!

    Timothy Hitchens (HiTCHO) Open Platform Consulting e-mail: timhitcho.com.au

    > -----Original Message----- > From: pippobellnet.ca [mailto:pippobellnet.ca] > Sent: Friday, 10 January 2003 11:00 AM > To: php-generallists.php.net > Subject: [PHP] HEEELP...please > > > I absolutely cannot understand the include_path directive. > Can somebody, please, explain this? > I have a situation that I find absolutely incomprehensible: I > moved my > experimental web-site from FreeBSD 4.5 running php4 v. 4.0 > (or something), > apache 1.13 where thesite worked just fine to another box > with FreeBSD 4.7 > running php4 v. 4.2.3, apache 1.13.27_1. > All of a sudden, I get the message: > Warning: Failed opening '/../lib/somefile.conf' for inclusion > (include_path='.:/usr/local/lib/php') in > /usr/local/www/html/index.php on > line 6 > > I can find nothing in the httpd.conf files that could account > for this; > there is no configuration in them for include_path. > > Obviously, the php file is being parsed correctly, but there > is a problem > with the line : > include "$DOCUMENT_ROOT/../lib/somefile.conf". > > It works on one machine, but not on the latest version of > php4 an apache. > > I see there are others on the net who have had this problem, > but I have not > yet found an explanation or a cure. > > HEEEEELP.... please, > > PJ > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    $DOCUMENT_ROOT is now $_SERVER['DOCUMENT_ROOT'] unless register_globals is on.

    You need

    include $_SERVER['DOCUMENT_ROOT'].'/../lib/somefile.conf';

    take care, Greg

    --
    phpDocumentor
    http://www.phpdoc.org
    

    <pippobellnet.ca> wrote in message news:5.1.0.14.2.20030109194115.00b32880mail.host45.com... > I absolutely cannot understand the include_path directive. > Can somebody, please, explain this? > I have a situation that I find absolutely incomprehensible: I moved my > experimental web-site from FreeBSD 4.5 running php4 v. 4.0 (or something), > apache 1.13 where thesite worked just fine to another box with FreeBSD 4.7 > running php4 v. 4.2.3, apache 1.13.27_1. > All of a sudden, I get the message: > Warning: Failed opening '/../lib/somefile.conf' for inclusion > (include_path='.:/usr/local/lib/php') in /usr/local/www/html/index.php on > line 6 > > I can find nothing in the httpd.conf files that could account for this; > there is no configuration in them for include_path. > > Obviously, the php file is being parsed correctly, but there is a problem > with the line : > include "$DOCUMENT_ROOT/../lib/somefile.conf". > > It works on one machine, but not on the latest version of php4 an apache. > > I see there are others on the net who have had this problem, but I have not > yet found an explanation or a cure. > > HEEEEELP.... please, > > PJ > > > > >

    attached mail follows:


    Is register_globals on or off? If it's off on the new machine that explains why $DOCUMENT_ROOT is evaluating to "" which would produce the error message you are getting...

    On Thu, 9 Jan 2003 pippobellnet.ca wrote:

    > I absolutely cannot understand the include_path directive. > Can somebody, please, explain this? > I have a situation that I find absolutely incomprehensible: I moved my > experimental web-site from FreeBSD 4.5 running php4 v. 4.0 (or something), > apache 1.13 where thesite worked just fine to another box with FreeBSD 4.7 > running php4 v. 4.2.3, apache 1.13.27_1. > All of a sudden, I get the message: > Warning: Failed opening '/../lib/somefile.conf' for inclusion > (include_path='.:/usr/local/lib/php') in /usr/local/www/html/index.php on > line 6 > > I can find nothing in the httpd.conf files that could account for this; > there is no configuration in them for include_path. > > Obviously, the php file is being parsed correctly, but there is a problem > with the line : > include "$DOCUMENT_ROOT/../lib/somefile.conf". > > It works on one machine, but not on the latest version of php4 an apache. > > I see there are others on the net who have had this problem, but I have not > yet found an explanation or a cure. > > HEEEEELP.... please, > > PJ > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    If you choose to use header("Location: yellow.php"); it might be useful to add an exit; statement after it. I have experienced that if I use more header(..) function calls in one page, it can skip the first ones. Don't know why, but with the exit; statement your are sure:

    if ($Color == "Yellow") { header( "Location: yellow.php" ); exit; else if ($Color == "Green") header( "Location: green.php" ); exit; }

    tommy

    "Teo Petralia" <t.mattiozziauckland.ac.nz> wrote in message news:v04220802ba423dc4c316[130.216.229.11]... > Hi All! > I would like to redirect the user to another php page accordingly to > his/her chosen options, example: > if ($Color == "Yellow") { > go to page .... > else if ($Color == "Green") > go to page .... > } > > Does anyone knows how to achieve the goal?? > > Thanks > > Teo

    attached mail follows:


    You should always use the exit after a redirect, the browser is not required to go to the new location.

    If you do not exit your script after you redirect and the browser does not go to the new location you risk the unintended continued execution of your script.

    Jason

    On Thu, 2003-01-09 at 18:30, Tommy Jensehaugen wrote: > If you choose to use > header("Location: yellow.php"); > it might be useful to add an exit; statement after it. I have experienced > that if I use more header(..) function calls in one page, it can skip the > first ones. Don't know why, but with the exit; statement your are sure: > > if ($Color == "Yellow") { > header( "Location: yellow.php" ); > exit; > else if ($Color == "Green") > header( "Location: green.php" ); > exit; > } > > tommy > > > "Teo Petralia" <t.mattiozziauckland.ac.nz> wrote in message > news:v04220802ba423dc4c316[130.216.229.11]... > > Hi All! > > I would like to redirect the user to another php page accordingly to > > his/her chosen options, example: > > if ($Color == "Yellow") { > > go to page .... > > else if ($Color == "Green") > > go to page .... > > } > > > > Does anyone knows how to achieve the goal?? > > > > Thanks > > > > Teo > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

    attached mail follows:


    Hi,

    Friday, January 10, 2003, 4:25:00 AM, you wrote: JEO> Hi

    JEO> HELP!!!

    JEO> I have read through the manual about using $_POST['<name>'] to retrieve JEO> data from forms, but what happens when a form element is not filled in JEO> or checked?

    JEO> If I have a checkbox on a form called "chk1" I get an error from PHP JEO> when I try this: JEO> $chk1 = $_POST['chk1']; // error if user did not chech the checkbox on JEO> the form!!!

    JEO> How do ya usefully retrieve the fact that a form element has not been JEO> filled in/checked?

    JEO> Be Well,

    JEO> John-Erik Omland

    JEO> ====================================

    JEO> "Rhythm is the basis of life, JEO> not steady forward progress. JEO> The forces of creation, destruction, and preservation JEO> have a whirling, dynamic interaction." JEO>                                         - Kabbalah

    Do it like this:

    $chk1 = (isset($_POST['chk1']))? $_POST['chk1'] : 'No';

    replace 'No' with whatever you want for an unchecked box

    -- 
    regards,
    Tom
    

    attached mail follows:


    Hi,

    I finally figured out how to use fsockopen() to post data when my server responded with a Document Moved error.

    I knew the document was where I said it was ... After many hours I realised that the location the document had allegedly been moved to was the login screen that the user would be redirected to if they did not have a valid session id.

    I removed the session handling and ... success!

    This is not an acceptable solution because I need the session to be valid.

    Any help would be most appreciated.

    Thanks,

    Max

    --
    

    Oz Impact Multimedia Innovate, Immerse, Inspire

    www.ozimpact.com

    attached mail follows:


    > Anyone know why this is happening? I have mySQL on Win2000 Server with IIS > and PHP: > > mysql_num_rows(): supplied argument is not a valid MySQL result resource > > Here is my code: > > <? > $conn = mysql_connect('localhost', "xxx", "yyy") or die('Could not connect > to db'); > $result = mysql_query('select * from blah'); > echo "Number of rows: " . mysql_num_rows($result); > if (mysql_num_rows($result) > 0) { > while ($row = mysql_fetch_row($result)) { > for ($i = 0; $i < sizeOf($row); $i++) { > echo "$i: " . $row[$i] . "<BR>"; > } > } > } > ?> > > It couldn't get any simpler. I just installed mySQL on my machine and am > trying to see what I can do with it giving Win2K and IIS. > > AUGH! Thanx > Phil >

    attached mail follows:


    You query is incorrect. Try doing the same query from the MySQL clent.

    |-> -----Original Message----- |-> From: Phil Powell [mailto:soazineerols.com] |-> Sent: Thursday, January 09, 2003 7:46 PM |-> To: php-generallists.php.net; talknyphp.org |-> Subject: [PHP] mysql_num_rows() error |-> |-> |-> > Anyone know why this is happening? I have mySQL on |-> Win2000 Server with |-> > IIS and PHP: |-> > |-> > mysql_num_rows(): supplied argument is not a valid MySQL result |-> > resource |-> > |-> > Here is my code: |-> > |-> > <? |-> > $conn = mysql_connect('localhost', "xxx", "yyy") or |-> die('Could not |-> connect |-> > to db'); |-> > $result = mysql_query('select * from blah'); |-> > echo "Number of rows: " . mysql_num_rows($result); |-> > if (mysql_num_rows($result) > 0) { |-> > while ($row = mysql_fetch_row($result)) { |-> > for ($i = 0; $i < sizeOf($row); $i++) { |-> > echo "$i: " . $row[$i] . "<BR>"; |-> > } |-> > } |-> > } |-> > ?> |-> > |-> > It couldn't get any simpler. I just installed mySQL on |-> my machine and |-> > am trying to see what I can do with it giving Win2K and IIS. |-> > |-> > AUGH! Thanx |-> > Phil |-> > |-> |-> |-> -- |-> PHP General Mailing List (http://www.php.net/) |-> To unsubscribe, visit: http://www.php.net/unsub.php |-> |->

    attached mail follows:


    Are you actually checking that the query result is valid?

    $conn = mysql_connect('localhost', "xxx", "yyy") or die('Could not connect to db'); $result = mysql_query('select * from blah', $conn); if ($result) { echo "Number of rows: " . mysql_num_rows($result); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_row($result)) { for ($i = 0; $i < sizeOf($row); $i++) { echo "$i: " . $row[$i] . "<BR>"; } } } } else { echo mysql_error($conn); }

    -----Original Message----- From: Phil Powell [mailto:soazineerols.com] Sent: Friday, 10 January 2003 1:46 PM To: php-generallists.php.net; talknyphp.org Subject: [PHP] mysql_num_rows() error

    > Anyone know why this is happening? I have mySQL on Win2000 Server with IIS > and PHP: > > mysql_num_rows(): supplied argument is not a valid MySQL result resource > > Here is my code: > > <? > $conn = mysql_connect('localhost', "xxx", "yyy") or die('Could not connect > to db'); > $result = mysql_query('select * from blah'); > echo "Number of rows: " . mysql_num_rows($result); > if (mysql_num_rows($result) > 0) { > while ($row = mysql_fetch_row($result)) { > for ($i = 0; $i < sizeOf($row); $i++) { > echo "$i: " . $row[$i] . "<BR>"; > } > } > } > ?> > > It couldn't get any simpler. I just installed mySQL on my machine and am > trying to see what I can do with it giving Win2K and IIS. > > AUGH! Thanx > Phil >

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

    attached mail follows:


    And which database are you using?? (hint - mysql_select_db() might be a good idea ...)

    > -----Original Message----- > From: Phil Powell [mailto:soazineerols.com] > > Anyone know why this is happening? I have mySQL on Win2000 > Server with IIS > > and PHP: >>

    attached mail follows:


    I have gone through the past posts and can't find an answer to my problem

    I'm using a URL based session management schema, and I was wondering how to set the session duration time. I know there is the session.gc_probability and session.gc_maxlifetime but that's only for garbage collection. Just for testing I set the probability to 100 and the maxlifetime to 60 just to see if my session would automatically expire, as my luck would have it didn't. I use session_start() in my test scripts so that should run with a 100% probability any garbage clean up of any sessions that are 1 minute old.

    I have the session.use_cookies set to 0 and, the session.cookie_lifetime only applies to cookies. So I don't know why my sessions are not expiring. Does anybody have any Idea? Should I just be manually checking for the duration of the session(?) and then delete it if it has expired?

    Best, Matt

    Matt Silva ---------------------------------------------------------------------------- ----------------------------------------- Empower Software Technologies mattstoragecommander.com PH 909.672.6257 FX 909.672.6258

    attached mail follows:


    First are you sure the data was not deleted? If the cookie is still set in your browser a new session file will be created with the same session id.

    I believe you adjust the session gc and the session max lifetime, additionally if you are concerned about someone bookmarking a sessionid or storing it in history take a look at the session.referer_check configuration directive:

    ; 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 =

    Obviously it wont work with some browsers and referer is sent by the client but every little bit helps.

    Jason

    On Thu, 2003-01-09 at 20:09, Matias Silva wrote: > I have gone through the past posts and can't find an answer to my problem > > I'm using a URL based session management schema, and I was wondering how to > set > the session duration time. I know there is the session.gc_probability and > session.gc_maxlifetime but > that's only for garbage collection. Just for testing I set the probability > to 100 and the maxlifetime to 60 > just to see if my session would automatically expire, as my luck would have > it didn't. I use session_start() > in my test scripts so that should run with a 100% probability any garbage > clean up of any sessions > that are 1 minute old. > > I have the session.use_cookies set to 0 and, the session.cookie_lifetime > only applies to cookies. So I don't > know why my sessions are not expiring. Does anybody have any Idea? Should > I just be manually checking > for the duration of the session(?) and then delete it if it has expired? > > Best, > Matt > > > Matt Silva > ---------------------------------------------------------------------------- > ----------------------------------------- > Empower Software Technologies > mattstoragecommander.com > PH 909.672.6257 > FX 909.672.6258 > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

    attached mail follows:


    Vinod Panicker wrote: > Hi, > > Thanks for the quick response - I am aware of PHP's support for sockets, > but since I cant store persistent connection information in a PHP script > I was looking out for a module > > Tx, > Vinod. > > ----------------------------------- > Vinod Panicker <vinodgeodesiconline.com> > Sr. Software Designer > Geodesic Information Systems Ltd. > > > > -----Original Message----- > From: Timothy Hitchens (HiTCHO) [mailto:phplistshitcho.com.au] > Sent: Thursday, January 09, 2003 1:00 PM > To: 'Vinod Panicker'; php-generallists.php.net > Subject: RE: [PHP] Connection pool extension? > > > PHP supports sockets check out: > > http://www.php.net/manual/en/ref.sockets.php > > > Timothy Hitchens (HiTCHO) > Open Platform Consulting > e-mail: timhitcho.com.au > > >>-----Original Message----- >>From: Vinod Panicker [mailto:vinodgeodesiconline.com] >>Sent: Thursday, 9 January 2003 5:31 PM >>To: php-generallists.php.net >>Subject: [PHP] Connection pool extension? >> >> >>Hi, >> >>I was wondering if there is a php extension available that >>allows me to do the following - >> >>1. Connect to a given IP address and port >>2. Allow me to send and receive data from a particular ip and port >>3. Pool the connections so that further requests to the given ip >>and port will reuse the existing connection >> >>Tx, >>Vinod. >> >>----------------------------------- >>Vinod Panicker <vinodgeodesiconline.com> >>Sr. Software Designer >>Geodesic Information Systems Ltd. >>

    Vinod,

    Look for 'SRM' - VL-SRM I think it is. It's a separate daemon that has specific PHP functions to allow PHP to talk to it - it'll hold connections open for you automatically.

    Michael Kimsal http://www.tapinternet.com/php PHP Training Courses 734-480-9961

    attached mail follows:


    As PHP becomes more accepted in the corporate world, it is only logical that larger and more complex applications are going to be developed using it. While there is an abundance of information out there about making specific things work, there seems to be a shortage regarding the big picture.

    As such, my question is this: What methods and techniques can be used to help design and build complex, medium to large PHP applications that are not only scalable, but maintainable and extensible? I'm looking for online references, personal experience and opinion and even examples of open source code which you think demonstrate the above criteria on this one. I think an extended discussion on this topic could be of great benefit to everyone.

    Obviously separating application and business logic from interface code is a given, but what about other things? Are the object orientated facilities of PHP currently worth really trying to take advantage of? If so, what are you doing to take advantage of them? Are design concepts such as design patterns relevant at this level? What frameworks, if any, currently exist to assist in rapid, structured development, and what specific benefits do they bring to the table?

    These are just some of the questions that I'd like to see expanded upon, I'm sure there are others out there who can add more to the list.

    Nick Oostveen

    attached mail follows:


    Nick Oostveen wrote: > As PHP becomes more accepted in the corporate world, it is only logical > that larger and more complex applications are going to be developed > using it. While there is an abundance of information out there about > making specific things work, there seems to be a shortage regarding the > big picture. > > As such, my question is this: What methods and techniques can be used to > help design and build complex, medium to large PHP applications that are > not only scalable, but maintainable and extensible? I'm looking for > online references, personal experience and opinion and even examples of > open source code which you think demonstrate the above criteria on this > one. I think an extended discussion on this topic could be of great > benefit to everyone. > > Obviously separating application and business logic from interface code > is a given, but what about other things? Are the object orientated > facilities of PHP currently worth really trying to take advantage of? If > so, what are you doing to take advantage of them? Are design concepts > such as design patterns relevant at this level? What frameworks, if > any, currently exist to assist in rapid, structured development, and > what specific benefits do they bring to the table? > > These are just some of the questions that I'd like to see expanded upon, > I'm sure there are others out there who can add more to the list. > > Nick Oostveen >

    Hello Mr. Oostveen:

    Is that the same hpmarketing.com that had someone named 'jozef' at it? The domain name looks familiar - like I've seen it in online chats before.

    Anywho...

    Are you only looking for 'open source' (GPL/BSD/etc) frameworks? If not, I'd encourage you to take a look at http://www.logicreate.com/index.php/html/main/developer1.html for a quick overview of our product - feel free to email back or call if you've any questions.

    Now, in general, yes, it's certainly worth thinking about design patterns at this level (whatever 'this' is). There's very few situations where thinking like that *isn't* helpful. Preplanning code projects, coming up with a structure, and other 'niceties' become essential as projects grow and mature to help manage the inevitable complexities which arise. These complexities stem not just from the management of the code itself, but from the growing number of contributors and/or end users whc will be affected by the project as it becomes larger and/or more important.

    There's some discussion about topics of scalability, design patterns, and other similar topics on many websites, but not much on the group here itself. I'd suggest having a look at http://www.phppatterns.com for a start.

    Interesting related tools I came across recently: Umbrello and Microgold.com's UML program. Umbrello (uml.sourceforge.net) is a KDE app, and microgold is a windows app. The microgold, while about $200 (I think ) has the added ability to take preexisting classes and attempt to reverse them into UML diagrams, suitable for giving newcomers to a project a good starting point for understanding a project. Of course, UML is just one facet of a project's development, which isn't even that widely embraced in most circles, but it's becoming quite common in other circles.

    Hope that helps some.

    Michael Kimsal http://www.phpappserver.com 734-480-9961

    attached mail follows:


    Many people develop their own framework which include classes / functions etc. We have build such a framework that includes authentication layers, custom mark-up language, advanced caching for data sets and templated content.

    If you develop your application correctly you can build in caching and replication systems for enterprise operations.

    Timothy Hitchens (HiTCHO) Open Platform Consulting e-mail: timhitcho.com.au

    > -----Original Message----- > From: Nick Oostveen [mailto:nicko-mlhpmarketing.com] > Sent: Friday, 10 January 2003 1:52 PM > To: php-generallists.php.net > Subject: [PHP] Medium to Large PHP Application Design > > > As PHP becomes more accepted in the corporate world, it is > only logical > that larger and more complex applications are going to be > developed using > it. While there is an abundance of information out there > about making > specific things work, there seems to be a shortage regarding > the big picture. > > As such, my question is this: What methods and techniques can > be used to > help design and build complex, medium to large PHP > applications that are > not only scalable, but maintainable and extensible? I'm > looking for online > references, personal experience and opinion and even examples of open > source code which you think demonstrate the above criteria on > this one. I > think an extended discussion on this topic could be of great > benefit to > everyone. > > Obviously separating application and business logic from > interface code is > a given, but what about other things? Are the object > orientated facilities > of PHP currently worth really trying to take advantage of? If > so, what are > you doing to take advantage of them? Are design concepts such > as design > patterns relevant at this level? What frameworks, if any, > currently exist > to assist in rapid, structured development, and what specific > benefits do > they bring to the table? > > These are just some of the questions that I'd like to see > expanded upon, > I'm sure there are others out there who can add more to the list. > > Nick Oostveen > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    "Nick Oostveen" <nicko-mlhpmarketing.com> wrote in message news:5.1.1.6.0.20030109183841.04059e80pop1.hpmarketing.net... > > As such, my question is this: What methods and techniques can be used to > help design and build complex, medium to large PHP applications that are > not only scalable, but maintainable and extensible? I'm looking for online > references, personal experience and opinion and even examples of open > source code which you think demonstrate the above criteria on this one. I > think an extended discussion on this topic could be of great benefit to > everyone. > > Obviously separating application and business logic from interface code is > a given, but what about other things? Are the object orientated facilities > of PHP currently worth really trying to take advantage of? If so, what are > you doing to take advantage of them? Are design concepts such as design > patterns relevant at this level? What frameworks, if any, currently exist > to assist in rapid, structured development, and what specific benefits do > they bring to the table?

    Hello,

    It is not nearly covering all aspects you have asked about but here is some of my expirience.

    I think there is a good usage of object oriented approach when working with PHP. Projects I am working on are using TemplateTamer to separate interface from the appearance from the functionality. Asifde from that it also encourages usage of objects

    First for each page you get php class descirbing it, and on larger projects it commes naturaly to have a few base page classes defining common stuff while each particular page class overides or adds its specifics to it. Base class usually has bells and wistless for sessions, cacheing, translation, general layout etc.

    Second thing that usually happens is that we develop a lot of smaller parts of the page as classes that can be used or refined. For instance various widgets like menus, paged lists, some entity editor, etc.. , they all naturally fit into the classes.

    Third place where it is a good isea to use classes is to access db objects. Generally wrapping a something from the db into the object can be usefull in order to siplify migration to another database, to have good loging, replication etc.

    rush

    --
    http://www.templatetamer.org/
    

    attached mail follows:


    Hello ...

    I was wondering if anyone had a good resource or code sample for opening ( or accessing ) an excel spreadsheet using php. I need to be able to convert a spreadsheet of products and info to a table of products in a mysql database. Also ... I need to be able to perform this on a Linux machine. Any help would be great.

    Thanks guys! Adam Ferguson

    attached mail follows:


    Native Excel.. good luck as it is a binary format.

    If you save it as a CSV version of the document then you have many approaches to this issue.

    Timothy Hitchens (HiTCHO) Open Platform Consulting e-mail: timhitcho.com.au

    > -----Original Message----- > From: Adam Ferguson [mailto:adamadamferguson.com] > Sent: Friday, 10 January 2003 4:05 PM > To: php-generallists.php.net > Subject: [PHP] Converting Excel Spreadsheet to MySQL table ... > > > Hello ... > > I was wondering if anyone had a good resource or code sample > for opening ( or accessing ) an excel spreadsheet using php. > I need to be able to convert a spreadsheet of products and > info to a table of products in a mysql database. Also ... I > need to be able to perform this on a Linux machine. Any help > would be great. > > Thanks guys! > Adam Ferguson >

    attached mail follows:


    Excel on its own is a compiled document. However, I think there was some way to do that. I remember I had to do it for MS Aceess files (Access -> mySQL) and i used a tool made by a brasilian guy, (someone remind me the name). I have the feeling that this is accomplisheable. Not sure if directly on Linux box...

    --
    Maxim Maletsky
    maximphp.net
    

    "Adam Ferguson" <adamadamferguson.com> wrote... :

    > Hello ... > > I was wondering if anyone had a good resource or code sample for opening ( or accessing ) an excel spreadsheet using php. I need to be able to convert a spreadsheet of products and info to a table of products in a mysql database. Also ... I need to be able to perform this on a Linux machine. Any help would be great. > > Thanks guys! > Adam Ferguson

    attached mail follows:


    If this is a one off excercise, ie you only have to do it once and afterwards things will be dealt with ENTIRELY through the MySQL database, you could save the spreadsheet as a CSV file and work with that.

    HTH,

    Richy

    ========================================== Richard Black Senior Developer, DataVisibility Ltd - http://www.datavisibility.com Tel: 0141 951 3481 Email: rblackdatavisibility.co.uk

    Maxim Maletsky <maximphp.net To: "Adam Ferguson" <adamadamferguson.com> > cc: <php-generallists.php.net> Subject: Re: [PHP] Converting Excel Spreadsheet to MySQL table ... 10/01/2003 11:40 Please respond to maxim

    Excel on its own is a compiled document. However, I think there was some way to do that. I remember I had to do it for MS Aceess files (Access -> mySQL) and i used a tool made by a brasilian guy, (someone remind me the name). I have the feeling that this is accomplisheable. Not sure if directly on Linux box...

    --
    Maxim Maletsky
    maximphp.net
    

    "Adam Ferguson" <adamadamferguson.com> wrote... :

    > Hello ... > > I was wondering if anyone had a good resource or code sample for opening ( or accessing ) an excel spreadsheet using php. I need to be able to convert a spreadsheet of products and info to a table of products in a mysql database. Also ... I need to be able to perform this on a Linux machine. Any help would be great. > > Thanks guys! > Adam Ferguson

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

    ________________________________________________________________________ This email has been scanned for all viruses by the MessageLabs SkyScan service. For more information on a proactive anti-virus service working around the clock, around the globe, visit http://www.messagelabs.com ________________________________________________________________________

    attached mail follows:


    Just a thought, set your form to use the get method so that you can see exactly what the php page is receiving. Then before any of your existing code put the first line to "echo $variable;" without the quotes and using one of the variables being sent and visible in the url. The page should then at least show that one variable. If that doesn't work there is some problem with the install I would imagine.

    Larry S. Brown Dimension Networks, Inc. (727) 723-8388

    -----Original Message----- From: Hendrik van Niekerk [mailto:hendrik.vanniekerkcenturytel.net] Sent: Thursday, January 09, 2003 12:58 PM To: php-generallists.php.net Subject: Re: [PHP] newbee

    Joseph

    I can get the errors to go away but then my example just shows a blank page! The variable are not being passed through to the .php doc

    hendrik

    "Joseph W. Goff" <jgoffusers.sourceforge.net> wrote in message news:003201c2b803$ada54f60$bdcaa8c0jg42000... > This is because of the default error reporting setting in the newer version > of php. This was not the case when your book was written. > In your php.ini file set error reporting = E_ALL & ~E_NOTICE and you will > quit getting the 'Undefined Variable' notices. > ----- Original Message ----- > From: "Hendrik van Niekerk" <hendrik.vanniekerkcenturytel.net> > To: <php-generallists.php.net> > Sent: Thursday, January 09, 2003 10:50 AM > Subject: [PHP] newbee > > > > Hi > > > > I'm very new to PHP. (have just bought the book "PHP and MySQL Web > > Deelopment") SAMS authors Luke Welling and Laura Thompson > > > > I working with the examples in the book. > > > > I have loaded MySQL, Apache and PHP onto a NT server. All the test passed > as > > per the examples in the book. > > > > Working with the the first example in chapter one. > > > > I have the HTML document that when the quantities are entered the > > "processorder.php" should be called to show the results and do some calcs. > > > > what happens is that the php file is called but I get an error message: > > > > "Warning: Undefined variable typeqty in C:\apache > > group\apache\htdocs\processorder.php on line 23" > > > > this varialbe is defined in the html document exactly as in the php > > document. > > > > now this warning is repeated for all the variables that should have been > > passed to the php for processing. > > > > What am I missing ? > > > > > > thank you in advance > > > > > > Hendrik van Niekerk > > > > > > > > -- > > 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:


    Moving to PHP from an ASP backgroun, I always found one thing really annoying about PHP.

    With ASP, you could have a file structure such as:

    SYSTEM |--HTML | |--header.asp | |--LOGIC | |--engine.asp | |--core.asp

    in default.asp, you would <!--#include file="system/core.asp"--> in core.asp, engine.asp would be included as such <!--#include file="LOGIC/engine.asp"--> in engine.asp, header.asp would be included as such <!--#include file="../HTML/header.asp"-->

    Its a bad example. However, it demonstrates that the relative path for each include changed depending on what file was being included.

    PHP doesn't do that. Which is kind of annoying, but you get used to it.. But I've come up with a work around.

    htdocs/index.php include('./system/core.php');

    htdocs/system/core.php define('CORE_PATH', str_replace('core.php', '', __FILE__)); include(CORE_PATH.'logic/engine.php');

    htdocs/system/logic/engine.php include(CORE_PATH.'html/header.php');

    and so on and so forth. searching for __FILE__, and removing the filename from the output, gives you a sort of relative path hack.

    Hope someone finds that useful

    attached mail follows:


    Sean Malloy wrote: > > Moving to PHP from an ASP backgroun, I always found one thing really > annoying about PHP. > > With ASP, you could have a file structure such as: > > SYSTEM > |--HTML > | |--header.asp > | > |--LOGIC > | |--engine.asp > | > |--core.asp > > in default.asp, you would > <!--#include file="system/core.asp"--> > in core.asp, engine.asp would be included as such > <!--#include file="LOGIC/engine.asp"--> > in engine.asp, header.asp would be included as such > <!--#include file="../HTML/header.asp"--> > > > Its a bad example. However, it demonstrates that the relative path for each > include changed depending on what file was being included. > > PHP doesn't do that. Which is kind of annoying, but you get used to it.. But > I've come up with a work around. > > htdocs/index.php > include('./system/core.php'); > > htdocs/system/core.php > define('CORE_PATH', str_replace('core.php', '', __FILE__)); > include(CORE_PATH.'logic/engine.php'); > > htdocs/system/logic/engine.php > include(CORE_PATH.'html/header.php'); > > and so on and so forth. searching for __FILE__, and removing the filename > from the output, gives you a sort of relative path hack. > > Hope someone finds that useful >

    You could also simply use the $DOCUMENT_ROOT variable prepopulated for you ($_SERVER['DOCUMENT_ROOT'] perhaps?) and base your includes relative to that.

    Michael Kimsal http://www.phpappserver.com/ 734-480-9961

    attached mail follows:


    "Sean Malloy" <seanelement.net.au> wrote... :

    > Moving to PHP from an ASP backgroun, I always found one thing really > annoying about PHP. > > With ASP, you could have a file structure such as: > > SYSTEM > |--HTML > | |--header.asp > | > |--LOGIC > | |--engine.asp > | > |--core.asp > > in default.asp, you would > <!--#include file="system/core.asp"--> > in core.asp, engine.asp would be included as such > <!--#include file="LOGIC/engine.asp"--> > in engine.asp, header.asp would be included as such > <!--#include file="../HTML/header.asp"--> > > > Its a bad example. However, it demonstrates that the relative path for each > include changed depending on what file was being included. > > PHP doesn't do that. Which is kind of annoying, but you get used to it.. But > I've come up with a work around.

    Wrong. PHP doesn't care that much about these paths themselves, both ASP and PHP need the path to give it to the filesystem and to retrieve the file pointer. Which means, on the same system both PHP and ASP would behave the same way to get the same files from the same locations.

    Difference stays in the fact that you can also configure it in the php.ini file. For instance, if you add '.' in php.ini then every file request will be relative to your current location (check it, it might not be set for you - include_path directive).

    > htdocs/index.php > include('./system/core.php');

    dot `.' is the current directory *relative* to the current directory - makes not much sense in many cases.

    > htdocs/system/core.php > define('CORE_PATH', str_replace('core.php', '', __FILE__));

    a cute way to accomplish the above is: define('CORE_PATH', dirname(__FILE__) . '/');

    > include(CORE_PATH.'logic/engine.php'); > > htdocs/system/logic/engine.php > include(CORE_PATH.'html/header.php'); > > and so on and so forth. searching for __FILE__, and removing the filename > from the output, gives you a sort of relative path hack. > > Hope someone finds that useful

    --
    Maxim Maletsky
    maximphp.net
    

    attached mail follows:


    Is this possible;

    function TestRef() { $var =& func_get_arg(0); ++$var; }

    $b = 1; TestRef($b); echo $b;

    It doesn't seem to work. Is there a way to do it?

    Or am I wasting my time trying to do this?

    (Yes I am aware I could define TestRef(&$b)), but I can't, reason being; I'm trying to create a couple of functions that 'sort of' emulate function overloading, but also allow me to pass a couple of objects by reference rather than value

    Anyone tried to do this already?

    attached mail follows:


    well upon reading user comments in manual, looks like the only solution is to dump variables into an array, and pass the array to a function with a single defined by-ref parameter, so it kind of defeats the purpose.

    Oh well.

    -----Original Message----- From: Sean Malloy [mailto:seanelement.net.au] Sent: Friday, 10 January 2003 3:24 PM To: PHP General Subject: [PHP] func_get_args...

    Is this possible;

    function TestRef() { $var =& func_get_arg(0); ++$var; }

    $b = 1; TestRef($b); echo $b;

    It doesn't seem to work. Is there a way to do it?

    Or am I wasting my time trying to do this?

    (Yes I am aware I could define TestRef(&$b)), but I can't, reason being; I'm trying to create a couple of functions that 'sort of' emulate function overloading, but also allow me to pass a couple of objects by reference rather than value

    Anyone tried to do this already?

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

    attached mail follows:


    Hi. I thought I had abstracted out the SQL querying part of my code out, just to find out today that it doesn't work when it comes to transactions. I had come up with this code:

    function sql_query($sql) { $conn = pg_connect("dbname=JC user=postgres"); $res = pg_exec($conn, $sql); if (!$res) { echo "CONNECTION: could not execute query ($sql)<br>"; die; } else return $res; }

    I had transactions in my code implemented like this:

    $sql = "BEGIN"; sql_query($sql); [some sql that should be in a transaction ...] $sql = "COMMIT"; sql_query($sql);

    This doesn't work. Now that I look at my code I clearly see why. All sql queries are executed using a new Postgres connection, hence the use of BEGIN/COMMIT as I was using them have no effect.

    Can someone recommend a way to abstract out my DB layer while still being able to use transactions?

    I was thinking of using the same function but if the incoming query contained the word BEGIN, saving that and all future queries in a session var and when the COMMIT comes in executing all the saved queries as one (i.e. "BEGIN;[....];COMMIT"). One drawback is that all queries will be written out to disk (as session vars) and that will slow things down. Another drawback is that I have to abort if not COMMIT comes in. And a few more drawbacks ...

    I was also thinking about maybe the $sql a GLOBAL or first building up my query as as long string ("BEGIN;[....];COMMIT") and *then* sending it to my sql_query() function.

    The last two seem easier to implement, safer, and more efficient but they don't seem "elegant" because I haven't abstracted out the fact that I want a transaction. Whenever I write an SQL query I have to think "does this need to be in a transaction" and then use a different coding technique depending on the answer. And if the future something that didn't need to be in a transaction now needs to be in a transaction I have to revisit my code and change the code.

    I'm sure someone out there must have thought about this and come up with an elegant solution and way of abstracting out the DB layer from PHP.

    Can anyone share their solution with me or give me some pointers to reference material?

    Thanks,

    Jc

    attached mail follows:


    Not exactly sure why your transactions aren't working but if your script already has an open connection to the database and you issue another call to pg_connect with the same connect string PHP will return the existing connection and should not create another connection to the database, that is provided you do not pg_close the connection between calls.

    Manual Excerpt: " If a second call is made to pg_connect() with the same connection_string, no new connection will be established, but instead, the connection resource of the already opened connection will be returned. You can have multiple connections to the same database if you use different connection string."

    The manual page for pg_connect is: http://www.php.net/manual/en/function.pg-connect.php

    Storing your db connection as a global will work.

    On Thu, 2003-01-09 at 21:56, Jean-Christian Imbeault wrote: > Hi. I thought I had abstracted out the SQL querying part of my code out, > just to find out today that it doesn't work when it comes to > transactions. I had come up with this code: > > function sql_query($sql) { > $conn = pg_connect("dbname=JC user=postgres"); > $res = pg_exec($conn, $sql); > if (!$res) { > echo "CONNECTION: could not execute query ($sql)<br>"; > die; > } > else return $res; > } > > I had transactions in my code implemented like this: > > $sql = "BEGIN"; > sql_query($sql); > [some sql that should be in a transaction ...] > $sql = "COMMIT"; > sql_query($sql); > > This doesn't work. Now that I look at my code I clearly see why. All sql > queries are executed using a new Postgres connection, hence the use of > BEGIN/COMMIT as I was using them have no effect. > > Can someone recommend a way to abstract out my DB layer while still > being able to use transactions? > > I was thinking of using the same function but if the incoming query > contained the word BEGIN, saving that and all future queries in a > session var and when the COMMIT comes in executing all the saved queries > as one (i.e. "BEGIN;[....];COMMIT"). One drawback is that all queries > will be written out to disk (as session vars) and that will slow things > down. Another drawback is that I have to abort if not COMMIT comes in. > And a few more drawbacks ... > > I was also thinking about maybe the $sql a GLOBAL or first building up > my query as as long string ("BEGIN;[....];COMMIT") and *then* sending it > to my sql_query() function. > > The last two seem easier to implement, safer, and more efficient but > they don't seem "elegant" because I haven't abstracted out the fact that > I want a transaction. Whenever I write an SQL query I have to think > "does this need to be in a transaction" and then use a different coding > technique depending on the answer. And if the future something that > didn't need to be in a transaction now needs to be in a transaction I > have to revisit my code and change the code. > > I'm sure someone out there must have thought about this and come up with > an elegant solution and way of abstracting out the DB layer from PHP. > > Can anyone share their solution with me or give me some pointers to > reference material? > > Thanks, > > Jc > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

    attached mail follows:


    Jason Sheets wrote: > > Manual Excerpt: " If a second call is made to pg_connect() with the same > connection_string, no new connection will be established, but instead, > the connection resource of the already opened connection will be > returned. You can have multiple connections to the same database if you > use different connection string."

    You're right! I did some more testing and the problem is with my testing code. I don't know why but the following code times out *but*, PHP throws an error saying the code has timed out *but* calling connection_status() says the code did *not* time out!

    Any idea why connection_status() returns 0 when it should return 2??

    My code:

    set_time_limit(2); echo "set execution limit to 2 seconds <BR>"; register_shutdown_function("timed_out"); require_once("db_functions/sql_query.inc");

    $sql = "BEGIN;"; $res = sql_query($sql); $sql = "insert into test(test) values('testing 4');"; $res = sql_query($sql);

    //This will cause the script to time out $i = 0; while(true) {$i++;}

    $sql = "COMMIT;"; $res = sql_query($sql);

    function timed_out() { $status = connection_status(); if ($status == 2) { echo "the script timed out <BR>"; } else echo "no time out. Connection status is $status <BR>"; }

    The OUPUT:

    set execution limit to 2 seconds

    Fatal error: Maximum execution time of 2 seconds exceeded in /www/htdocs/jc/shut.php on line 16 no time out. Connection status is 0

    Jc

    attached mail follows:


    Jean-Christian

    If you are only doing an insert then you do not need the transactions "BEGIN" and "COMMIT" because that is already done for you on a single insert. PGSQL is transaction based so if it does not go then it will not work.

    -Ray

    On Thu, 2003-01-09 at 22:23, Jean-Christian Imbeault wrote: > Jason Sheets wrote: > > > > Manual Excerpt: " If a second call is made to pg_connect() with the same > > connection_string, no new connection will be established, but instead, > > the connection resource of the already opened connection will be > > returned. You can have multiple connections to the same database if you > > use different connection string." > > You're right! I did some more testing and the problem is with my testing > code. I don't know why but the following code times out *but*, PHP > throws an error saying the code has timed out *but* calling > connection_status() says the code did *not* time out! > > Any idea why connection_status() returns 0 when it should return 2?? > > My code: > > set_time_limit(2); > echo "set execution limit to 2 seconds <BR>"; > register_shutdown_function("timed_out"); > require_once("db_functions/sql_query.inc"); > > $sql = "BEGIN;"; > $res = sql_query($sql); > $sql = "insert into test(test) values('testing 4');"; > $res = sql_query($sql); > > //This will cause the script to time out > $i = 0; > while(true) {$i++;} > > $sql = "COMMIT;"; > $res = sql_query($sql); > > function timed_out() { > $status = connection_status(); > if ($status == 2) { > echo "the script timed out <BR>"; > } > else echo "no time out. Connection status is $status <BR>"; > } > > The OUPUT: > > set execution limit to 2 seconds > > Fatal error: Maximum execution time of 2 seconds exceeded in > /www/htdocs/jc/shut.php on line 16 > no time out. Connection status is 0 > > Jc

    attached mail follows:


    You could try leaving off the ";"...

    Try $sql = "BEGIN"

    Try $sql = "COMMIT"

    That should work...

    On Thu, 2003-01-09 at 22:23, Jean-Christian Imbeault wrote: > Jason Sheets wrote: > > > > Manual Excerpt: " If a second call is made to pg_connect() with the same > > connection_string, no new connection will be established, but instead, > > the connection resource of the already opened connection will be > > returned. You can have multiple connections to the same database if you > > use different connection string." > > You're right! I did some more testing and the problem is with my testing > code. I don't know why but the following code times out *but*, PHP > throws an error saying the code has timed out *but* calling > connection_status() says the code did *not* time out! > > Any idea why connection_status() returns 0 when it should return 2?? > > My code: > > set_time_limit(2); > echo "set execution limit to 2 seconds <BR>"; > register_shutdown_function("timed_out"); > require_once("db_functions/sql_query.inc"); > > $sql = "BEGIN;"; > $res = sql_query($sql); > $sql = "insert into test(test) values('testing 4');"; > $res = sql_query($sql); > > //This will cause the script to time out > $i = 0; > while(true) {$i++;} > > $sql = "COMMIT;"; > $res = sql_query($sql); > > function timed_out() { > $status = connection_status(); > if ($status == 2) { > echo "the script timed out <BR>"; > } > else echo "no time out. Connection status is $status <BR>"; > } > > The OUPUT: > > set execution limit to 2 seconds > > Fatal error: Maximum execution time of 2 seconds exceeded in > /www/htdocs/jc/shut.php on line 16 > no time out. Connection status is 0 > > Jc

    attached mail follows:


    To all who replied to my initial question ...

    I actually did *not* have problems with transactions in the way I first implemented my abstraction layer. In the case of PHP

    "If a second call is made to pg_connect() with the same connection_string, no new connection will be established, but instead, the connection resource of the already opened connection will be returned."

    The bug was in my transaction testing code. I was forcing PHP to time out to check weather the transaction went through or not. In the script I was catching the time-out but it so happens that there is a bug in PHP when it comes to catching connection time outs using the connection_status() function ...

    Jc

    attached mail follows:


    Hello,

    i have document in html and i want to get out string between <title> tags to put it into another variable..

    i am wondering if i could use eregi() here....but how? I cant figure out any possible way... same with strchr() and strstr()

    can anyone help me please?

    -- 
    Best regards,
     Martin                          mail   corwincorwin.sk
                                     mobile +421.907.303.393
                                     icq    34358414
                                     www    http://www.corwin.sk
    

    PGP key fingerprint 21365ca05ecfd8aeb1cf19c838fff033

    "In those days spirits were brave, the stakes were high, men were real men, women were real women and small furry creatures from Alpha Centauri were real small furry creatures from Alpha Centauri."

    by Douglas Adams

    attached mail follows:


    Use Preg:

    // put your html into $html

    preg_match('/<title>(.*)<\/title>/Usi', $htlm, $title);

    echo $title[1];

    ** very basic example

    Timothy Hitchens (HiTCHO) Open Platform Consulting e-mail: timhitcho.com.au

    > -----Original Message----- > From: Martin Hudec [mailto:corwincorwin.sk] > Sent: Friday, 10 January 2003 3:22 PM > To: php-generallists.php.net > Subject: [PHP] searching for string inside document > > > Hello, > > i have document in html and i want to get out string between > <title> tags to put it into another variable.. > > i am wondering if i could use eregi() here....but how? I cant > figure out any possible way... same with strchr() and strstr() > > can anyone help me please? > > -- > Best regards, > Martin mail corwincorwin.sk > mobile +421.907.303.393 > icq 34358414 > www http://www.corwin.sk > > PGP key fingerprint 21365ca05ecfd8aeb1cf19c838fff033 > > "In those days spirits were brave, the stakes were high, > men were real men, women were real women and small furry > creatures from Alpha Centauri were real small furry creatures > from Alpha Centauri." > > by Douglas Adams > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    Oops...

    // $htlm should have been $html

    preg_match('/<title>(.*)<\/title>/Usi', $html, $title);

    Timothy Hitchens (HiTCHO) Open Platform Consulting e-mail: timhitcho.com.au

    > -----Original Message----- > From: Timothy Hitchens (HiTCHO) [mailto:phplistshitcho.com.au] > Sent: Friday, 10 January 2003 3:22 PM > To: 'Martin Hudec'; php-generallists.php.net > Subject: RE: [PHP] searching for string inside document > > > Use Preg: > > // put your html into $html > > preg_match('/<title>(.*)<\/title>/Usi', $htlm, $title); > > echo $title[1]; > > ** very basic example > > > Timothy Hitchens (HiTCHO) > Open Platform Consulting > e-mail: timhitcho.com.au > > > -----Original Message----- > > From: Martin Hudec [mailto:corwincorwin.sk] > > Sent: Friday, 10 January 2003 3:22 PM > > To: php-generallists.php.net > > Subject: [PHP] searching for string inside document > > > > > > Hello, > > > > i have document in html and i want to get out string between > > <title> tags to put it into another variable.. > > > > i am wondering if i could use eregi() here....but how? I cant > > figure out any possible way... same with strchr() and strstr() > > > > can anyone help me please? > > > > -- > > Best regards, > > Martin mail corwincorwin.sk > > mobile +421.907.303.393 > > icq 34358414 > > www http://www.corwin.sk > > > > PGP key fingerprint 21365ca05ecfd8aeb1cf19c838fff033 > > > > "In those days spirits were brave, the stakes were high, > > men were real men, women were real women and small furry > > creatures from Alpha Centauri were real small furry creatures > > from Alpha Centauri." > > > > by Douglas Adams > > > > > > -- > > 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:


    Martin Hudec <corwincorwin.sk> wrote... :

    > Hello, > > i have document in html and i want to get out string between <title> > tags to put it into another variable.. > > i am wondering if i could use eregi() here....but how? I cant figure > out any possible way... same with strchr() and strstr()

    all these functions can work. Though, you will need to get the document's contents into a variable of your script so you can perform a preg_match()/ereg()/strstr() on that string variable. I believe this is what you missed out.

    --
    Maxim Maletsky
    maximphp.net
    

    attached mail follows:


    I would like to know if the follwing function can be implemneted in php with help of other tools:

    using MS Word in windows, when a file is saved, can it be AUTOMATICALLY uploaded (via http POST or other mechanism) to a server?

    Currently I need to first save it on my desktop, then upload that copy to a php-supported server.

    Thanks in advance.

    Tim

    attached mail follows:


    So you want to be able to have a directory that when saved to it is really the server well besides ftp or samba integration into explorer the only other option you have is to use webdav with apache and that way it would be a post of sorts to the mod webdav module in apache.

    Timothy Hitchens (HiTCHO) Open Platform Consulting e-mail: timhitcho.com.au

    > -----Original Message----- > From: tryneasys.com [mailto:tryneasys.com] > Sent: Friday, 10 January 2003 4:06 PM > To: php-generallists.php.net > Subject: [PHP] Is this possible with php? > > > I would like to know if the follwing function can be > implemneted in php with help of other tools: > > using MS Word in windows, when a file is saved, can it be > AUTOMATICALLY uploaded (via http POST or other mechanism) to a server? > > Currently I need to first save it on my desktop, then upload > that copy to a php-supported server. > > Thanks in advance. > > Tim > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    Hi,

    Friday, January 10, 2003, 4:06:23 PM, you wrote: tnc> I would like to know if the follwing function can be implemneted tnc> in php with help of other tools:

    tnc> using MS Word in windows, when a file is saved, can it be AUTOMATICALLY tnc> uploaded (via http POST or other mechanism) to a server?

    tnc> Currently I need to first save it on my desktop, then upload that copy tnc> to a php-supported server.

    tnc> Thanks in advance.

    tnc> Tim

    I use webdrive which allows me to map an ftp site to a windows drive letter so it gets treated as a local drive ..... very usefull. You can read about it here http://www.webdrive.com/

    -- 
    regards,
    Tom
    

    attached mail follows:


    tryneasys.com wrote... :

    > I would like to know if the follwing function can be implemneted > in php with help of other tools:

    in PHP distribution? PHP is the programming language, not a client/server tool. This is definitely something to be an integrated part of something else.

    > using MS Word in windows,

    MS Word for editing PHP files? That is very, very bad ... You will never find a job if ever mention it to an employer. Search the archives of this list for "PHP Editors". I recommend Edit Plus for plain-text programming. If you want a whole IDE then Zend Studio is probably the best for you.

    > when a file is saved, can it be AUTOMATICALLY > uploaded (via http POST or other mechanism) to a server? > > Currently I need to first save it on my desktop, then upload that copy > to a php-supported server.

    Oh well, there are four ways to accomplish this.

    1. Professional way:

    Using CVS. CVS (cvshome.org) is a system that allows you to version your files. This, in two words, works this way: in CVS, you `checkout' (update) a file, edit it, and save it (if somebody else edited that file while you edited yours both changes will merge). CVS is the most professional solution for this thing.

    2. Simplest way:

    Use a mapped networking like Samba. This will mean that you will see your server just as it was a hard disk on your windows. You drag&drop files there and the same will occur remotely. Not a very secure way, though.

    3. FTP integrated tool:

    Get a good editor that has some FTP integration. It will means that when you `save' a file in your editor, it will automatically FTP that file on the server. A very tool-dependent way but can work. Very cruel when something goes wrong, though. Again, Zend IDE and Edit Plus can do that.

    4. The Geeky way:

    Edit all your files in a simple VIM or other fancy directly on the server by logging there with telnet or SSH.

    Have fun.

    --
    Maxim Maletsky
    maximphp.net
    

    attached mail follows:


    Hello Gareth, Well I've the same problems here what I added to Mine httpd.conf

    <Files *.php> SetOutputFilter PHP SetInputFilter PHP </files> LoadModule php4_module modules/libphp4.so

    Thats all it works. But be carefull with 2.0.40 it's shouldn't used for production. PHP is (!)EXPERIMENTAL(!) for it. Hope it will help

    Thursday, January 9, 2003, 7:52:12 PM, you wrote:

    GT> Tim,

    GT> thanks but it still doesn't work. What puzzles me is that last night I GT> reinstalled a 'vanilla' install of RedHat 8 from the distribution where I GT> selected PHP and Apache. So now I am running PHP 4.2.2 and Apache 2.0.40, I GT> make the change you recommened to httpd.conf, stop and restart the service GT> and it still simply ignores the PHP code...this is driving me insane.

    GT> Gareth

    GT> "Timothy Hitchens )" <phplistshitcho.com.au> wrote in message GT> news:007101c2b784$652736b0$0500a8c0bambino... >> Your settings should be something similar to this: >> >> <IfModule mod_php4.c> >> AddType application/x-httpd-php .php .html >> AddType application/x-httpd-php-source .phps >> </IfModule> >> >> Do you have the page remotely available to see what is happening for >> you?? >> >> >> >> Timothy Hitchens (HiTCHO) >> Open Platform Consulting >> e-mail: timhitcho.com.au >> >> > -----Original Message----- >> > From: Gareth Thomas [mailto:gdthomasmercurysoft.com] >> > Sent: Thursday, 9 January 2003 12:03 PM >> > To: php-generallists.php.net >> > Subject: [PHP] apache and php >> > >> > >> > I am trying to run a PHP page from my browser (Mozilla) and >> > each time I load the page it is attempting to force a dowload >> > of the page instead, based on the mime-type. I had been >> > developing a command line PHP application which works fine >> > and then had just started on a web interface and realised >> > that Apache may not be configured correctly. So I edited >> > httpd.conf and added the Add Type line for x-type-httpd .php. >> > I am running Apache 2.0.40 on RedHat 8 and PHP 4.3.0pre2. Can >> > anyone tell me what I am doing wrong? What should the >> > modifications be to httpd.conf for PHP? >> > >> > Thanks in advance >> > >> > >> > >> > >> > >> > -- >> > PHP General Mailing List (http://www.php.net/) >> > To unsubscribe, visit: http://www.php.net/unsub.php >> > >>

    -- 
    Best regards,
     Submission.org.ru                            mailto:freemansubmission.org.ru
    

    attached mail follows:


    Dear Noel Wade,

    I've been coding session for quite sometime, but this is the first time i encounter such problem...

    in the login.php page, i've tested out session_is_registered("userkey");

    it was TRUE.

    but when i redirect it to main.php and did a checking on session_is_registered("userkey"); it return FALSE...

    i've session_start(); at every start of the php page...

    what's wrong? I've output session not set on main.php when the userkey session is not set. when i click on back button and retry login, it works!!! what happened?

    please check my code again...

    ==============login.php================== include "lib/mysql.php"; include "lib/u007lib.php";

    // connecting to mysql db , my own lib... $rs = getdb(""); $rs->query("select * from ct_user where companyid like '" . $HTTP_POST_VARS["companyid"] . "'"); $rs2 = getdb("");

    $erron = "";

    if(!$rs->eof) {

    // if company records found... $rs2->query("select * from ct_login where loginid like '" . $HTTP_POST_VARS["loginid"] . "' and userid=" . $rs->fields("id") . " and pass like '" . $HTTP_POST_VARS["password"] . "'");

    if(!$rs2->eof) { // if loginid and password match...

    session_start(); // session key to be checked... $userkey = $rs2->fields("lvl");

    $userid = $rs2->fields("id"); $userloginid = $rs2->fields("loginid");

    $usercomid = $rs->fields("id"); $usercompany = $rs->fields("company"); $usercompanyid = $rs->fields("companyid");

    // registering session key session_register("userkey"); session_register("usercomid"); session_register("usercompany"); session_register("usercompanyid");

    session_register("userid"); session_register("userloginid");

    setcookie("companyid", $HTTP_POST_VARS["companyid"], time()+(60*60*24*30)); setcookie("loginid", $HTTP_POST_VARS["loginid"], time()+(60*60*24*30));

    //redirecting to main.php //header("location: main.php"); exit(); if (session_is_registered("userkey")) { header("location: main.php"); return; } else { echo "session not set!"; } // always return TRUE...

    } else { $erron = "Invalid User / Password"; }

    } else { $erron = "No Such Company ID"; }

    ?> =============end of login code========================

    =============beginning code of main.php================= <? session_start(); include "lib/u007lib.php"; include "lib/mysql.php";

    // check session userkey if (!session_is_registered("userkey")) { echo "session not set!"; exit(); } // RETURNED FALSE HERE? Y?

    if($HTTP_SESSION_VARS["userkey"]-0 < 1) { header("location: ./"); return; } ?> ==============end of main.php code=====================

    best regards,

    James

    "Noel Wade" <noelwadeattbi.com> wrote in message news:20030109121025.68129.qmailpb1.pair.com... > James - > > Don't know how you're working with Cookies and sessions for sure, but the > default / "easy" way to check for an established session is to put > "session_start();" at the top of every page that's going to access the > session variables. That will check for an established/open session and make > the registered session variables accessible to the page. > > Then a logical check is as simple as using "session_is_registered()" like > this: > > if (session_is_registered("registered_variable_name")) > //do something here if the person has already registered their session > else > //session not registered! > > Hope this helps! > > Take care, > > --Noel > > >

    attached mail follows:


    I have a question about the usage of fsockopen() to open and "scrape" the contents of a remote URL: if the contents take a very long time to load on the remote URL either due to server or coding issues, is there a way for the socket on the PHP end to time out, that is, quit trying to "scrape" contents from the remote site and post a default message instead?

    Just wondering Thanx Phil

    attached mail follows:


    "Phil Powell" <soazineerols.com> wrote... :

    > I have a question about the usage of fsockopen() to open and "scrape" the contents of a remote URL: if the contents take a very long time to load on the remote URL either due to server or coding issues, is there a way for the socket on the PHP end to time out, that is, quit trying to "scrape" contents from the remote site and post a default message instead?

    Yes, it is the last parameter of the fsockopen() function. Normally, it will be set to something like 30 seconds, you might adjust it to whatever you like. After that time you will get error 110 which means "Connection timed out". Additionally, if you set anything over 30 seconds, you might also consider altering the execution time limit for the php script itself.

    --
    Maxim Maletsky
    maximphp.net
    

    attached mail follows:


    Hello again

    thank's for the fast anwser.

    So I trie it now with the access_log file but this file become very big (20 - 40 MB)

    and then i get "Allowed memory size of 10485760 bytes exhausted" (i can set the size in php.ini to a higher value but ..)

    is there a possibility to read a part of the file and not the hole contend a time (like RPC or a database select)

    BR/Torsten Rosenberger

    attached mail follows:


    I'm not sure what you are trying to do exactly (i haven't been following this thread) but if you want to analyze apache web logs try analog. It can do everything and is *blazzingly* fast. I use on log file that are 10 Gb or greater ...

    http://www.analog.cx

    Jc

    attached mail follows:


    You're missing string concatenation operators. I use "echo" instead of "print" - but here's how it should look with either:

    echo "<SELECT NAME=\"".$vari[$i][$j]."\">";

    Explanation: The \" makes the double-quote appear in the final HTML, then you have to use a plain " to end the text string. Then you use the . concatenation operator, followed by your variable. To add further text, use another . operator, then " to open up the text string, then \" for the HTML close-quote, then the > to close the HTML tag, then " to close out the echo or print statement. End with a ;

    Let me know if that helps!

    Take care,

    --Noel

    "Rizki Salamun" <kiputpceisc.iitr.ernet.in> wrote in message news:Pine.GSO.4.05.10301091911200.19568-100000isc.iitr.ernet.in... > hi there.. > > I have a problem when I want to passing two dimension varible. I made this > variable from html form. > > like this: > > > <FORM method=post action="page2.php"> > <? > print "<SELECT name=\"vari[$i][$j]\">"; > ?> > <OPTION value="A">a > <OPTION value="B">b > ....... > ....... > </SELECT> > </FORM> > > but when again I want to print the $vari[$i][$j, in the page2.php it > seems doesnt recognize this variable. > > > thanks > > -rizki- > >

    attached mail follows:


    Or,

    "Noel Wade" <noelwadeattbi.com> wrote: > You're missing string concatenation operators. I use "echo" instead of > "print" - but here's how it should look with either: > > echo "<SELECT NAME=\"".$vari[$i][$j]."\">";

    Try this instead:

    Just add curly brackets before and after the variable and don't forget the "$" sign. So, this

    > > print "<SELECT name=\"vari[$i][$j]\">";

    would be like this:

    print "<SELECT name=\"{$vari[$i][$j]}\">";

    or this:

    echo "<select name=\"{$vari[$i][$j]}\">";

    - E

    ...[snip]...

    __________________________________________________ Do You Yahoo!? Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/

    attached mail follows:


    Hi,

    If I pass a <FORM> (using POST) from one php script to another, which contains the following HTML checkbox:

    <INPUT type="checkbox" name="insurance" value="yes">

    I know that the input will only be passed if the checkbox is ticked... but how do I check if the checkbox was ticked and the value has actually been passed ?

    At the moment I am doing this:

    if ( $_POST["insurance"] == "yes" ) { }

    But is there a more "accurate" way of checking the exsistence of "insurance" ?

    Many Thanks, Shams

    attached mail follows:


    "Shams" <shamskhanmalikhotmail.com> wrote:

    [snip] > At the moment I am doing this: > > if ( $_POST["insurance"] == "yes" ) > { > } > > But is there a more "accurate" way of checking the exsistence of > "insurance"? [/snip]

    I think you're looking for isset():

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

    - E

    __________________________________________________ Do You Yahoo!? Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/

    attached mail follows:


    thanks a lot, thats what I was looking for

    :o)

    Shams

    "- Edwin" <copperwa11syahoo.co.jp> wrote in message news:JO20030110183105.27443796yahoo.co.jp... > "Shams" <shamskhanmalikhotmail.com> wrote: > > [snip] > > At the moment I am doing this: > > > > if ( $_POST["insurance"] == "yes" ) > > { > > } > > > > But is there a more "accurate" way of checking the exsistence of > > "insurance"? > [/snip] > > I think you're looking for isset(): > > http://www.php.net/manual/en/function.isset.php > > - E > > __________________________________________________ > Do You Yahoo!? > Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/ >

    attached mail follows:


    Why re-invent the wheel. There are plenty of these out there...

    Two I suggest are

    [1] mine... http://daevid.com/photo_album.phtml

    And

    [2] http://www.andymack.com/freescripts/

    attached mail follows:


    Hi,

    No problems with my code but instead I'd like some views on the best way of doing the following:

    When I read in a text field from a users HTML form, I will allow them a maximum of say 50 characters. So, I define the corresponding field in MySQL to be VARCHAR(50). The problem is that after I run it through htmlspecialchars() the size could have increased considerably, if there were for example 5 characters that got escaped, this would mean possibly an extra 25 characters to the original meaning it would be truncated considerably. One option is to store the input without using htmlspecialchars, and then when I display the information wrap the output in htmlspecialchars. I don't like this though as I've got several text fields which will be hit very often, it seems too much of a performance penalty. The other option is to str_replace($text, '<', '') so this gets round people embedding Javascript and other HTML but means non-malicious less-than characters would be lost, however I would only need to use htmlspecialchars when outputting to an input box, not just as plain text, so not so much a performance penalty as the first option.

    How do you guys go about resolving this situation?

    Thanks for any input,

    Jim.

    attached mail follows:


    Hello,

    "Jim" <jimytyahoo.com> wrote:

    ...[snip]...

    > How do you guys go about resolving this situation?

    Well, first, increase the size of your field, say VARCHAR(100) then in your form, use "maxlength" like this:

    <input type="text" name="mytext" size="50" maxlength="50" />

    That would prevent them from entering more that 50 characters. (At least, that's how it should work.) But, just to make sure, count the characters entered using strlen() or something before you use htmlspecialchars()...

    - E

    __________________________________________________ Do You Yahoo!? Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/

    attached mail follows:


    >Everything works fine, just now I'm getting "Notice" messages for every undefined variable or undefined index in arrays.. >So now I have to use issset() everytime to avoid this messages...

    you would initialize your variables in the beginning of your scripts. With that, you don't need isset().

    >..is there any way to turn this messages off, because if prior versions I never got them..??

    ok, the other guys have answered with error_reporting(E_ALL ~E_NOTICE) or error_reporting(E_NONE). But don't you think it would be a best practice to set error reporting to E_ALL and initialize your variables ? your script would work, regardless of the configuration of php.ini, and would be more portable. error_reporting(E_ALL) and register_globals = off are IMHO a good way to have better code. In fact, I use error_reporting(E_ALL) on my test server, and error_reporting(E_NONE) (or a file log) on the production one. Best regards, Philippe

    attached mail follows:


    I've posted this a few weeks ago with no response. I want to use an external "email template" as it were, so that the sales guys can edit it as they like and simply shuffle the variables around that they need $username and $password (either with or without the <?php ?> tags).

    I don't want them mucking around in my code and potentially screwing it up. Not to mention having a huge 'email' text in between those HTMLMESSAGE markers is ugly as hell and ends up making the color-coding in HomeSite all kinds of whack at the end of it.

    I tried to use:

    $message = <<<HTMLMESSAGE include("/pathto/customer_email.php"); HTMLMESSAGE;

    But $message has the literal string ''include("/pathto/customer_email.php");'' instead of including the file. Grr.. (wouldn't it make sense that an include() should be parsed FIRST with the contents put in place basically? This seems like a 'bug' not a feature.

    I also tried:

    $filename = "/pathto/customer_email.php"; $fd = fopen ($filename, "r"); $message = fread ($fd, filesize ($filename)); fclose ($fd);

    But all the $username, etc. are treated as literals and if I use <?=$username?> in the customer_email.php the field is blank (like it's being parsed but doesn't have a value for it or something), instead of being converted to their actual PHP values. I also tried to put the "global" keyword in the customer_email.php file at the top.

    Ideally I would like to set things up so we have varoius form letter emails and I can switch them around based upon say a "special order code", where the $user/$pw is always the same (depending on the database user of course), but the email content is different formats.

    Is there no way to accomplish this? Am I not being clear on what it is I'm trying to accomplish?

    My final thought is to use some regex to search for <?=$username?> in $message after it's all been read in, and replace it with the variable $username or make up my own tag codes like [!username!] or something like that. This seems like such a hack, when PHP should be able to do this natively somehow.

    Surely somebody out there has had to do this type of thing?

    attached mail follows:


    I think this should make it:

    ob_start(); include("/pathto/customer_email.php"); $message = ob_get_contents(); ob_end_clean();

    ----- Original Message ----- From: "Daevid Vincent" <daeviddaevid.com> To: <php-generallists.php.net> Sent: Friday, January 10, 2003 10:48 AM Subject: [PHP] how can I use an external 'template' file and still use PHP variables?

    > I've posted this a few weeks ago with no response. I want to use an > external > "email template" as it were, so that the sales guys can edit it as they > like and simply shuffle the variables around that they need > $username and $password (either with or without the <?php ?> tags). > > I don't want them mucking around in my code and potentially screwing it > up. Not to mention having a huge 'email' text in between those > HTMLMESSAGE markers is ugly as hell and ends up making the color-coding > in HomeSite all kinds of whack at the end of it. > > I tried to use: > > $message = <<<HTMLMESSAGE > include("/pathto/customer_email.php"); > HTMLMESSAGE; > > But $message has the literal string > ''include("/pathto/customer_email.php");'' instead of including the > file. Grr.. (wouldn't it make sense that an include() should be parsed > FIRST with the contents put in place basically? This seems like a 'bug' > not a feature. > > I also tried: > > $filename = "/pathto/customer_email.php"; > $fd = fopen ($filename, "r"); > $message = fread ($fd, filesize ($filename)); > fclose ($fd); > > But all the $username, etc. are treated as literals and if I use > <?=$username?> in the customer_email.php the field is blank (like it's > being parsed but doesn't have a value for it or something), instead of > being converted to their actual PHP values. I also tried to put the > "global" keyword in the customer_email.php file at the top. > > Ideally I would like to set things up so we have varoius form letter > emails and I can switch them around based upon say a "special order > code", where the $user/$pw is always the same (depending on the database > user of course), but the email content is different formats. > > Is there no way to accomplish this? Am I not being clear on what it is > I'm trying to accomplish? > > My final thought is to use some regex to search for <?=$username?> in > $message after it's all been read in, and replace it with the variable > $username or make up my own tag codes like [!username!] or something > like that. This seems like such a hack, when PHP should be able to do > this natively somehow. > > Surely somebody out there has had to do this type of thing? > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

    attached mail follows:


    "Daevid Vincent" <daeviddaevid.com> wrote: > I've posted this a few weeks ago with no response. I want to use an > external > "email template" as it were, so that the sales guys can edit it as they > like and simply shuffle the variables around that they need > $username and $password (either with or without the <?php ?> tags). > > I don't want them mucking around in my code and potentially screwing it > up. Not to mention having a huge 'email' text in between those > HTMLMESSAGE markers is ugly as hell and ends up making the color-coding > in HomeSite all kinds of whack at the end of it. > > I tried to use: > > $message = <<<HTMLMESSAGE > include("/pathto/customer_email.php"); > HTMLMESSAGE; > > But $message has the literal string > ''include("/pathto/customer_email.php");'' instead of including the > file. Grr.. (wouldn't it make sense that an include() should be parsed > FIRST with the contents put in place basically? This seems like a 'bug' > not a feature.

    Well, include() will parse the file--maybe you're just doing it the wrong way... ;)

    I'm not sure how your customer_email.php looks like but consider this:

    <?php

    $name = "General PHP";

    include "inc.php";

    echo $message;

    ?>

    Then in inc.php you have:

    <?php

    $message = "$name, how are you doing?";

    ?>

    Running the first script should echo:

    General PHP, how are you doing?

    So, as you can see the $name was replaced.

    Just a simple example...

    - E

    ...[snip]...

    __________________________________________________ Do You Yahoo!? Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/

    attached mail follows:


    I agree with Edwin on this one.

    What's the <<< for??

    Could it be you want to be doing this:

    $templatestring = include("/pathto/email_template.php");

    $message = "<<<HTMLMESSAGE".$templatestring."HTMLMESSAGE";

    ??

    When you "include()" a file with PHP, it DOES parse the included file (although in the included file, anything not between "<?php" and "?>" tags will be considered plain text. Put another way: Even though the "include" statement in the main document is ALREADY between PHP tags, the parser looks for an opening PHP tag in the included file to find where to begin parsing - anything before that opening tag is echo'ed out as plain text).

    Hope this helps!

    Take care,

    --Noel

    ------------------------------------------- "Daevid Vincent" <daeviddaevid.com> wrote in message news:006801c2b88d$69748a60$0801a8c0telecom... > I've posted this a few weeks ago with no response. I want to use an > external > > $message = <<<HTMLMESSAGE > include("/pathto/customer_email.php"); > HTMLMESSAGE; >

    attached mail follows:


    Check out Smarty:

    http://smarty.php.net

    it does exactly what you need.

    --
    Maxim Maletsky
    maximphp.net
    

    "Daevid Vincent" <daeviddaevid.com> wrote... :

    > I've posted this a few weeks ago with no response. I want to use an > external > "email template" as it were, so that the sales guys can edit it as they > like and simply shuffle the variables around that they need > $username and $password (either with or without the <?php ?> tags). > > I don't want them mucking around in my code and potentially screwing it > up. Not to mention having a huge 'email' text in between those > HTMLMESSAGE markers is ugly as hell and ends up making the color-coding > in HomeSite all kinds of whack at the end of it. > > I tried to use: > > $message = <<<HTMLMESSAGE > include("/pathto/customer_email.php"); > HTMLMESSAGE; > > But $message has the literal string > ''include("/pathto/customer_email.php");'' instead of including the > file. Grr.. (wouldn't it make sense that an include() should be parsed > FIRST with the contents put in place basically? This seems like a 'bug' > not a feature. > > I also tried: > > $filename = "/pathto/customer_email.php"; > $fd = fopen ($filename, "r"); > $message = fread ($fd, filesize ($filename)); > fclose ($fd); > > But all the $username, etc. are treated as literals and if I use > <?=$username?> in the customer_email.php the field is blank (like it's > being parsed but doesn't have a value for it or something), instead of > being converted to their actual PHP values. I also tried to put the > "global" keyword in the customer_email.php file at the top. > > Ideally I would like to set things up so we have varoius form letter > emails and I can switch them around based upon say a "special order > code", where the $user/$pw is always the same (depending on the database > user of course), but the email content is different formats. > > Is there no way to accomplish this? Am I not being clear on what it is > I'm trying to accomplish? > > My final thought is to use some regex to search for <?=$username?> in > $message after it's all been read in, and replace it with the variable > $username or make up my own tag codes like [!username!] or something > like that. This seems like such a hack, when PHP should be able to do > this natively somehow. > > Surely somebody out there has had to do this type of thing? > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    redhat linux 7.3 apache 1.3.27 mysql 3.23.49 php 4.0.4pl1 (static install) mod_ssl-2.8.12

    the box had php 4.2.3 installed on it originally. we had a mysql application that would only run with php version 4.0.4pl1 so we installed that version of php and everything worked.

    later we ran autorpm with the 'interactive' setting (just downloading and not auto installing) and the php-dependent application broke. when we run debug_phpinfo it says version 4.2.3. we have reinstalled php version 4.0.4pl1 and debug_phpinfo still says version 4.2.3 and the app. remains broken. yes we copied the php.ini file after the reinstall of the old version

    we checked the new php binary and its definitely version 4.0.4pl1. we're pulling our hair out. what are we doing wrong/do we have yet to do?

    thanks!

    attached mail follows:


    You high jacked someone else's thread, probably because you hit the "reply-to" button and just changed the subject line instead of posting a "new" message.

    Try posting again, creating a new message this time. You'll start your own thread and will definitely get more answers ...

    Jc

    Christian Stalberg wrote: > redhat linux 7.3 > apache 1.3.27 > mysql 3.23.49 > php 4.0.4pl1 (static install) > mod_ssl-2.8.12 > > the box had php 4.2.3 installed on it originally. > we had a mysql application that would only run > with php version 4.0.4pl1 so we installed that > version of php and everything worked. > > later we ran autorpm with the 'interactive' setting > (just downloading and not auto installing) and the > php-dependent application broke. when we run > debug_phpinfo it says version 4.2.3. we have > reinstalled php version 4.0.4pl1 and > debug_phpinfo still says version 4.2.3 and the app. > remains broken. yes we copied the php.ini file > after the reinstall of the old version > > we checked the new php binary and its definitely > version 4.0.4pl1. we're pulling our hair out. > what are we doing wrong/do we have yet to do? > > thanks!

    attached mail follows:


    Please, when posting a new message - MAKE IT A *NEW* MESSAGE and not reply to something on the list changing the body and the subject - we notice it because that breaks threading of most email clients (Reference header)

    --
    Maxim Maletsky
    maximphp.net
    

    "Christian Stalberg" <nocpharosweb.net> wrote... :

    > redhat linux 7.3 > apache 1.3.27 > mysql 3.23.49 > php 4.0.4pl1 (static install) > mod_ssl-2.8.12 > > the box had php 4.2.3 installed on it originally. > we had a mysql application that would only run > with php version 4.0.4pl1 so we installed that > version of php and everything worked. > > later we ran autorpm with the 'interactive' setting > (just downloading and not auto installing) and the > php-dependent application broke. when we run > debug_phpinfo it says version 4.2.3. we have > reinstalled php version 4.0.4pl1 and > debug_phpinfo still says version 4.2.3 and the app. > remains broken. yes we copied the php.ini file > after the reinstall of the old version > > we checked the new php binary and its definitely > version 4.0.4pl1. we're pulling our hair out. > what are we doing wrong/do we have yet to do? > > thanks! > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

    attached mail follows:


    Can anybody explain me what does mean error:

    Warning: main(footer.inc.php) [function.main.html]: failed to create stream: Too many open files in /www/sql/main.php on line 96

    (phpPgAdmin 2.4.2 scripts, PHP 4.3.0 + Apache)

    Does PHP exceed any limit of opened files? How can I change the limit?

    Krzysztof Czuma czumapoland.org

    attached mail follows:


    On Wed, 8 Jan 2003, Macrosoft wrote:

    > Can anybody explain me what does mean error: > > Warning: main(footer.inc.php) [function.main.html]: failed to > create stream: > Too many open files in /www/sql/main.php on line 96 > > (phpPgAdmin 2.4.2 scripts, PHP 4.3.0 + Apache) > > Does PHP exceed any limit of opened files? How can I change the limit? > > Krzysztof Czuma > czumapoland.org > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

    That looks more like a operating system limit. Can you check the SYSLOG on the host at all?

    Rgds

    Rus

    --
    http://www.fsck.me.uk - My blog
    http://www.65535.net - $120 for a lifetime UNIX shell account
    

    attached mail follows:


    Thanks Michael!!

    This process is something really new to me and sounds like there is much to learn abt. Thanks for the guide.

    Can I also request that you send the perl equivalent script that you have written to me to kokboonshinningstudios.com please? Thank you very, very much =)

    kokboon

    -----Original Message----- From: Michael Sims [mailto:mhsimsmidsouth.rr.com] Sent: 09 January 2003 11:49 To: php-generallists.php.net Cc: See kok Boon Subject: Re: [PHP] how to make server response to emails

    On Thu, 9 Jan 2003 17:33:02 +0800, you wrote:

    >I believe >that there is a way to make the mail server, or which ever it is, to >response specifically to text within the mail. [...] >However, I have no idea how this is accomplished and what this system is >called, so I need some precious help here. Anyone please?

    99% of the time scripts such as this operate in the following manner. Lets say the script responds to emails sent to fooexample.com. The server which handles mail for example.com has an alias for the address "foo" which actually points to an external script. Most MTA's will allow you to do this (yes, even some for Windows, believe it or not). For example, in sendmail you could place a line in /etc/aliases or /etc/mail/aliases (depending on your installation) like the following:

    foo: "|/usr/local/bin/myscript.php -s"

    This would cause sendmail to send the text of any email sent to "foo" to myscript.php's stdin via a pipe. (Be aware that some sites with sendmail use the sendmail restricted shell, so there are some extra steps involved in getting an alias like the above to work, which I won't go into here).

    "myscript.php" would need to be a PHP CLI script, meaning that it's chmod'ed executable and has:

    #!/usr/local/bin/php

    at the top or something similar. Then this script would have to read from stdin and parse the text it receives via regexes or some other method to determine how to handle it. The script would receive the full message, including all headers.

    In PHP you can read from stdin by opening a filehandle to it:

    $stdin = fopen('php://stdin', 'r');

    Although in PHP 4.3.0 there are CLI specific constants defined which obseletes the above. For more info:

    http://www.php.net/manual/en/features.commandline.php

    I've implementing a script like this before, but unfortunately it's written in Perl. Many of the concepts are similar, though, so if you know any Perl at all and think it may help you I can send it to you off-list.

    HTH...

    attached mail follows:


    I have just installed php 4.3.0 what do I have to do now to get the gd library to work? thanks _____

    Jorge Martins Jorge.MartinsWeMake.pt Engenheiro de Informática Engineering Department Tel: +351 22 3744827 <http://www.wemake.pt/> WeMake - Tecnologias de Informação, Lda http://www.WeMake.pt/ Rua Pinto de Aguiar, 223 2º ESQ 4400-252 V.N. GAIA - Portugal Fax: +351 22 3744831

    Este E-mail contém informação dirigida e para uso exclusivo das pessoas acima enunciadas. O seu conteúdo é confidencial e é expressamente proibida qualquer utilização não autorizada. Se recebeu este mail por engano, por favor notifique o seu remetente imediatamente. Muito obrigado.

    The information contained in this E-mail is intended for the exclusive use of the individual named above. The contents may be confidential and any unauthorized use of whatever kind is strictly prohibited. If you have received this comunication in error, please notify de sender immediately. Thank you.


    attached mail follows:


    > -----Original Message----- > From: Dave Gervais [mailto:dag27dslmagma.ca] > Sent: 09 January 2003 21:36 > > Here is the C code. There is a decode function, but I don't > need it in > PHP because I have a C program listening to serial port on > the other end > that will validate the checksum. > > > /* > * operator fletcher_encode > */ > fletcher_encode( buffer, count ) > unsigned char* buffer; > long count; > { > int i; > unsigned char c0 = 0; > unsigned char c1 = 0; > * ( buffer + count - 1 ) = 0; > * ( buffer + count - 2 ) = 0; > for( i = 0; i < count; i++) > { > c0 = c0 + * ( buffer + i ); > c1 =c1 +c0; > } > * ( buffer + count - 2 ) = c0 - c1; > * ( buffer + count - 1 ) = c1 - 2*c0; > } > > > My problem with PHP was with the unsigned char.

    Well, as I guess that would effectively be an integer in the range 0-255, I'd just treat it as an integer and reduce it modulo 256 in places where it might overflow that value.

    Exactly how this translates into your PHP code depends on how you're translating the rest of the routine, and especially what you turn buffer into, but the loop might go something like:

    for ($i=0; $i<$count; $i++): $c0 = ($c0+$buffer[i])%256; $c1 = ($c1+$c0)%256; endfor;

    You could also do the modulo 256 reduction by doing a bitwise and with 0xff (or 0377, or 255), of course -- this is likely to be more efficient, and may, depending on your point of view, be more obvious as to what's going on. Then your loop might look like this:

    for ($i=0; $i<$count; $i++): $c0 = ($c0+$buffer[i])&0xff; $c1 = ($c1+$c0)&0xff; endfor;

    Hope this is helpful and sets you off on the right track.

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

    attached mail follows:


    Hi,

    I haven't seen anything like that implemented yet. I have my functions logically grouped/organised into files... I only include the file when needed. Some files (like my string functions and DB functions) are auto-prepend (a php.ini directive) auto-included into every script, which does save me some time.

    However, it occurs to me that there COULD be a way to implement what you want... whether it's worth the grief or not is a different discussion altogether :)

    For starters, you can check whether a function has been defined using function_exists(). If it doesn't exist, you could then include() it, assuming that you have one function per file, and each file named the same as the function, or with decent naming conventions.

    There are two functions which can call your user defined function

    call_user_func_array() (use an array to pass multiple arguments) or call_user_func() aparently for single arguments.

    I haven't used either of these.

    In psuedo code, here's what i'm thinking:

    <? function theWrapper($targetFunction,$args) { if(!function_exists($targetFunction)) { $file = "functions_lib/{$targetFunction}.func"; if(file_exists($file)) { include($file); } } $result = call_user_func_array($targetFunction,$args); return $result; } ?>

    so, let's say I have a function called foo, saved as a file foo.func in the /functions_lib/ directory

    <? function foo($animal,$name,$color) { return "I have a {$animal} named {$name}, and it is {$color}"; } ?>

    I could the call foo() thru theWrapper()

    <? $args = array('cat','muffins','black'); echo theWrapper('foo',$args); ?>

    *Totally* untested code, but in theory this should echo

    "I have a cat named muffins, and it is black"

    Now, this still needs a LOT of work. theWrapper() needs lots of error handling code... i haven't allowed for missing functions/files, missing arguments, or anything else... I guess this was more of a "proof of concept"... perhaps something to get you started? Or perhaps something to make you say "nahhhhh, too difficult" :)

    Justin

    on 10/01/03 9:15 AM, Brian T. Allen (briangzmarketing.com) wrote:

    > Hi, > > This may exist, but I haven't been able to find it, and I think it would > be REALLY helpful and convenient. > > The idea is this: > > When you write a script and call a function: > > <?php > > $whatever = previously_uncalled_function("one","two"); > > ?> > > PHP would automatically look for a file named > "previously_uncalled_function" in your /include/functions/ directory. > > This would eliminate a LOT of include() and require() calls (or at least > make them automatic) in a script. The function would only get read in > if it was used. > > This would be very convenient. When you create a new function you drop > it in that directory (with a very specific, unique name, of course), and > it can immediately be called anywhere in the site. And, you only incur > the disk IO to read it when its used for the first time in a script. > > The 3 things I want to avoid are: > > 1) Explicitly including every function, every time it's needed. > 2) Disk IO of including a function when it's not needed. > 3) Taking the easy route and including a file with a bunch of functions > when most won't get called. > > Does this already exist, or is this a good idea (if not, any reasons > why)? I personally would love to see it implemented if it isn't > already. > > Thanks, > Brian Allen > briangzmarketing.com >

    attached mail follows:


    Totally depends on the data in question.

    I tend to organise my data in a mySQL database, for easy queries, sorting, categorisation, etc etc. However sometimes I associate a file to a record (eg a photo of a member or employee)... so the employee with the id 45 will have a photo stored in the filesystem called 45.jpg.

    I tend to keep raw-text-based data in a database, and binary or heavily formatted data (mp3s, giffs, JPEGs, PNGs, .doc's, .xls's) in the file system, attached to the database records.

    I've read that you get faster queries by separating bulky data from the simple stuff... this separation can be done with files, or with relational db tables...

    I guess it depends a lot on what sort of data, how you will use it, and which your prefer (file/db).

    One other bit of advice i've read: if you do have LOTS of files in a filesystem (1000's, not 100's), it's best to break them up somehow... by alphabet (a/, b/, c/, etc), year (2002/, 2003/, 2004/, etc), category (entrés/, mains/, soups/, deserts/, etc), etc.

    on 09/01/03 4:04 PM, Erich Kolb (ekolbkolbsoft.com) wrote:

    > I am going to be dealing with a ton of data shortly and my goal is to make > it accessible via the web. I am curious about the performance differences > between using a database or leaving the data in the individual files they > originated in. Can anyone offer any recommendations?

    Justin French