php-general Digest 25 Nov 2001 15:56:18 -0000 Issue 1015
Topics (messages 75632 through 75652): Re: what the best version PHP + APACHE on Solaris8 75632 by: Justin England Re: Can php do this? 75633 by: Michael Sims 75634 by: Michael A. Peters 75636 by: Casey Allen Shobe 75637 by: Joelmon2001.aol.com 75643 by: Miles Thompson 75651 by: Michael Sims Creating $key, $value pairs 75635 by: Ashley M. Kirchner 75650 by: Hank Marquardt Help needed: Failed opening '' for inclusion 75638 by: David De Graff 75640 by: B. van Ouwerkerk Classes 75639 by: Rudi Ahlers 75641 by: Christopher William Wesley 75642 by: Miles Thompson 75645 by: Jason G. 75646 by: Jason G. 75647 by: Jason G. Re: [php] telnet describe command for mysql 75644 by: Jason G. gnupg, running php as a cgi script 75648 by: Scott Redirect upon execution of script... 75649 by: Daniel Alsén 75652 by: Miles Thompson Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] ----------------------------------------------------------------------
--- Begin Message ---Just grap the lastest stable version. As of now: Apache ver 1.3.22 PHP ver 4.0.6 Most all of my Sparc Solaris8 machines are running Apache 1.3.19/PHP 4.0.6 Hope this helps. Justin England [EMAIL PROTECTED] Network Administrator E-Net Information Services http://www.enetis.net Tel: 605-341-3638 Fax: 605-341-8880 On Thu, 22 Nov 2001, Evgeny Rachlenko wrote: > Dir Justin England, > Could you tell me what the version of apache and php do you prefer for > Solaris 8 . > > thanks > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] >--- End Message ---
--- Begin Message ---At 10:04 PM 11/24/2001 -0500, [EMAIL PROTECTED] wrote: [snip] >Sort of like cron doing what you would do if you visited >page.php and once it's hit, it emails specified users in a database >Would I need path to php in the cron script to do this? >Or am I just living a dream? It sure can. There's a couple of ways to accomplish this. I personally think the easiest way is to code your page like normal, then call it in a cron job via lynx. Let's say you have a page called "page.php" that connects to your database, retrieves the email addresses, and sends the emails. To call it from a cron job add the following to your crontab: 0 8 * * * /usr/bin/lynx -dump http://localhost/page.php > /path/to/logfile/or/dev/null Of course this means your script is in your public web space, so theoretically could be called by anyone who knew the name of the page. You could put the page in a subdirectory and add an .htaccess file that restricts access to only 127.0.0.1 to take care of that if it concerns you. If you have PHP installed as a CGI then you could also write your page as a shell script. As the first line of your script put the line: #!<path to php> -q I haven't personally used this method because I have PHP installed as an apache module and I was too lazy to compile the CGI version. Using lynx in the above configuration works fine for me...--- End Message ---
--- Begin Message ---If you have built the php standalone binary then its easy- #!/usr/local/bin/php <?php // your php code here ?> What I do when I build php is build it twice. First I build it with all my options EXCEPT for with-apxs=/blah That builds the standalone binary, and I install that in /usr/local/bin Then, I build the apache module and install that where my apache modules go. This allows me to use php as a regular unix scripting language, so I can do stuff from the crontab. btw- I'm actually doing a very similar thing- I have some customer support software that pops my support e-mail address and puts the message in a MySQL database. I have a cron job that calls a php shell script that pops the e-mail for me every 15 minutes. That way I don't have to log on to the support application as often, and the customers get an automated response fairly quickly, giving them a unique case ID etc. On Sat, 24 Nov 2001 22:04:21 EST [EMAIL PROTECTED] mentioned: > Thanks for your time . *This* = create follow up autoresponders > Or at least have php run with cron, so I can daily hit a mysql > db and use php to email those people at a specified time, like > every 3 days. Just so when I have users to the site who register > and their name/email is in a table "users" in db "data", > php/cron can be used to pull the name/email from mysql > and (with unsubscribe message at bottom) email them when I > say to do so in cron. Getting cron by itself to work is fine > but with php script that connects to mysql and emails users? > Can that be done? > > Sort of like cron doing what you would do if you visited > page.php and once it's hit, it emails specified users in a database > Would I need path to php in the cron script to do this? > Or am I just living a dream? > > The idea of emailing users in a mysql db with php script > every day is very appealing to me. (Yes, with unsubscribe feature) > ;) > > Thanks, I hope to goodness this made sense and you > enjoyed your holiday > > Joel > -- -=-=-=-=-=-=-=-=-=-=-=-=- Michael A. Peters http://24.5.29.77:10080/--- End Message ---
--- Begin Message ---On 24 November 2001 23:45, Michael Sims spaketh unto ye recipient: > It sure can. There's a couple of ways to accomplish this. I personally > think the easiest way is to code your page like normal, then call it in a > cron job via lynx. Let's say you have a page called "page.php" that > connects to your database, retrieves the email addresses, and sends the > emails. To call it from a cron job add the following to your crontab: > > 0 8 * * * /usr/bin/lynx -dump http://localhost/page.php > > /path/to/logfile/or/dev/null Nice tip! Another alternative is using wget on the URL, or links -dump if you have that instead. Or if your script has #!/usr/bin/php or whatever path at the top and is made executable, you can just call that script without relying on the webserver. I think, even if it's just a normal php file you could cron it as /usr/bin/php <scriptpath/name>. -- Casey Allen Shobe [EMAIL PROTECTED] GCS/CM d+ s+:->+: a-- C++(++++) ULU++++$ P- L+++>++++ E- W++ N++ !o K- w-- !O M V- PS++ PE Y+ PGP>++ t+ 5+ X R>+ tv-- b++ DI+ D---- G++ e h-(*) r--- z----- End Message ---
--- Begin Message ---Thanks guys I just want to confirm one last thing, as it's been a while since I needed cron After I create this file (cron.file) for ex and use crontab cronfile (I do this as root, if it matters) do permissions need to be set? I really can't recall I would think that would do it as I am not uploading it and do it as root Thanks for the help, GREAT help and it's appreciated Now I just need to get freetype 2 installed right on my raq 3 and I can live like a king Joel--- End Message ---
--- Begin Message ---I've followed this with interest, but unless you specifically need some properties of PHP to do this, use an easier tool. Python has modules for both MySQL and PHP. They are easily invoked and don't involve calling Lynx & feeding it the script. Here's some code, you might want to think about it as an alternative. I hope the indents preserve, as Python reliese on indentation and a <CR> ends it's line. Miles Thompson #! /usr/bin/python "Mails Passwords from sub_list, a MySQL database " import sys, MySQLdb, traceback import rfc822, string, sys import smtplib # MySQLdb allows connection to the MySQL database # This connects to the database, all parameters must be explicitly named try: db = MySQLdb.connect( db='sub_list' ) except: traceback.print_exc() sys.exit() # create connection to the database object try: pcursor = db.cursor() except: traceback.print_exc() sys.exit() #let's display some information print db.get_host_info() print db.stat() #let's fetch our data, mailing to everyone who has not been emailed a password try: pcursor.execute("select * from subscriber where lpasswd_mailed = 0 and email !='';") resultset = pcursor.fetchall() except: traceback.print_exc() sys.exit() #let's build the message fromaddr = '[EMAIL PROTECTED]' toaddr = '[EMAIL PROTECTED]' username = "" password = "" msgFirstPart = "Thanks for subscribing. Passwords have been\n\ updated as part of our security schedule to protect your subscription. \n\ Your name and new password are: \n\n" msgEndPart = "Please contact us at (555) 555-5555 or 555-5556 for help with your subscription, \n\ or email us at [EMAIL PROTECTED]\n\ \n\ Best regards, \n\ John Doe" # we've gotten this far, so let's open the SMTP connection server = smtplib.SMTP('smtp.domain.com',25) server.set_debuglevel(2) # for each record in the cursor # set toaddr, username and password # then send the message # here in the for loop we send the mail message .... #server.sendmail( fromaddr, toaddr, msg, "Subject: Your new password" )[D for cursorRecord in resultset: toaddr = cursorRecord[ 3 ] first_name = " First name: " + cursorRecord[ 2 ] + "\n" last_name = " Last name: " + cursorRecord[ 1 ] + "\n" password = " Password : " + cursorRecord[ 4 ] + "\n\n" msgMail = msgFirstPart + first_name + last_name + password + msgEndPart print msgMail server.sendmail( fromaddr, toaddr, msgMail, "Subject: Password for ALLnovascotia.com" ) # build the update query upd_query = "update subscriber set lpasswd_mailed = 1 where email ='" + cursorRecord[ 3 ] + "';" try: #pcursor.execute( "update subscriber set lpasswd_mailed = 1 where email = c_email;") pcursor.execute( upd_query ) except: traceback.print_exc() sys.exit() print "\n\n" print "All records printed" #close the smpt connection #server.quit() # close the database try: db.close() except: traceback.print_exc() sys.exit() # All done print "*"*30 print "" print "mailpass.py completed" print "" print "*"*30 At 02:58 AM 11/25/2001 -0500, you wrote: >Thanks guys > >I just want to confirm one last thing, as it's been a while since I needed >cron > >After I create this file (cron.file) for ex >and use >crontab cronfile (I do this as root, if it matters) >do permissions need to be set? I really can't recall >I would think that would do it as I am not uploading it >and do it as root > >Thanks for the help, GREAT help and it's appreciated > >Now I just need to get freetype 2 installed right on my raq 3 >and I can live like a king > >Joel--- End Message ---
--- Begin Message ---At 09:22 AM 11/25/2001 -0400, Miles Thompson wrote: >I've followed this with interest, but unless you specifically need some >properties of PHP to do this, use an easier tool. > >Python has modules for both MySQL and PHP. They are easily invoked and >don't involve calling Lynx & feeding it the script. >Here's some code, you might want to think about it as an alternative. I >hope the indents preserve, as Python reliese on indentation and a <CR> >ends it's line. Thanks for the code! The easiest way for me personally to learn a new language is to think of a task that needs to be done then look at some sample code. I'm not quite ready to learn Python (yet) but I'm saving this into the archive for when I'm ready. :)--- End Message ---
--- Begin Message ---I need to "convert" the following: --------------------------------------------------- Todays Date: 20-Nov-2001 10:58:24AM Order ID: W25 Customer Email: [EMAIL PROTECTED] Email Promotions: Ok BILL TO: Business Name: Contact Name: Ashley M. Kirchner Day Number: 800 555-1212 Evening Number: 303 555-1212 Fax Number: Address: 3550 Arapahoe Ave #6 Address: Address: City: Boulder State/Province: CO Zip/Postal Code: 80303 Country: USA Payment Method: CC Card Number: 99****1234 Expiration Date: 01/71 Shipping Method: PICKUP Order Comment: Gift Message: Shipping Instruction: --------------------------------------------------- ...into $key, $value pairs. Ideally, I'd like to be able to name/use my own names for $key so I can end up with something like: $BillToContact => 'Ashley M. Kirchner' $BillToDayPhone => '800 555-1212' $BillToEvePhone => '303 555-1212' etc. (or maybe with something like: $bill['contact'] => 'Ashley M. Kirchner' $bill['dayphone'] => '800 555-1212' $bill['evephone'] => '303 555-1212' etc.) All of these variables will eventually be shoved into a DB once the entire form has been parsed. And then, at the bottom of that same (submitted) form, there's the actual information on the order, which looks something like this (the spacing is slightly different): (unfortunately, this will wrap rather ugly) --------------------------------------------------- ORDER NO. QTY UNIT DESCRIPTION PRICE TOTAL 4x6 1 4"x6" Standard Print (full-frame from 35mm) .75 $0.75 4x6 1 4"x6" Standard Print (full-frame from 35mm) .75 $0.75 5x7.5 1 5x7.5 Image:Uploaded Image 3 4.25 $4.25 8x12 1 8x12 Classic Full Frame Image:Uploaded Image 4 10.25 $10.25 SUBTOTAL: $16.00 TAX: $1.18 SHIPPING: $0.00 TOTAL: $17.18 --------------------------------------------------- This part again I'd like to break up into separate lines, and separate variables for the product no., the quantity, unit, decription, price, total (per line), then the subtotal, tax, shipping cost and final (grant) total. Again, if I can somehow use my own variable names, that'd be great. ($product['no'] $product['quantity'] $product['unit'] etc. $order['subtotal'] $order['tax'] $order['shipping'] $order['total'] etc.) I don't know yet how to create different entries for each line in that order - kinda stupid to create $product_1['no'], $product_2['no'], $product_3['no'], $product_4['no'], but then again, I don't know. -- H | "Life is the art of drawing without an eraser." - John Gardner +-------------------------------------------------------------------- Ashley M. Kirchner <mailto:[EMAIL PROTECTED]> . 303.442.6410 x130 Director of Internet Operations / SysAdmin . 800.441.3873 x130 Photo Craft Laboratories, Inc. . 3550 Arapahoe Ave, #6 http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A.--- End Message ---
--- Begin Message ---OK, I took a stab at this using your post for input and it should be a good enough starting point for you ... if you do have extraneous ':'s elsewhere in the message then you'll need to be a little more picky with your regex stuff to only pick out what you want -- for example, your post has a couple of sentences that end with ':' before an example ... the script as written picks those up as key value pairs, but since you'll unlikely have those in your order messages I figure you're on safe ground for now -- Of course the really easy way to do this is just to process the form output directly then you have your key/values nice and neat in $HTTP_POST_VARS already:) ... but I'm assuming this is on and processed by a separate server, or with a canned script that only gens emails, so this is what you need to do. Here's the code: #!/usr/bin/php4 -q <? // OK, I assume you use this as a filter, so we're reading from // php://stdin -- $fp = fopen("php://stdin","r"); // Initialize a counter for the order items $itemcnt=0; while(!feof($fp)) { $buffer = fgets($fp,8192); // Simple regex effectively 'splitting' on colon(:) with capture if(preg_match('/([^:]+):\t*(.*)/',$buffer,$matches)) { // strip out spaces and /'s in the variable name $matches[1] = preg_replace("/[ \/\"]/","",$matches[1]); // create an entry for it in $billinginfo array $billinginfo[$matches[1]] = $matches[2]; } // Regex to match order items (INCOMPLETE!!!) only matches order // number and quantity so far -- Hey I had to leave something for you // to do:) if(preg_match('/([0-9]+x[0-9.]+)\s+([0-9]+).*/',$buffer,$orderitem)) { // since we don't have field ids in the matches, we create our own $order[$itemcnt]["Itemnum"] = $orderitem[1]; $order[$itemcnt++]["Quantity"] = $orderitem[2]; } } fclose($fp); // just for testing, dump the arrays -- while(list($key,$val) = each($billinginfo)) { echo "$key -> $val \n"; } echo "ORDER HERE!!!\n"; for($x=0; $x<$itemcnt; $x++) { echo "Item: $x \n"; while(list($k,$v) = each($order[$x])) { echo "$k -> $v \n"; } echo "\n"; } ?> On Sat, Nov 24, 2001 at 10:20:45PM -0700, Ashley M. Kirchner wrote: > > I need to "convert" the following: > > --------------------------------------------------- > Todays Date: 20-Nov-2001 10:58:24AM > Order ID: W25 > Customer Email: [EMAIL PROTECTED] > Email Promotions: Ok > > BILL TO: > Business Name: > Contact Name: Ashley M. Kirchner > Day Number: 800 555-1212 > Evening Number: 303 555-1212 > Fax Number: > Address: 3550 Arapahoe Ave #6 > Address: > Address: > City: Boulder > State/Province: CO > Zip/Postal Code: 80303 > Country: USA > > Payment Method: CC > > Card Number: 99****1234 > Expiration Date: 01/71 > > Shipping Method: PICKUP > Order Comment: > Gift Message: > Shipping > Instruction: > --------------------------------------------------- > > ...into $key, $value pairs. Ideally, I'd like to be able to name/use my own >names for $key so I can end up with something like: > > $BillToContact => 'Ashley M. Kirchner' > $BillToDayPhone => '800 555-1212' > $BillToEvePhone => '303 555-1212' > etc. > (or maybe with something like: > $bill['contact'] => 'Ashley M. Kirchner' > $bill['dayphone'] => '800 555-1212' > $bill['evephone'] => '303 555-1212' > etc.) > > All of these variables will eventually be shoved into a DB once the entire form >has been parsed. > > And then, at the bottom of that same (submitted) form, there's the actual >information on the order, which looks something like this (the spacing is slightly >different): > > (unfortunately, this will wrap rather ugly) > --------------------------------------------------- > ORDER NO. QTY UNIT DESCRIPTION PRICE TOTAL > 4x6 1 4"x6" Standard Print (full-frame from 35mm) .75 $0.75 > 4x6 1 4"x6" Standard Print (full-frame from 35mm) .75 $0.75 > 5x7.5 1 5x7.5 Image:Uploaded Image 3 4.25 $4.25 > 8x12 1 8x12 Classic Full Frame Image:Uploaded Image 4 10.25 $10.25 > > SUBTOTAL: $16.00 > TAX: $1.18 > SHIPPING: $0.00 > TOTAL: $17.18 > --------------------------------------------------- > > > This part again I'd like to break up into separate lines, and separate variables >for the product no., the quantity, unit, decription, price, total (per line), then >the subtotal, tax, shipping cost and final (grant) total. > > Again, if I can somehow use my own variable names, that'd be great. > > ($product['no'] > $product['quantity'] > $product['unit'] > etc. > $order['subtotal'] > $order['tax'] > $order['shipping'] > $order['total'] > etc.) > > I don't know yet how to create different entries for each line in that order - >kinda stupid to create $product_1['no'], $product_2['no'], $product_3['no'], >$product_4['no'], but then again, I don't know. > > -- > H | "Life is the art of drawing without an eraser." - John Gardner > +-------------------------------------------------------------------- > Ashley M. Kirchner <mailto:[EMAIL PROTECTED]> . 303.442.6410 x130 > Director of Internet Operations / SysAdmin . 800.441.3873 x130 > Photo Craft Laboratories, Inc. . 3550 Arapahoe Ave, #6 > http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- Hank Marquardt <[EMAIL PROTECTED]> http://web.yerpso.net GPG Id: 2BB5E60C Fingerprint: D807 61BC FD18 370A AC1D 3EDF 2BF9 8A2D 2BB5 E60C *** Web Development: PHP, MySQL/PgSQL - Network Admin: Debian/FreeBSD *** PHP Instructor - Intnl. Webmasters Assn./HTML Writers Guild *** Beginning PHP -- Starts January 7, 2002 *** See http://www.hwg.org/services/classesmsg41030/pgp00000.pgp
--- End Message ---
Description: PGP signature
--- Begin Message ---Hi, To test a new php installation I accessed a page called index.php that contains only <?php phpinfo(); ?> but that produces this error: Warning: Failed opening '' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/include/php:/usr/local/bin/ph p') in Unknown on line 0 This seems very odd given that: a) the error does not specify any filename that failed opening, only '', and b) permissions of the index.php file and the include path directories are readable by all users. I have even started the php fastcgi runner as root to double-check the permissions aspect of this. The setup is php 4.0.6 with Zeus webserver version 4 using FastCGI on Solaris 2.6. Any ideas? Help of any sort would be greatly appreciated. Thanks, Dave De Graff--- End Message ---
--- Begin Message ---> >To test a new php installation I accessed a page called index.php that >contains only <?php phpinfo(); ?> Perhaps you want to: <?phpinfo();?> Not sure if anything else should produce errors.. Bye, B.--- End Message ---
--- Begin Message ---Hi Can anyone explain classes to me please? On many sites have I seen classes, I'm not sure how these work, or how to use them. I'm still learning about php, and I get it going nicely. Is a class something like a variable (but as a whole script) that I simply include into my other scripts? Your help would be grateful as I'm still learning, and all info or knowledge helps Regards Rudi Ahlers--- End Message ---
--- Begin Message ---On Sun, 25 Nov 2001, Rudi Ahlers wrote: > Can anyone explain classes to me please? On many sites have I seen classes, There are people earning PHD's while explaining classes. I know your question originates from using PHP, and this is a PHP general mailing list ... but your question is just a tad too general for this list. > I'm not sure how these work, or how to use them. I'm still learning about Classes aren't unique to PHP. You need to learn a true object-oriented programming language (C++, Java, ... etc.) to really learn classes. Truly gifted individuals can learn object-oriented programming w/o too much help, but they'd first have a firm grip on programming. I'd expect the average, novice programmer to need a good amount of help learning & understanding objecte-oriented programming ... like that attained from a University, a good High School, or a lot of independent study and time experimenting with code. That said ... You weren't completely missing the boat with your analogy of a class to a variable, but in the same breath, that idea is totally missing the boat (I can see from where you're coming, and to where you're headed). Classes are an IDEA. They're not actually anything. They're the definition of private and public data members and methods that should make up an object. When a class is instantiated, an object is created with the defined data members and methods available. You can then use the objects' methods to set, get, alter, or otherwise interact with its data members, or to simply perform a set of related operations. <Insert a couple semesters of theory here.> That's my feeble attempt to explain classes. It's abstract, I know, and possibly not a help at all. But it's because of the paragraph above this one. Let's look at some petty code: class chair{ // DATA var num_legs; var color; var num_arms; // METHODS function chair( $legs = 3, $arms = 0 ){ //CONSTRUCTOR $this->num_legs = $legs; $this->num_arms = $arms; } function setLegs( $legs ){ $this->num_legs = $legs; return; } function getLegs( ){ return $this->num_legs; } // ... *clip* ... } Above is the [incomplete] definition of a chair class. As you can see, the class is useless. But you can instantiate the class, and create a useable object ... you can now create a chair. $myChair = new chair( 4, 2 ); Now I have a chair [object] with 4 legs and 2 arms, called $myChair. Let's have the chair tell us how many legs it has ... $numLegsOnMyChair = $myChair->getLegs(); print( "My Chair has $numLegsOnMyChair legs." ); Lets change how many legs the chair has ... $myChair->setLegs( 7 ); // very odd, seven-legged chair We should have a chair with 7 legs now, instead of 4. Prove it ... $numLegsOnMyChair = $myChair->getLegs(); print( "My Chair has $numLegsOnMyChair legs." ); (As you alluded to previously, the object $myChair is seemingly a variable that has access to scripts ... but I hope you see now that $myChair is an object with methods and data members, not a variable.) That's very simple, and not too useful. Which brings me to the next point. Knowing object-oriented programming is to know when and when not to use it (especially with PHP). I don't need a class definition and an object for a one-time use 7-legged chair. But I may need a class definition if I were making many complete graph data structures, each with a number of nodes equal to a unique number in the Fibonacci sequence. I wouldn't want to re-code the basic logic of a complete graph over and over for each graph. I could just instantiate graph objects, each with different numbers of nodes, much like I did with the chair, above. </ramble> g.luck, ~Chris /"\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden--- End Message ---
--- Begin Message ---Chris, Not such a useless explanation at all, in fact a damned good one. Tight & concise, and you immediately related the functions to code examples, along with an easy-to-visualize object, the chair. But I have two questions: 1. Why is a constructor class needed? My OO background is Visual FoxPro, and all it requires is a declaration of the class, it' methods and properties. 2. Are the chairs properties exposed, or are they private? You use functions to both set and retrieve them, which implies that they are private. Even so, PHP's syntax is much cleaner than the tortured syntax used in VB. Miles Thompson At 03:28 AM 11/25/2001 -0800, you wrote: >On Sun, 25 Nov 2001, Rudi Ahlers wrote: > > Can anyone explain classes to me please? On many sites have I seen classes, > >There are people earning PHD's while explaining classes. I know your >question originates from using PHP, and this is a PHP general mailing list >... but your question is just a tad too general for this list. > > > I'm not sure how these work, or how to use them. I'm still learning about > >Classes aren't unique to PHP. You need to learn a true object-oriented >programming language (C++, Java, ... etc.) to really learn classes. >Truly gifted individuals can learn object-oriented programming w/o too >much help, but they'd first have a firm grip on programming. I'd expect >the average, novice programmer to need a good amount of help learning & >understanding objecte-oriented programming ... like that attained from a >University, a good High School, or a lot of independent study and time >experimenting with code. > >That said ... > >You weren't completely missing the boat with your analogy of a class to a >variable, but in the same breath, that idea is totally missing the boat (I >can see from where you're coming, and to where you're headed). Classes >are an IDEA. They're not actually anything. They're the definition of >private and public data members and methods that should make up an object. >When a class is instantiated, an object is created with the defined data >members and methods available. You can then use the objects' methods to >set, get, alter, or otherwise interact with its data members, or to simply >perform a set of related operations. <Insert a couple semesters of theory >here.> That's my feeble attempt to explain classes. It's abstract, I >know, and possibly not a help at all. But it's because of the paragraph >above this one. > >Let's look at some petty code: > >class chair{ > // DATA > var num_legs; > var color; > var num_arms; > > // METHODS > function chair( $legs = 3, $arms = 0 ){ //CONSTRUCTOR > $this->num_legs = $legs; > $this->num_arms = $arms; > } > > function setLegs( $legs ){ > $this->num_legs = $legs; > return; > } > function getLegs( ){ > return $this->num_legs; > } > > // ... *clip* ... >} > > >Above is the [incomplete] definition of a chair class. As you can see, >the class is useless. But you can instantiate the class, and create a >useable object ... you can now create a chair. > >$myChair = new chair( 4, 2 ); > >Now I have a chair [object] with 4 legs and 2 arms, called $myChair. >Let's have the chair tell us how many legs it has ... > >$numLegsOnMyChair = $myChair->getLegs(); >print( "My Chair has $numLegsOnMyChair legs." ); > >Lets change how many legs the chair has ... > >$myChair->setLegs( 7 ); // very odd, seven-legged chair > >We should have a chair with 7 legs now, instead of 4. Prove it ... > >$numLegsOnMyChair = $myChair->getLegs(); >print( "My Chair has $numLegsOnMyChair legs." ); > >(As you alluded to previously, the object $myChair is seemingly a variable >that has access to scripts ... but I hope you see now that $myChair is an >object with methods and data members, not a variable.) > >That's very simple, and not too useful. Which brings me to the next >point. Knowing object-oriented programming is to know when and when not >to use it (especially with PHP). I don't need a class definition and an >object for a one-time use 7-legged chair. But I may need a class >definition if I were making many complete graph data structures, each with >a number of nodes equal to a unique number in the Fibonacci sequence. I >wouldn't want to re-code the basic logic of a complete graph over and over >for each graph. I could just instantiate graph objects, each with >different numbers of nodes, much like I did with the chair, above. ></ramble> > > g.luck, > ~Chris /"\ > \ / September 11, 2001 > X We Are All New Yorkers > / \ rm -rf /bin/laden > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED]--- End Message ---
--- Begin Message ---Miles, I have come from a QBASIC to VFP to VC++ to PHP (VFP and PHP are my primary languages), so I'll try to clear it up a bit. In VFP, there is no constructor. I believe that the equivalent is the init() method. The init() method, or the constructor (in PHP, C++, etc) are useful for doing stuff that needs to be done when an object is created. Likewise in true object oriented languages (PHP is not one of them yet), there is a Destructor that is called when an object goes out of scope or is deleted. In VFP, there is a Destroy() method to simulate this behavior. In VFP, there is the notion of Public, Private, and Hidden properties. PHP does not yet support this behavior. In PHP, especially since it is such a loosely typed language, you can add and remove properties on the fly. Generally when programming in PHP, I like to identify private properties and methods by placing a single underscore before their name. This makes it clear for someone using the class not to ever reference these entities. If you want to see a neat example of object oriented programming in action (not that I like M$ or anything), check out how the Microsoft Foundation Classes (MFC) work. They effectively demonstrate public and private class members, inheritance, constructors, destructors, parent objects, etc... Hope it Helped... -Jason Garber IonZoft.com At 09:10 AM 11/25/2001 -0400, Miles Thompson wrote: >Chris, > >Not such a useless explanation at all, in fact a damned good one. Tight & >concise, and you immediately related the functions to code examples, along >with an easy-to-visualize object, the chair. > >But I have two questions: > >1. Why is a constructor class needed? My OO background is Visual FoxPro, >and all it requires is a declaration of the class, it' methods and properties. > >2. Are the chairs properties exposed, or are they private? You use >functions to both set and retrieve them, which implies that they are >private. Even so, PHP's syntax is much cleaner than the tortured syntax >used in VB. > >Miles Thompson > >At 03:28 AM 11/25/2001 -0800, you wrote: >>On Sun, 25 Nov 2001, Rudi Ahlers wrote: >> > Can anyone explain classes to me please? On many sites have I seen >> classes, >> >>There are people earning PHD's while explaining classes. I know your >>question originates from using PHP, and this is a PHP general mailing list >>... but your question is just a tad too general for this list. >> >> > I'm not sure how these work, or how to use them. I'm still learning about >> >>Classes aren't unique to PHP. You need to learn a true object-oriented >>programming language (C++, Java, ... etc.) to really learn classes. >>Truly gifted individuals can learn object-oriented programming w/o too >>much help, but they'd first have a firm grip on programming. I'd expect >>the average, novice programmer to need a good amount of help learning & >>understanding objecte-oriented programming ... like that attained from a >>University, a good High School, or a lot of independent study and time >>experimenting with code. >> >>That said ... >> >>You weren't completely missing the boat with your analogy of a class to a >>variable, but in the same breath, that idea is totally missing the boat (I >>can see from where you're coming, and to where you're headed). Classes >>are an IDEA. They're not actually anything. They're the definition of >>private and public data members and methods that should make up an object. >>When a class is instantiated, an object is created with the defined data >>members and methods available. You can then use the objects' methods to >>set, get, alter, or otherwise interact with its data members, or to simply >>perform a set of related operations. <Insert a couple semesters of theory >>here.> That's my feeble attempt to explain classes. It's abstract, I >>know, and possibly not a help at all. But it's because of the paragraph >>above this one. >> >>Let's look at some petty code: >> >>class chair{ >> // DATA >> var num_legs; >> var color; >> var num_arms; >> >> // METHODS >> function chair( $legs = 3, $arms = 0 ){ //CONSTRUCTOR >> $this->num_legs = $legs; >> $this->num_arms = $arms; >> } >> >> function setLegs( $legs ){ >> $this->num_legs = $legs; >> return; >> } >> function getLegs( ){ >> return $this->num_legs; >> } >> >> // ... *clip* ... >>} >> >> >>Above is the [incomplete] definition of a chair class. As you can see, >>the class is useless. But you can instantiate the class, and create a >>useable object ... you can now create a chair. >> >>$myChair = new chair( 4, 2 ); >> >>Now I have a chair [object] with 4 legs and 2 arms, called $myChair. >>Let's have the chair tell us how many legs it has ... >> >>$numLegsOnMyChair = $myChair->getLegs(); >>print( "My Chair has $numLegsOnMyChair legs." ); >> >>Lets change how many legs the chair has ... >> >>$myChair->setLegs( 7 ); // very odd, seven-legged chair >> >>We should have a chair with 7 legs now, instead of 4. Prove it ... >> >>$numLegsOnMyChair = $myChair->getLegs(); >>print( "My Chair has $numLegsOnMyChair legs." ); >> >>(As you alluded to previously, the object $myChair is seemingly a variable >>that has access to scripts ... but I hope you see now that $myChair is an >>object with methods and data members, not a variable.) >> >>That's very simple, and not too useful. Which brings me to the next >>point. Knowing object-oriented programming is to know when and when not >>to use it (especially with PHP). I don't need a class definition and an >>object for a one-time use 7-legged chair. But I may need a class >>definition if I were making many complete graph data structures, each with >>a number of nodes equal to a unique number in the Fibonacci sequence. I >>wouldn't want to re-code the basic logic of a complete graph over and over >>for each graph. I could just instantiate graph objects, each with >>different numbers of nodes, much like I did with the chair, above. >></ramble> >> >> g.luck, >> ~Chris /"\ >> \ / September 11, 2001 >> X We Are All New Yorkers >> / \ rm -rf /bin/laden >> >> >>-- >>PHP General Mailing List (http://www.php.net/) >>To unsubscribe, e-mail: [EMAIL PROTECTED] >>For additional commands, e-mail: [EMAIL PROTECTED] >>To contact the list administrators, e-mail: [EMAIL PROTECTED] > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] >--- End Message ---
--- Begin Message ---Miles, I have come from a QBASIC to VFP to VC++ to PHP (VFP and PHP are my primary languages), so I'll try to clear it up a bit. In VFP, there is no constructor. I believe that the equivalent is the init() method. The init() method, or the constructor (in PHP, C++, etc) are useful for doing stuff that needs to be done when an object is created. Likewise in true object oriented languages (PHP is not one of them yet), there is a Destructor that is called when an object goes out of scope or is deleted. In VFP, there is a Destroy() method to simulate this behavior. In VFP, there is the notion of Public, Private, and Hidden properties. PHP does not yet support this behavior. In PHP, especially since it is such a loosely typed language, you can add and remove properties on the fly. Generally when programming in PHP, I like to identify private properties and methods by placing a single underscore before their name. This makes it clear for someone using the class not to ever reference these entities. If you want to see a neat example of object oriented programming in action (not that I like M$ or anything), check out how the Microsoft Foundation Classes (MFC) work. They effectively demonstrate public and private class members, inheritance, constructors, destructors, parent objects, etc... Hope it Helped... -Jason Garber IonZoft.com At 09:10 AM 11/25/2001 -0400, Miles Thompson wrote: >Chris, > >Not such a useless explanation at all, in fact a damned good one. Tight & >concise, and you immediately related the functions to code examples, along >with an easy-to-visualize object, the chair. > >But I have two questions: > >1. Why is a constructor class needed? My OO background is Visual FoxPro, >and all it requires is a declaration of the class, it' methods and properties. > >2. Are the chairs properties exposed, or are they private? You use >functions to both set and retrieve them, which implies that they are >private. Even so, PHP's syntax is much cleaner than the tortured syntax >used in VB. > >Miles Thompson > >At 03:28 AM 11/25/2001 -0800, you wrote: >>On Sun, 25 Nov 2001, Rudi Ahlers wrote: >> > Can anyone explain classes to me please? On many sites have I seen >> classes, >> >>There are people earning PHD's while explaining classes. I know your >>question originates from using PHP, and this is a PHP general mailing list >>... but your question is just a tad too general for this list. >> >> > I'm not sure how these work, or how to use them. I'm still learning about >> >>Classes aren't unique to PHP. You need to learn a true object-oriented >>programming language (C++, Java, ... etc.) to really learn classes. >>Truly gifted individuals can learn object-oriented programming w/o too >>much help, but they'd first have a firm grip on programming. I'd expect >>the average, novice programmer to need a good amount of help learning & >>understanding objecte-oriented programming ... like that attained from a >>University, a good High School, or a lot of independent study and time >>experimenting with code. >> >>That said ... >> >>You weren't completely missing the boat with your analogy of a class to a >>variable, but in the same breath, that idea is totally missing the boat (I >>can see from where you're coming, and to where you're headed). Classes >>are an IDEA. They're not actually anything. They're the definition of >>private and public data members and methods that should make up an object. >>When a class is instantiated, an object is created with the defined data >>members and methods available. You can then use the objects' methods to >>set, get, alter, or otherwise interact with its data members, or to simply >>perform a set of related operations. <Insert a couple semesters of theory >>here.> That's my feeble attempt to explain classes. It's abstract, I >>know, and possibly not a help at all. But it's because of the paragraph >>above this one. >> >>Let's look at some petty code: >> >>class chair{ >> // DATA >> var num_legs; >> var color; >> var num_arms; >> >> // METHODS >> function chair( $legs = 3, $arms = 0 ){ //CONSTRUCTOR >> $this->num_legs = $legs; >> $this->num_arms = $arms; >> } >> >> function setLegs( $legs ){ >> $this->num_legs = $legs; >> return; >> } >> function getLegs( ){ >> return $this->num_legs; >> } >> >> // ... *clip* ... >>} >> >> >>Above is the [incomplete] definition of a chair class. As you can see, >>the class is useless. But you can instantiate the class, and create a >>useable object ... you can now create a chair. >> >>$myChair = new chair( 4, 2 ); >> >>Now I have a chair [object] with 4 legs and 2 arms, called $myChair. >>Let's have the chair tell us how many legs it has ... >> >>$numLegsOnMyChair = $myChair->getLegs(); >>print( "My Chair has $numLegsOnMyChair legs." ); >> >>Lets change how many legs the chair has ... >> >>$myChair->setLegs( 7 ); // very odd, seven-legged chair >> >>We should have a chair with 7 legs now, instead of 4. Prove it ... >> >>$numLegsOnMyChair = $myChair->getLegs(); >>print( "My Chair has $numLegsOnMyChair legs." ); >> >>(As you alluded to previously, the object $myChair is seemingly a variable >>that has access to scripts ... but I hope you see now that $myChair is an >>object with methods and data members, not a variable.) >> >>That's very simple, and not too useful. Which brings me to the next >>point. Knowing object-oriented programming is to know when and when not >>to use it (especially with PHP). I don't need a class definition and an >>object for a one-time use 7-legged chair. But I may need a class >>definition if I were making many complete graph data structures, each with >>a number of nodes equal to a unique number in the Fibonacci sequence. I >>wouldn't want to re-code the basic logic of a complete graph over and over >>for each graph. I could just instantiate graph objects, each with >>different numbers of nodes, much like I did with the chair, above. >></ramble> >> >> g.luck, >> ~Chris /"\ >> \ / September 11, 2001 >> X We Are All New Yorkers >> / \ rm -rf /bin/laden >> >> >>-- >>PHP General Mailing List (http://www.php.net/) >>To unsubscribe, e-mail: [EMAIL PROTECTED] >>For additional commands, e-mail: [EMAIL PROTECTED] >>To contact the list administrators, e-mail: [EMAIL PROTECTED] > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED]--- End Message ---
--- Begin Message ---Miles, I have come from a QBASIC to VFP to VC++ to PHP (VFP and PHP are my primary languages), so I'll try to clear it up a bit. In VFP, there is no constructor. I believe that the equivalent is the init() method. The init() method, or the constructor (in PHP, C++, etc) are useful for doing stuff that needs to be done when an object is created. Likewise in true object oriented languages (PHP is not one of them yet), there is a Destructor that is called when an object goes out of scope or is deleted. In VFP, there is a Destroy() method to simulate this behavior. In VFP, there is the notion of Public, Private, and Hidden properties. PHP does not yet support this behavior. In PHP, especially since it is such a loosely typed language, you can add and remove properties on the fly. Generally when programming in PHP, I like to identify private properties and methods by placing a single underscore before their name. This makes it clear for someone using the class not to ever reference these entities. If you want to see a neat example of object oriented programming in action (not that I like M$ or anything), check out how the Microsoft Foundation Classes (MFC) work. They effectively demonstrate public and private class members, inheritance, constructors, destructors, parent objects, etc... Hope it Helped... -Jason Garber IonZoft.com At 09:10 AM 11/25/2001 -0400, Miles Thompson wrote: >Chris, > >Not such a useless explanation at all, in fact a damned good one. Tight & >concise, and you immediately related the functions to code examples, along >with an easy-to-visualize object, the chair. > >But I have two questions: > >1. Why is a constructor class needed? My OO background is Visual FoxPro, >and all it requires is a declaration of the class, it' methods and properties. > >2. Are the chairs properties exposed, or are they private? You use >functions to both set and retrieve them, which implies that they are >private. Even so, PHP's syntax is much cleaner than the tortured syntax >used in VB. > >Miles Thompson > >At 03:28 AM 11/25/2001 -0800, you wrote: >>On Sun, 25 Nov 2001, Rudi Ahlers wrote: >> > Can anyone explain classes to me please? On many sites have I seen >> classes, >> >>There are people earning PHD's while explaining classes. I know your >>question originates from using PHP, and this is a PHP general mailing list >>... but your question is just a tad too general for this list. >> >> > I'm not sure how these work, or how to use them. I'm still learning about >> >>Classes aren't unique to PHP. You need to learn a true object-oriented >>programming language (C++, Java, ... etc.) to really learn classes. >>Truly gifted individuals can learn object-oriented programming w/o too >>much help, but they'd first have a firm grip on programming. I'd expect >>the average, novice programmer to need a good amount of help learning & >>understanding objecte-oriented programming ... like that attained from a >>University, a good High School, or a lot of independent study and time >>experimenting with code. >> >>That said ... >> >>You weren't completely missing the boat with your analogy of a class to a >>variable, but in the same breath, that idea is totally missing the boat (I >>can see from where you're coming, and to where you're headed). Classes >>are an IDEA. They're not actually anything. They're the definition of >>private and public data members and methods that should make up an object. >>When a class is instantiated, an object is created with the defined data >>members and methods available. You can then use the objects' methods to >>set, get, alter, or otherwise interact with its data members, or to simply >>perform a set of related operations. <Insert a couple semesters of theory >>here.> That's my feeble attempt to explain classes. It's abstract, I >>know, and possibly not a help at all. But it's because of the paragraph >>above this one. >> >>Let's look at some petty code: >> >>class chair{ >> // DATA >> var num_legs; >> var color; >> var num_arms; >> >> // METHODS >> function chair( $legs = 3, $arms = 0 ){ //CONSTRUCTOR >> $this->num_legs = $legs; >> $this->num_arms = $arms; >> } >> >> function setLegs( $legs ){ >> $this->num_legs = $legs; >> return; >> } >> function getLegs( ){ >> return $this->num_legs; >> } >> >> // ... *clip* ... >>} >> >> >>Above is the [incomplete] definition of a chair class. As you can see, >>the class is useless. But you can instantiate the class, and create a >>useable object ... you can now create a chair. >> >>$myChair = new chair( 4, 2 ); >> >>Now I have a chair [object] with 4 legs and 2 arms, called $myChair. >>Let's have the chair tell us how many legs it has ... >> >>$numLegsOnMyChair = $myChair->getLegs(); >>print( "My Chair has $numLegsOnMyChair legs." ); >> >>Lets change how many legs the chair has ... >> >>$myChair->setLegs( 7 ); // very odd, seven-legged chair >> >>We should have a chair with 7 legs now, instead of 4. Prove it ... >> >>$numLegsOnMyChair = $myChair->getLegs(); >>print( "My Chair has $numLegsOnMyChair legs." ); >> >>(As you alluded to previously, the object $myChair is seemingly a variable >>that has access to scripts ... but I hope you see now that $myChair is an >>object with methods and data members, not a variable.) >> >>That's very simple, and not too useful. Which brings me to the next >>point. Knowing object-oriented programming is to know when and when not >>to use it (especially with PHP). I don't need a class definition and an >>object for a one-time use 7-legged chair. But I may need a class >>definition if I were making many complete graph data structures, each with >>a number of nodes equal to a unique number in the Fibonacci sequence. I >>wouldn't want to re-code the basic logic of a complete graph over and over >>for each graph. I could just instantiate graph objects, each with >>different numbers of nodes, much like I did with the chair, above. >></ramble> >> >> g.luck, >> ~Chris /"\ >> \ / September 11, 2001 >> X We Are All New Yorkers >> / \ rm -rf /bin/laden >> >> >>-- >>PHP General Mailing List (http://www.php.net/) >>To unsubscribe, e-mail: [EMAIL PROTECTED] >>For additional commands, e-mail: [EMAIL PROTECTED] >>To contact the list administrators, e-mail: [EMAIL PROTECTED] > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED]--- End Message ---
--- Begin Message ---Yeah, use a real client program like Terra Term. -Jason Garber At 05:07 PM 11/24/2001 +0000, cosmin laslau wrote: >I've got a huge table that I'm trying to get information about. I use a >MySQL database, and the windows telnet utility to access it. To see info >about the table, the DESCRIBE command is used. However, since it's about >40 fields, it doesn't fit on the screen, so the top half just zips by in a >millisecond. > >Is there any break command, something to show one screen of info, read >key, and then show another screen, for the DESCRIBE command? > >Or just any other way to see the information... > >Thanks. > >_________________________________________________________________ >Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] >--- End Message ---
--- Begin Message ---I am trying to use php and gnupg on my virtual host to send user input to myself in encryptd form. The problem I am having is that I have installed gnupg in my user account and it is functional, but the keyring and keys that I have generated are under my user name for the account. Php runs under the user name "nobody" and does not have access to the keys for encryption. I have spoken to a tech at the company who said that I would not be allowed to install keys under "nobody". I'm not quite sure I believe this. Anyway, as a way to get around this, I have tried to run the php script as cgi, by putting the script into the cgi-bin in my user directory. This way the scripts should run as my username. Here is the script: #!/usr/local/bin/php $filename = "/home/gildedpg/public_html/mydata.txt"; $newfile = fopen($filename, "w+") or die("Couldn't create file."); fclose($newfile); $msg = "<p>File created!</p>"; <html> <head> <title></title> </head> <body> <? echo "$msg"; ?> </body> </html> This is the error I get: CGIwrap Error: System Error: execv() failed Error: No such file or directory (2) If anyone could tell me why this script will not run, or better yet, make any suggestions to make this process workwithout using cgi, I would appreciate it. Thanks, SW--- End Message ---
--- Begin Message ---Hi, is there a way to redirect after a script has run? I have a form whos result is being put into a database. When, or if, the operation is sucessful i set a variable $done to 1. Now, i need a redirection from here (if $done is 1). But since i cant send out headers that far down on the page - what do i do? Regards # Daniel Alsén | www.mindbash.com # # [EMAIL PROTECTED] | +46 704 86 14 92 # # ICQ: 63006462 | #--- End Message ---
--- Begin Message ---What scenario do you have? 1. User fills in a form somewhere & those values get transmitted to another script which processes them or 2. User fills in a form, clicks "submit" which calls the same script, passing itself the values. Depending on the value passed by the submit button, the script processes the information (INSERT or UPDATE) and sets $done = 1 if successful. The second scenario is easier to handle. Call the same script, passing it $done, and depending on whether or not $done is set you redirect. Juli Meloni has done an excellent tutorial on just this at http://www.thickbook.com. look in the tutorials for something like "Form With Error Message". You just have to adapt the logic to suit your needs. Miles Thompson At 03:56 PM 11/25/2001 +0100, Daniel Alsén wrote: >Hi, > >is there a way to redirect after a script has run? > >I have a form whos result is being put into a database. When, or if, the >operation is sucessful i set a variable $done to 1. > >Now, i need a redirection from here (if $done is 1). But since i cant send >out headers that far down on the page - what do i do? > >Regards ># Daniel Alsén | www.mindbash.com # ># [EMAIL PROTECTED] | +46 704 86 14 92 # ># ICQ: 63006462 | # > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED]--- End Message ---