Re: [PHP] Php Projects
on 2/8/02 12:49 PM, Nick Wilson at [EMAIL PROTECTED] wrote: Do I detect a bit of Friday-afternoon sarcasm??? GRIN Actually, a beer sounds good about now Friday evening in .dk and php is always best served with a cold one! reminds me of my days as a netadmin. playing with routers late on a friday night after a few cold ones was always fun :) -- mike cullerton michaelc at bakednotfried dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] copy + chmod problems ...
i just tried a test and it works on MacOS X. even with the space between 'chmod' and '('. what platform are you on? is this a standalone script/app or from a web page? can you perform the chmod from the command-line? what is the entire error message? also, the error doesn't really suggest this, but have you tried using the full path? on 2/7/02 8:07 AM, jeremy rotsztain at [EMAIL PROTECTED] wrote: hello, i'm attempting to copy a file from its original location to a new folder ... $oldfile = files/adamsCampbells.swf; $newfile = photos/adamsCampbells.swf; $test = copy($oldfile, $newfile); however, in doing so, i'm encountering some problems: Warning: Unable to create 'adamsCampbells.swf': Permission denied i've been trying to change permissions so that i can copy the file, but i'm encountering some errors chmod (files, 0777); Badly placed ()'s. does anybody recognize any problems with my approach or have any advice? dnke, jeremy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why does heredoc fail in this instance?
on 2/4/02 11:32 AM, Peter J. Schoenster at [EMAIL PROTECTED] wrote: Hi If I use $snippet = ; and escape the quotes in the block then it works. But if I use it as is below, it fails with no useful error message. Why? not sure if this is it or not, but from the manual http://www.php.net/manual/en/language.types.string.php Variables are expanded, but the same care must be taken when expressing complex variables inside a here doc as with strings. i wonder if $this-this_cgi is causing the problem Thanks, Peter function GetAddCommentSnippet($args) { $topic_id= $args[id]; $return_page= $args[return_page]; $snippet = EOS form action=$this-this_cgi method=post brYour First Name: input type=text name=FirstName value= brYour Last Name: input type=text name=LastName value= brYour Email Address: input type=text name=EmailAddress value= brYour Comments: br textarea cols=40 rows=4 name=Comments/textarea br input type=submit value=submit now input type=hidden name=action value=AddComment input type=hidden name=response_to_id value=$topic_id input type=hidden name=r value=$return_page /form EOS; return $snippet; } // END GetAddCommentSnippet --- Reality is that which, when you stop believing in it, doesn't go away. -- Philip K. Dick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Attaching a file via MAIL()
on 2/1/02 11:36 AM, Dave at [EMAIL PROTECTED] wrote: How can I add an attachment to an email using MAIL(). So far I have been able to successfully send email by using: mail($to, $subject, $message, $headers); Is there something I can add in the $headers to add an attachment?? you really want to read the rfc for this. i think it is 821. google for 'smtp rfc' and you should be able to find it. here is a function i wrote when i was first learning php, and i'm sure it can be cleaned up, but it usually works for me. hope it helps, mike function mail_attachment($to,$subject,$attachment,$attachmentType=,$filename=,$me ssage=) { if ($attachmentType==) $attachmentType = text/plain; charset=US-ASCII; $timestring = md5(time()); $seperator = NextPart_$timestring; $header = MIME-Version: 1.0\nContent-Type: multipart/mixed;\n boundary=\$seperator\\n this is some extra text that should be ignored. if you can read this, perhaps you should upgrade your email program.\n; if ($filename !=) { $attachpreface = \n--$seperator Content-Type: $attachmentType; name=\$filename\ Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=\$filename\; } else { $attachpreface = \n--$seperator Content-Type: $attachmentType Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; } $messagepreface = \n--$seperator Content-Type: text/plain; charset=US-ASCII; $attachment = $attachpreface\n\n.$attachment.\n--$seperator; if ($message != ) { $message = $messagepreface\n\n.$message.$attachment; } else { $message = $attachment; } //echo $header\n$message\n; mail ($to,$subject,$message,$header); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] command line are -c doesn't work on win2k?
on 1/18/02 12:00 AM, Jeff D. Hamann at [EMAIL PROTECTED] wrote: I've been trying to figure out what was wrong with my script... ? mail([EMAIL PROTECTED], Subject, command line mail() test); ? from the command line, php mail_test.php and getting, X-Powered-By: PHP/4.0.6 Content-type: text/html attempting to deliver the mailbr bWarning/b: Unknown error in bmail_test.php/b on line b3/bbr didn't notice any other responses, and this is just a guess here, but how about taking the '()' out of the body of the message. ie, command line mail test -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] help installing php
hi juni, although i totally agree with the folks who recommended you compile php from source, maybe it's time you sat down :) compiling apache, mysql and php from source can tax even the greatest patience the first time it is tried. hopefully, here's a couple things to think about. create a directory where you store _all_ your source for everything you compile. lots of folks use /usr/src and i'll assume that here. now, download all the source tarballs you need into that directory and expand them all in there. this should create subdirectories for everything. ie, /usr/src/apache_1.3.22 /usr/src/php-4.1.0 /usr/src/mysql-3.23.40 it's possible that you may need other packages. only you will now what is used on your machine. do you use snmp with php? gd? do y'all also use perl with apache? you'll want to read the documentation that comes with _each_ package you are compiling. especially apache. they know about php. there is lots of good info in there. there are also many sites out there with tutorials on getting these all to compile together. you'll need to decide if you want to compile php as a static or dynamic module. static seems to compile easier for some folks, but dynamic means in the future you only need to recompile php to upgrade it (as opposed to recompiling everything like you are about to do :) the first time you do this, it could take hours just getting it all squared away, and that doesn't necessarily include compile time. after that, it should only take you a few minutes each time. to answer the specific question about apache source, if we assume the directories above, then you would use ../apache_1.3.22. i recommend writing down everything it took to get it all working so you have it for next time. the configure string might look something like ./configure \ --enable-track-vars \ --with-mysql=/usr/local \ --with-apache=/usr/src/apache_1.3.22 \ --enable-trans-sid \ --with-snmp \ --with-ftp \ --with-gd depending on what all you need from php. hope this all helps, mike on 1/18/02 12:09 PM, Juni Adi at [EMAIL PROTECTED] wrote: Ok, I'm now in the middle of installing it from source code. But I'm not sure where the path to apache and mysql source code to fill in : ./configure --with apache=/path/to/apache_source_code --with mysql=/path/to/mysql_source_code I 'm even not I have the source code for the two of them as I was instaling both apache and mysql from rpms. So, can you tell me to define the path for those apache and mysql so I can make the PHP work along with apache and mysql as well? Or at least tell me what indicate a source code directory (what files are in). Maybe I can search it manually. -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] $this objects and vars
on 1/18/02 8:58 AM, TD - Sales International Holland B.V. at [EMAIL PROTECTED] wrote: now further in the script you'll get an sql query $this = mysql_fetch_array(indentifier); now as far as I knew you shouldn't be possible to use $this for this purpose, it has nothing to do with objects... why can it be used? it's only confusing things. The script works tho... this is only a guess, but maybe separate namespaces. one is an array and one is an object. the object $this should only exist inside a method definition, right? $this outside of that context isn't referring to itself at that point but some memory space allocated to the variable named 'this' instead, i guess. ? mike -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] command line are -c doesn't work on win2k?
what about the [EMAIL PROTECTED]? is it failing on a 'bad' email address? or maybe putting everything in variables and trying mail($to,$subject,$message); on 1/18/02 9:14 AM, Jeff D. Hamann at [EMAIL PROTECTED] wrote: nope. no difference. jeff. Mike Cullerton [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... on 1/18/02 12:00 AM, Jeff D. Hamann at [EMAIL PROTECTED] wrote: I've been trying to figure out what was wrong with my script... ? mail([EMAIL PROTECTED], Subject, command line mail() test); ? from the command line, php mail_test.php and getting, X-Powered-By: PHP/4.0.6 Content-type: text/html attempting to deliver the mailbr bWarning/b: Unknown error in bmail_test.php/b on line b3/bbr didn't notice any other responses, and this is just a guess here, but how about taking the '()' out of the body of the message. ie, command line mail test -- mike cullerton michaelc at cullerton dot com -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] function arguments
expanding on this... function func($arga, $argb, $argc='') { do_something_with_arga($arga); do_another_thing_with_argb($argb); if ($argc != '') do_somthing_with_argc($argc); } on 1/18/02 1:19 PM, Ben Sinclair at [EMAIL PROTECTED] wrote: You can do something like this: function myFunction($a = hello, $b = world) { } Both arguments are optional and have default values. This is in the documentation. -- Ben Sinclair [EMAIL PROTECTED] - Original Message - From: Malte Fucks [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, January 18, 2001 2:17 PM Subject: [PHP] function arguments Hi, how do i tell a function which arguments can be passed and which must be passed... example: function func($arga, $argb, $argc) { do_something_with_arga; do_another_thing_with_argb; and_if_argc_was_passed_do_something_with_it_too; } because i dont want to pass argc if i dont need it, and to pass void arguments like '' is annoying... -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Php.ini file missing
on 1/17/02 8:54 AM, Michael Sciascia at [EMAIL PROTECTED] wrote: Looking in the sendmail configuration with Webmin I see that the message sent by the php script is queued and that it isn't possible to send it because the host www@localhost isn't correct. In some web sites I found that I should change, in the hostconfig file, the value Hostname = AUTOMATIC to Hostname = my domain (which should be my IP or DNS) isn't getting your bearings always the hardest part of getting started. it's how all the pieces fit together that causes the magic. if you read between the lines, i believe the website you mention has already answered some of your remaining questions here. yet more of getting your bearings straight. anyway, not sure how much of the following you already now, but here's a bunch of stuff. the hostconfig file doesn't have anything to do with php or sendmail. it is only info about your host (or computer) so macosx can boot up properly. processes on the box may use or need info generated from /etc/hostconfig. my guess is that it's gonna be tough (but not impossible) to use sendmail on your machine since you have a dynamic ip address. the reason for this is that sendmail needs to know who 'it' is. ie, what machine to send the message from. you may want to check out the apache documentation http://httpd.apache.org/docs/ What isn't really clear to me is which domain I have to write here. i believe i am quoting from the website you mentioned this hostname is supposed to be the valid DNS entry of your Mac. I have an ISDN connection, so I don't have a static IP address and I don't know about the DNS. first, to find the dns, nslookup your_ip_address should return the name associated with the ip address. you really want the name in the hostconfig file. if it's changing all the time, you will need to change the entry in hostconfig or automate it. How do you usually check if a php script has really sent the e-mail to the address in the script? you can't really. the mail function returns true if the mail was sent (as far as php is concerned) but you don't necessarily now if the mail was delivered. i'm not even sure if mail returns true in your case (the mail was queued) you can check the mail queue from the terminal with mailq and (if sendmail is working) force messages to be sent with sendmail -q In the book I am using to approach to php this isn't explained, so I believe it should be something really easy to do. The book is for really and *absolute* beginners and everything is explained in a clear and exhaustive way. It also has a CD-ROM with mysql, php apache and it clearly explains how to install them, but there isn't written anything about setting something special to let the e-mail scripts work (well actually something just for Windows and not for Linux or other *nix based systems like Mac OS X) can't remember if i sent these to you already, but some good sites for macosx are http://macosxhints.com/ http://www.stepwise.com/ http://www.kung-foo.tv/xtips.shtml http://www.entropy.ch/software/macosx/php/ Which values do you think I should write in the hostconfig file? My usual provider domain (i.e. www.tiscali.it)? ideally, you would type the fully qualified domain name of your computer. so, to test all this - login to your isp - find out your hostname (nslookup ip_address) - edit /etc/hostconfig to add hostname - see if it works - woohooo! now, the hard part is automating that :) good luck, mike -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP Security - view source code
on 1/17/02 9:21 AM, Erik Price at [EMAIL PROTECTED] wrote: On my Linux box, which is shared with several users (I am admin), I would like to do something like this -- if I created the group php, and added myself to that group, I could use files associated with the group php. My web server runs as nobody. Do I just add nobody to the /etc/groups entry for the group php ? Or are you talking about a more involved administrative setup... another possibility is to add yourself to whatever group the webserver runs as. my webserver runs as www.www so i added myself to the www group. -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Lazy evaluation?
on 1/16/02 5:57 AM, Miles Thompson at [EMAIL PROTECTED] wrote: For or statements it does, but not or xor. I don't know about you, but I wouldn't want lazy evaluation on a conditional statement involving and. i'm new to all this stuff, so i'll bite. hopefully someone can explain what i'm missing. if i have a statement like if (($a == 'a') ($b == 'b')) blahblahblah(); and, $a != 'a'. why should php even look at the value for $b while evaluating this line? shouldn't the if fail after evaluating $a? thanks, mike -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] mysql_insert_id?
on 1/16/02 7:42 AM, Martin Wickman at [EMAIL PROTECTED] wrote: Dl Neil wrote: 2 because the (function argument) controlling feature is the connection, it is not possible for another concurrent user to 'steal' your ID or influence the ID returned to you - it's all yours! Ok, assume you are correct, but what if you are using persistent connections (ie pconnet)? it's still 'your' persistent connection that's being queried though. from the manual on mysql_pconnect Returns a positive MySQL persistent link identifier on success this is why you use the link identifier in things like mysql_query, and lets mysql 'know' what 'your' last insert was. hope this helps, mike -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Lazy evaluation?
aha! see, i didn't understand the whole picture. so, let me see if i can create another question. suppose if (($a_good = ($a == 'a')) ($b_good = ($b == 'b'))) blahblahblah(); are you saying, that $b_good should always have the result of ($b == 'b') even if $a != 'a'? that's not what my test shows (hi bogdan :) so, is there something other than that forces the other half to be evaluated? interesting... mike on 8/23/01 5:19 PM, TD - Sales International Holland B.V. at [EMAIL PROTECTED] wrote: On Wednesday 16 January 2002 16:18, you wrote: I think the cause is, which is lacking in the reply below, that if you have like if ((function1(val, val)) (function2(val, val)) blabla(); you still want function2 to be executed because it does things necessary for your script, however, if one of them returns false you don't want blabla() to be executed. If that isn't the case you should use or or one of the other operators not too sure about that tho' but i'm sure I'll be corrected if that isn't the case :-) on 1/16/02 5:57 AM, Miles Thompson at [EMAIL PROTECTED] wrote: For or statements it does, but not or xor. I don't know about you, but I wouldn't want lazy evaluation on a conditional statement involving and. i'm new to all this stuff, so i'll bite. hopefully someone can explain what i'm missing. if i have a statement like if (($a == 'a') ($b == 'b')) blahblahblah(); and, $a != 'a'. why should php even look at the value for $b while evaluating this line? shouldn't the if fail after evaluating $a? thanks, mike -- mike cullerton michaelc at cullerton dot com -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP as a cron job
Unable to open /home/admin/webmin-0.85/ in Unknown on line 0 this is possibly a path or env issue. have you tried using absolute filenames? mike on 1/16/02 10:07 AM, Tiago Luchini at [EMAIL PROTECTED] wrote: I am trying to run directly via PHP. I have tried setting 755 to the script and adding #!/usr/bin/php -q to it and also tried to change my cron line to run /usr/bin/php sending the script as a parameter. Both options run normally when logged on a TTY. Tiago - Original Message - From: Dennis Moore [EMAIL PROTECTED] To: Tiago Luchini [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 16, 2002 12:18 PM Subject: Re: [PHP] PHP as a cron job Please provide more information on how you have set up PHP to run your cron jobs. Are you trying to execute via LYNX or directly via a PHP script? /dkm - Original Message - From: Tiago Luchini [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, January 16, 2002 8:20 AM Subject: [PHP] PHP as a cron job I have been trying to use some PHP scripts as a Linux cron job. It tries to run but replies that: Unable to open /home/admin/webmin-0.85/ in Unknown on line 0 I have no idea why PHP parser is making this confusion. Could anyone bring some light to this mistery please? Atenciosamente, Tiago Luchini Diretor Técnico-Comercial Galluch Soluções Internet Tel.: 0xx11 6912-3255 Cel.: 0xx11 7839-7740 -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Maintenance of POP3 accounts
on 1/16/02 10:16 AM, HENDERSON, Roy at [EMAIL PROTECTED] wrote: I would like to be able to maintain ( ie create or delete ) POP3 accounts via PHP but my ISP says this cannot be done. I find this confusing since they provide me a PHP-based control panel which I use to do this manually ... first, this is _totally_ doable--heck, they're already doing it with the control panel--but that isn't to say they should necessarily let you have direct access. it's really a function of how the ISP has their end setup. some POP accounts are real accounts on a box and you'd have to mess with /etc/passwd. not something ISP's like their customers doing :) essentially, they'd have to write an API for you to base your code on and leave a port open on a box somewhere listening for requests from you. this could take lots of time to create (which isp's don't have) and be a possible security nightmare. on the other hand, a progressive ISP who had their act together and a competent php programmer could probably get this to work. note that most solutions i've seen to this problem don't actually let you mess with anything directly. you basically end up creating a file (or making an entry in a database) that gets picked up by a cron job the ISP runs and they actually 'do the work'. this adds a little delay between you sending the request and when the cron job runs. but is a pretty cool solution. probably not the answer you wanted to hear, but i've lived on both sides of this fence :) mike -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP as a cron job
on 1/16/02 11:26 AM, Tiago Luchini at [EMAIL PROTECTED] wrote: Unable to open /home/admin/webmin-0.85/ in Unknown on line 0 this is possibly a path or env issue. have you tried using absolute filenames? Yes. Same thing happens with absolute or relative paths. what's the line in your code where this error occurs? it doesn't run any line at all. don't matter what I put on my code, it just says unable to open what's the first line of the file being called by cron? is it #!/usr/local/bin/php -q -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] mySQL select statement with mulitple where definitions
on 1/16/02 11:57 AM, Mike Krisher at [EMAIL PROTECTED] wrote: someone here has to know the syntax for using multiple items in a where definition, something like: $values = 120106,120095; $sql = SELECT * FROM products WHERE catalognumber = $values ORDER BY price; select * from products where catalognumber in (120106,120095) order by you may need quotes around the stuff in the parens, ('120106','120095') -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] mysql_insert_id?
on 1/16/02 10:47 AM, Jimmy at [EMAIL PROTECTED] wrote: Hi DL, the only problem i can think of might occur with pconnect is, last_insert_id() will return you the last inserted ID from previous 'session', not current 'session'. to prevent this, you should call last_insert_id() only when your INSERT query executed succesfully. =Of course a right-living boy like me, cannot conceive of why one would look up LAST_INSERT other than immediately after the INSERT/UPDATE command... calling last_insert_id() after INSERT is the number one rule of course :) What i mean was, what if the INSERT query fail, but the script still execute the last_insert_id() function? Most probably the returned value would be wrong, because it will return the last_insert_id of previous INSERT query (from previous 'session') but of course, you'd have checked that the result id returned a valid result and not an error in this case and never looked for the last_insert_id, right? ;) mike -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP HTML: newbie question
hmmm... not sure about the cgi part. you'll probably need to start the file with something like #!/usr/loca/bin/php -q either way, within the file, you also need to tell the php parser what is php and what is html. surround the php code with ?php ? tags like ?php $var = 'Hello World'; ? htmlhead/headbody tabletrtd?php print($var); ?/td/tr/table /body/html on 1/16/02 2:25 PM, Richard at [EMAIL PROTECTED] wrote: Hi there I just signed up for an account at Spaceports so I can play with PHP I placed some PHP code in an HTML page and uploaded it to the server. But when I checked it in my browser I got the error message: can¹t parse line 1 Line 1 is simply the HTML tag!! On one of their user forums someone suggested getting rid of the HTML tags so I did and just left the PHP code on its own and this works fine so how can I use PHP with HTML? I think it has something to do with the fact that have to use their CGI server to run PHP??? Cheers Richard S -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP Security - view source code
on 1/16/02 6:04 PM, Rasmus Lerdorf at [EMAIL PROTECTED] wrote: On Thu, 17 Jan 2002, [EMAIL PROTECTED] wrote: (1) avoid using .inc files; use .php files like for normal script No, it is safer to block access to .inc files with an httpd.conf rule. Allowing people to execute files that were meant to be included out of context could end up being much more dangerous than simply having people see the source. here is that httpd.conf rule stolen from an earlier post by Rasmus Files ~ \.inc$ Order allow,deny Deny from all /Files with this rule, if someone requests a file ending in .inc, apache won't deliver it. however, php will still be allowed to include those files itself. -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Linux Book
also, find out if there is a linux users group in your area. in addition to holding group hacks and install fests, our group maintains a mailing list that's a great source of help. on 1/16/02 12:25 PM, Miles Thompson at [EMAIL PROTECTED] wrote: Book, I don't know. I'd suggest starting with the Guides at the Linux Documentation Project, http://www.linuxdoc.org/guides.html and work from there, and don't forget the HOWTO's. snip S. slightly OT, but what is the best linux book out there, aimed at admin/DNS/Networking? -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Another question - not exactly what i was looking for
how 'bout something like $query = 'select * from table_name where '; $and = ''; if ($lastname != '') { $query .= lastname = $lastname; $and = ' and '; } if ($firstname != '') { $query .= $comma.firstname = $firstname; $and = ' and '; } and so on on 1/15/02 1:53 PM, Phil Schwarzmann at [EMAIL PROTECTED] wrote: Yo, thanks for all your help. But it isn't exactly what im looking for. Let's say you had a database with the following four columns... -LastName -FirstName -Age -Weight ...and you wanted a page that would allow a user to search for one or more of these fields within the database. It would be easy if the user could only pick just one of the fields. But let's say that want to search only lastname and firstname, or maybe all four, or maybe just one. How could this be done? If I have code that looks like this... $query = select * from table where lastname='$lastname' and firstname='$firstname' and age='$age' and weight='$weight'; $result = mysql_query ($query); $num_results = mysql_num_rows($result); ...the $num_results is ALWAYS zero unless I typed in all four fields. Any help? Thanks! -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] 404 Redirection
on 1/13/02 6:07 AM, FiShcAkE at [EMAIL PROTECTED] wrote: Try that again, without pressing ctrl-enter this time!! As I said, I have got the usual script: ? if(isset($action)) { $include = $action; } else { $include = home; } include($include. .inc); ? but, how do I put in a custom error page instead of seeing: if i understand what you are asking, you might try something like if (is_file($include. .inc)) { include($include. .inc); } else { include(custom_error.inc); } you may need to execute is_file($include. .inc) inside a loop so that it checks in all your inlude_directories. foreach($dirs as $dir) { if (is_file($dir.'/'.$include. .inc)) { blahblahblah } otherwise, if you know 'all' the valid files, you could create an array of filenames and compare $include to elements of the array. Warning: Unable to access anyotherpage.inc in /var/virt/home/stuffwefound-co-uk/public_html/index.php on line 70 Warning: Failed opening 'anyotherpage.inc' for inclusion (include_path='') in /var/virt/home/stuffwefound-co-uk/public_html/index.php on line 70 I have got an error page for any other url i.e. apagenotfound.php but I dont know how to overcome the above. Thanks in advance Lee -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Newbie database question
on 1/13/02 10:51 AM, Dean Ouellette at [EMAIL PROTECTED] wrote: I am entering info from form into database, is there a way to check say firstname, lastname and address to see if it is a duplicate to what is already in database and if it is then just enter any new information they may enter and not create a new entry i'm definitely not an expert on this stuff, but here are some things to think about... on way to keep duplicates from being entered, is to make every (firstname, lastname, address) triplet unique in your database. in mysql, this would be something like ALTER TABLE table_name ADD UNIQUE some_unique_name(firstname, lastname, address); this may not be a good thing though. there may be instances where two folks exist with the same firstname,lastname, address. father/son and mother/daughter perhaps. if you just want to check, you can do something like SELECT id FROM table WHERE firstname = '$firstname' and lastname = '$lastname' and address = '$address'; if you get an id, then a record already exists. the problem with this, is data entry. depending on who is typing the stuff in a form, they may not type/spell it exactly the same each time. you may need to figure out some other unique identifier to determine if it's the 'same' person. hope this helps, mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] convert yyyy/mm/dd to mm/dd/yyyy, how?
on 1/13/02 12:56 PM, Sander Peters at [EMAIL PROTECTED] wrote: My first idea whas to split the date up in vars in php and then print the vars in the way I like it Is this a bad idea? Or are there better sollutions? that's the way i do it. i have 2 functions i use all the time for getting dates in and out of mysql using $month,$day,$year. for any project, i also create functions for formatting $month,$day,$year however the customer requires the output. -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] beginer
on 1/13/02 10:32 AM, Vania Lavielle Castro at [EMAIL PROTECTED] wrote: how work with sql server and code php? i try with the functions and the results are bad i need examples, please :( http://www.php.net/links.php -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] External Function
on 1/13/02 10:06 AM, Cory at [EMAIL PROTECTED] wrote: Is it possible to put all of my functions in a text file and just call it and use the functions in it? http://www.php.net/manual/en/function.require-once.php http://www.php.net/manual/en/function.include-once.php -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Php.ini file missing
hi michael, to create the directory and file, you'll need to run the terminal application. from there, type sudo mkdir /usr/local/lib to create the necessary directory. you should get prompted for a password. type your own password. you need to do this from an administrator account. the first account created during the install process is an administrator account. are you sure you don't have a copy of php.ini on your system? try locate php.ini from the terminal window. if there is one, you can copy it to the /usr/local/lib directory. sudo cp php.ini /usr/local/lib/ if you don't have one, you can download the distribution from php.net and copy php.ini-dist from there to /usr/local/lib and rename it sudo mv php.ini-dist /usr/local/lib/php.ini anyone know a better way to just get php.ini? a couple great sites for macosx http://www.stepwise.com http://macosxhints.com hope this helps, mike on 1/13/02 6:03 PM, Michael Sciascia at [EMAIL PROTECTED] wrote: Hi, I am new to this list and also to php and I am sorry to already bother you with a question you might find really stupid, but I looked around for this information several days now and I couldn't find some good resources. I installed php 4.1.0 on Mac OS X 10.1.2 and everything seems to work well, also with mySQL and Apache. I am learning php from a book for beginners full of explanations and scripts, so in the last days I wrote some scripts which make possible to send e-mails filling a form on the browser. The scripts worked out well, but I haven't been able to read the e-mails and understand where I should be able to. I believed I had to change the SMTP settings of php or some sort of mail server in the system and reading some articles found in several web sites I think the solution would be to change some settings in the php.ini file. The build I downloaded doesn't have any php.ini file and in the faq section of the website from where I downloaded it (http://www.entropy.ch/software/macosx/php/) there is simply written to create the php.ini file in the /usr/local/lib/php.ini, including the intermediate /lib/ directory that doesn't exist already on my system. I would like to know how I can create the php.ini file or if there is a easier way to get and read the e-mails sent by the php scripts without working on the php configuration. I am sorry to disturb you all, but I don't have any experience and I haven't been able to find anything clear about this question. I would really appreciate if you could give me some tips or some web site's addresses where I can find easy information, or where I can download a copy of the php.ini file. I thank you in advance for the kindness and the attention. Greetings, Michael -- mike cullerton michaelc at cullerton dot com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Php.ini file missing
on 1/13/02 6:35 PM, Rafael Perazzo at [EMAIL PROTECTED] wrote: I think that you have this problem because your sendmail is not running. Try to run your sendmail (probably this command /etc/rc.d/init.d/./sendmail start- Note that before the name sendmail you have two chars ./) and I think your problem will be fixed. Then test your script again to see if it's working. ahhh, if this is indeed the problem, then you (michael from the original message) need to enable sendmail in /etc/hostconfig by changing the line MAILSERVER=-NO- to MAILSERVER=-YES- (isn't everything different in macosx) again, you need to do this from an administrator account. this will start sendmail each time you reboot. i'm not exactly sure how to start sendmail correctly from the command line, but one of the sites i mentioned earlier might have something. mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] mysql_fetch_row win32 to Linux
on 1/12/02 11:45 AM, sundogcurt at [EMAIL PROTECTED] wrote: myquery = SELECT * FROM xpackage Warning: Supplied argument is not a valid MySQL result resource in /path to page with error/default.php on line 5 Line 5 is this part while($myrowz = mysql_fetch_row($myresult)){ this tells me that $myresult is not a valid mysql result resource identifier. how do you obtain $myresult? -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] php executing system commands..
on 1/11/02 1:35 AM, louie miranda at [EMAIL PROTECTED] wrote: Hi, can php execute system commands like df, and then print it to html ? http://www.php.net/manual/en/ref.exec.php -- mike cullerton -- 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] RTFM code snippet
hey folks, hope the new year is treating everyone well. i was RTFMing yesterday and ran across this piece of code while (false !== ($file = readdir($handle))) { which is similar to stuff i've done while ($file = readdir($dir)) { so, what am i not catching with my code, and what is really going on in the RTFM code with the false !== part? thanks y'all, mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] preg_replace help
on 1/11/02 8:20 PM, Gaylen Fraley at [EMAIL PROTECTED] wrote: Can someone recommend a good tutorial or book on this subject? Mastering Regular Expressions Jeffrey Friedl O'Reilly Associates ISBN 1-56592-257-3 -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] headers showing up in browser
#!/usr/local/bin/php -q on 1/10/02 12:16 PM, Mark at [EMAIL PROTECTED] wrote: I've got this problem that won't go away. The headers are showing up at the top of the page when I run php in cgi mode. any ideas? -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Form Question
keep the data in a variable and do something like INPUT TYPE=text NAME=name VALUE=?php print($name); ? on 1/10/02 1:30 PM, Lerp at [EMAIL PROTECTED] wrote: Hi there, how do I keep values in a form if the user has to go back and fill in some missing fields? Thx Joe :) -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] eregi
on 10/2/01 8:51 AM, CC Zona at [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Mike Cullerton) wrote: eregi(^[a-z0-9_\-]+$,$string) notice that i had to escape the dash with a backslash Are you sure? 'Cuz AFAIK, escaping shouldn't be necessary on a hyphen which is the last char (or, IIRC, the first) of a character class. cool. so, are you saying eregi(^[-a-z0-9_]+$,$string) should work? thanks, mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] eregi
i realize a solution using strspn/strcspn was offered, but you asked for eregi :) anyway, i use ereg, but i think this should work eregi(^[a-z0-9_\-]+$,$string) notice that i had to escape the dash with a backslash the plus sign forces atleast one character. you can use {x,y} in place of the plus to force atleast x characters but no more than y characters. mike on 10/1/01 4:53 PM, Tim Ballantine at [EMAIL PROTECTED] wrote: Thankyou... I should have made it clearer that I did want to use only the legal characters to compare the string by. Tim Rasmus Lerdorf [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Well, either you need to know the valid chars or the invalid ones. Make up your mind and use strspn() or strcspn() appropriately. -Rasmus On Mon, 1 Oct 2001, Tim Ballantine wrote: Returns the length of the initial segment of str1 which does not contain any of the characters in str2. I realise that i could see if this matches with the length of the entire word, and is there a way to get it to compare the word by the legal characters, because the amount of illegal symbols, including different language symbols (french for example) will be too high for me to list. Tim Rasmus Lerdorf [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Huh? You better read that documentation page again. You only need to list the illegal symbols. And what do you mean by length? -Rasmus On Mon, 1 Oct 2001, Tim Ballantine wrote: Is there anything which doesnt use length? And something like eregi, because it would be infeasible to list all of the symbols that a user could use, to compare a string by. Tim Rasmus Lerdorf [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... See php.net/strcspn On Mon, 1 Oct 2001, Tim Ballantine wrote: Hello, Could anyone tell me how to eregi a word, to see if it only contains either numbers, letters, the _ and the -, so that any other symbol with call it invalid. For example, theres the word expressio_n that will be valid, but the word express%^$-n will be invalid. Thankyou, Tim -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] DB.php, and how to use?
DB.php is part of PEAR check out php.net/PEAR http://vulcanonet.com/soft/index.php?pack=pear_tut on 9/25/01 12:40 PM, Matthew Walker at [EMAIL PROTECTED] wrote: I've searched the whole PHP website for any reference to this lib that comes standard with my distro of PHP4. No luck. Can someone provide me with an address I can go to, to read about DB.php and it's modules? (Specifically, the DB/mysql.php module) If there is no website, can someone provide a quick set of examples for how to use the class functions? I haven't done OO programming in a long time, and I've never done it in PHP. -- Matthew Walker Ecommerce Project Manager Mountain Top Herbs --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.281 / Virus Database: 149 - Release Date: 9/18/2001 -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Determining IP address
hmmm... for those of us really in the know... spoofing doesn't let an invalid user get access to sensitive data on your site. if someone is spoofing a valid ip address, the return packets will travel to the spoofed ip address, not to the 'real' ip address of the spoofer. so, even though they have a 'valid' ip address, they still can't see anything. mike on 9/6/01 1:31 AM, Tom Carter at [EMAIL PROTECTED] wrote: Just to bring that point up again for those in the know, IP addresses are easy to spoof, in other words make it appear that it comes from elsewhere. If your system contains sensitive or confidential data then I would suggest you do both - username/password and IP -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] networking
http://www.linuxdoc.org/HOWTO/SMB-HOWTO.html --On Friday, August 31, 2001 11:25 PM -0400 Data Driven Design [EMAIL PROTECTED] wrote: corel linux on a fourth machine. Is there a tutorial somewhere that will show me how to set up samba, or whatever else I need to access my network, and the internet from the linux machine? -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Sessions and Cookies on Macs
on 8/27/01 10:31 AM, Richard Baskett at [EMAIL PROTECTED] wrote: Ok on a pc when I have cookies turned off I am still able to access my session variables, but on a mac I can not. Is there a difference between the way session variables are stored on each platform? And if a session is indeed a cookie, then why does the session still work on pc's with cookies disabled? Rick check out http://www.php.net/manual/en/ref.session.php as a place to start. if cookies are turned off, the session is maintained in the url. have you figured out your mac session problem? i use a mac to develop my sites, and many of them use sessions without a problem. when i turn off cookies in the browser (usually the latest version of ie) php handles it smoothly. let me know if you have any questions, mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] The future of PHP
--On Tuesday, August 28, 2001 11:42 PM -0300 Manuel Lemos [EMAIL PROTECTED] wrote: These guys resort to these marketing tricks to promote Python as hell, and the PHP people just sits and waits doing almost nothing in comparision to promote PHP as hard as they can even when they lives depend on the acceptance of PHP as a wide spread language! dear mr lemos, your ongoing participation in this thread has opened my eyes to views i had not considered before and caused me to revisit mine. however, the above is representative of where i think you and i disagree. [please note that my thoughts here are really in response to the overall impression i received from reading all of your posts in this thread and i only include the above quote for my convenience. even though i'll mostly mention where you and i disagree, it doesn't mean i disagree with all that you say. indeed, i find your enthusiasm contagious and offer encouragement to you in your effort] one assumption you seem to have is the ongoing viability of php (if not the very livelihood of we the developers using php) is somehow a function of the number of folks who know what php is. that somehow the more folks know about php, the better php gets. it also seems that you feel 'the PHP people' are not putting forth enough effort to further php's acceptance and viability. from my point of view as a developer using php, recognition of php in the corporate world is not as important as how good php is. i prefer to see efforts focused on developing the best darn HTML-embedded scripting language this side of the railroad tracks. whether or not php gets talked about on the evening news doesn't really matter. what matters is whether php helps me as a programmer. i don't care how many folks recognize the power of php. i care about the power of php. the number of folks using php is a function of whether or not 'the PHP people' can continue to produce such rockin' code over the next few years. not the other way around. i imagine you have a unique perspective on the effort it takes to promote php. but, i'm guessing that 'the PHP people' probably do as well. i myself am unduly grateful for the effort that they put forth, not only in producing the rockin'st language anyone could have hoped for when learning to program, but in promoting php as well. when i saw php was featured at the open source convention in san jose, i knew things were moving along just fine. that's the kind of promotion i want to see. i believe 'the PHP people' should be allowed to promote php in a manner they are comfortable with. after all, it's their itch. ya know, making the best HTML-embedded scripting language seems a pretty noble goal to me. Regards, Manuel Lemos have a good one, mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] How can I read the value of an existing cookie?
on 8/25/01 6:20 AM, Pere at [EMAIL PROTECTED] wrote: I am setting up a cookie stating the language the user wishes to have the site written with. No problem up to here. Next time the user goes back to the site I want to read the cookie and, provided it exists, set up the site with the requested language. How can I retrieve the existing value of the cookie? (My cookie looks language,spanish or english or german,time()+1 year). $HTTP_COOKIE_VARS[language] if register_globals is on, you should be able to use $language mike Thank you for your support. Pere -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] $i % 2 ? 0:
it's an if/else shortcut. the part before the '?' is tested. '$i % 2' in your case. the part after the '?' is returned if the test evals to true. '0' in your case. the part after the ':' is returned if the test evels to false. i've never tried it with nothing after the ':' like in your case. guess it could be the same as an if without an else. hope this helps, mike on 8/25/01 10:38 AM, BRACK at [EMAIL PROTECTED] wrote: Hi Can someone explain to me what $i % 2 ? 0: means or what it does step by step? I was looking in PHP docs for ? and : and didn't find it there. I use this line in my script to assign different value for $bgcolor variable to color rows in result, but I want to understand what does it mean. Thank you in advance, Youri God is our provider http://www.body-builders.org -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] code check
on 8/23/01 11:51 AM, Tom Malone at [EMAIL PROTECTED] wrote: Sorry to bother you all with this, but I have no way to test this, as I have no access to a Mac. Could you tell me if this little piece of code looks as if it would work (detect whether someone's using the Mac OS)? ie 5.0 macos 9, powermac G3, i end up in the 'true' branch, but nothing happens to my font that i can tell... if (preg_match(/mac/i, $HTTP_USER_AGENT) || preg_match(/macintosh/i, $HTTP_USER_AGENT) || preg_match(/ppc/i, $HTTP_USER_AGENT) || preg_match(/PowerPC/i, $HTTP_USER_AGENT)): $basefont = Geneva; else: $basefont = Verdana, Helvetica, Serif; endif; It doesn't return an error, but that doesn't mean it works. I really appreciate your help. TIA Tom Malone Web Designer http://www.tom-malone.com -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] print_r question
one thing i do is put print_r inside pre /pre. function my_print_r($obj) { ?pre? print_r($obj); ?/pre? } does the output from print_r look fine if you view source? mike on 8/23/01 2:58 PM, james at [EMAIL PROTECTED] wrote: When I print an array out with print_r (php 4.06 on IIS 4.0) it does not print newlines even if newlines are embedded in the array element. I must embed br, instead. The manual examples use \n and the output shows that newlines are created. Am I missing something? Newbie, here. Hope this is the right thread for such question. Thanx, James -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] server run page
on 8/12/01 1:08 PM, lolodev at [EMAIL PROTECTED] wrote: i m beginner with php. i developp under asp or cold fusion. with this language, when you request a page, the server runs automatiquely a page: global.asa with asp and application.cfm with cold fusion. can i do the same thing under php ? inside php.ini ; automatically add files before or after any PHP document auto_prepend_file = auto_append_file= -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] if(!$submit)
if (!isset($submit)) :) on 8/7/01 8:47 AM, Tarrant Costelloe at [EMAIL PROTECTED] wrote: When using if (!$submit) I get an error saying: Warning: Undefined variable: submit in C:\Inetpub\webpub\default.php on line 1 Fair enough, so then I add if (isset(!$submit)) and I then get an error; Parse error: parse error, expecting `T_VARIABLE' or `'$'' Could someone please tell me the more than likely simple sollution. Thanks Taz -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] checking for null form fields fails
on 8/7/01 9:40 AM, Renze Munnik at [EMAIL PROTECTED] wrote: a couple things. although i agree with the general notion of using braces, return is not a function (the manual calls it a statement), and atleast from what i can find in the manual it doesn't take braces. http://www.php.net/manual/en/functions.returning-values.php also from that page - You can't return multiple values from a function, but similar results can be obtained by returning a list. i'm not really sure what the difference is between function, statement and language construct (which is what echo is). syntactically, i know that functions require parentheses. with echo, the manual says you _cannot_ use parantheses if you are echoing more than one thing. http://www.php.net/manual/en/function.echo.php -- mike cullerton You're right, return is a statement. I never said, though, to use braces with echo. Actualy I didn't say anything about echo. I never use echo, for some weird reason I just don't like it. I prefer print. So... I don't realy care how echo should be used. i don't use echo either. i use printf. i was just trying to pass along some things i learned reading the manual that were related to the topic. But you'll have to admit, using braces makes things a lot easier. i already did. And because what this was all about was JavaScript (and not PHP), using braces is a smart thing, because in JavaScript you can make realy ugly constructions in which things _can_ go wrong (no syntax error, but _wrong_) if you don't use braces. In JavaScript it's not required to end each line with a semicolon like in PHP. This can cause weird flows if you also don't use braces. cool, i came in late in the thread. i _do_ use braces. i like braces. braces are my friends. And e, who said anything about returning multiple values? again, just something learned from the manual. To be honest... I don't understand what you try to achieve with your post Please let me know... i was only trying to pass on info about differences between function calls, statements and constructs, and hopefully helping someone out in the process. isn't that what we do here? :) mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: Host OnLine ?
on 8/6/01 11:17 PM, Arcadius A. at [EMAIL PROTECTED] wrote: What if the host I'm checking is a simple workstation not running neither a HTTP nor a FTP server ? I'm writing this script for an intranet to check which machines are currently on ... maybe some kind of snmp query? -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Session problem
i would try session_start(); session_register(NAME); $res = mysql_query(SELECT NAME FROM dbhere where EMAIL = '$EMAIL' AND PASSWORD = '$PASSWORD'); if ($row = mysql_fetch_array($res)) { $NAME = $row[NAME]; } notice that $NAME is registered before being assigned to. on 8/6/01 2:23 PM, Chad Day at [EMAIL PROTECTED] wrote: PHP 4.0.2 .. I have a very basic script, gets the user's name, registers it, then displays Welcome, $NAME. $NAME is the session registered name. If I constantly reload that page that says Welcome, sometimes $NAME appears, sometimes not. Completely random. It just loses track of the variable. My code: auth.php: session_start(); ... $res = mysql_query(SELECT NAME FROM dbhere where EMAIL = '$EMAIL' AND PASSWORD = '$PASSWORD'); if ($row = mysql_fetch_array($res)) { $NAME = $row[NAME]; session_register(NAME); } ... Header(Location: menu.php); menu.php: session_start(); echo Welcome, $NAME; So like, what the hell. Why would it keep losing track of $NAME? Thanks, Chad -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] What's the difference between echo and print?
on 8/6/01 12:32 PM, Phil Latio at [EMAIL PROTECTED] wrote: What's the difference between echo and print? this is definitely one of those frequently asked ones :) a good place to start is http://php.net/echo http://php.net/print http://php.net/printf for info and user comments. i found a couple cool nuggets in there. here are some things i believe are true. print() is a function and you need the parantheses. print also returns whether or not is was successful, as in if (print($thing)) { $thing_was_printed = 1; } else { $thing_was_printed = 0; } echo is not a function. it is a language construct. (i'm not sure of all the implications of this) also, you do not need parantheses. so, echo $thing; is valid. -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Form call a function on submit
on 8/5/01 11:05 PM, Richard Kurth at [EMAIL PROTECTED] wrote: Is it possible to have a form submit button call a function. Like for updating a record in a database or for deleting data. Rather than a new page or with PHP_SELF i'm sure this isn't the only way, but what i do is... switch ($submit) { case my_value: my_function(); break; case my_other_value: my_other_function(); break; default: my_default_function(); break; } so, when the form is submitted, i check the value of submit and run the corresponding function. hope this helps, mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] How do I write a compound variable?
try for ($year=1995;$year=2001;$year++) { $high = high_ . $year; $low = low_ . $year; printf(avg for %s is %s,$year,($high + $low)/2); } on 8/6/01 5:50 PM, Hugh Danaher at [EMAIL PROTECTED] wrote: I want to do a simple FOR statement where I average the high and low value for a given year. A user will input the values on a separate page and hit a submit button. I can hard code each year to do what I want, but I'd like a simpler method. I've tried variations of multiple $'s, +'s and quote marks but haven't hit on the correct method, and I could certainly use someone's help. Thanks, Hugh What I want to do: ?php $high_1995=22; $high_1996=23; $high_1997=20; $high_1998=18; $high_1999=20; $high_2000=21; $high_2001=23; $low_1995=22; $low_1996=23; $low_1997=20; $low_1998=18; $low_1999=20; $low_2000=21; $low_2001=23; for ($year=1995;$year=2001;$year++) { $avg_$year=($high_$year+$low_$year)/2 // create $avg_1995, ... print $avg_$yearbr; } ? -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] running stand-alone php
i'm not sure i understand how you are running this... if it is a file you are running at the command line, try -q after the php.exe statement. if this is a web page, comment that line out. hope this helps, mike on 8/6/01 1:16 PM, miguel valero at [EMAIL PROTECTED] wrote: When I run the following script under an stand-alone php 4.0.6 and Apache 1.3 (Win95/98), the path to PHP (#!c:\php\php.exe) will show up on the first line of the browser output. #!c:\php\php.exe ?php phpinfo(); ? Is there a way to fix this? How can I get rid of the path line, on the top of the page, on the browser output? Any help will be greatly appreciated. My apologies if this has been covered before, or if this is in the manual, but I couldn't see it thanks. __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] How do I write a compound variable?
oops, that's printf(avg for %s is %s,$year,($$high + $$low)/2); :) sorry on 8/6/01 6:17 PM, mike cullerton at [EMAIL PROTECTED] wrote: try for ($year=1995;$year=2001;$year++) { $high = high_ . $year; $low = low_ . $year; printf(avg for %s is %s,$year,($high + $low)/2); } on 8/6/01 5:50 PM, Hugh Danaher at [EMAIL PROTECTED] wrote: I want to do a simple FOR statement where I average the high and low value for a given year. A user will input the values on a separate page and hit a submit button. I can hard code each year to do what I want, but I'd like a simpler method. I've tried variations of multiple $'s, +'s and quote marks but haven't hit on the correct method, and I could certainly use someone's help. Thanks, Hugh What I want to do: ?php $high_1995=22; $high_1996=23; $high_1997=20; $high_1998=18; $high_1999=20; $high_2000=21; $high_2001=23; $low_1995=22; $low_1996=23; $low_1997=20; $low_1998=18; $low_1999=20; $low_2000=21; $low_2001=23; for ($year=1995;$year=2001;$year++) { $avg_$year=($high_$year+$low_$year)/2 // create $avg_1995, ... print $avg_$yearbr; } ? -- mike cullerton -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Phone Number #s Only?
actually, it removes everything from $string that is not in the range 0-9. when a ^ is the first character inside [], it negates whatever is inside. ereg_replace (^[0-9],,$string); would remove the first character from $string if it were in the range 0-9. on 8/2/01 6:39 PM, Martin Cameron at [EMAIL PROTECTED] wrote: Just as the solution to spray paint the m/b green made me smile, this did too. This will strip out all characters except numerals at the beginning, right! martin Cameron On Fri, 03 Aug 2001 11:52, you wrote: on 8/2/01 5:32 PM, Jeff Oien at [EMAIL PROTECTED] wrote: Is there a routine out there to strip all characters from a phone number except the numbers? I was going to write my own but figured there must already be one out there I can use. Thanks. Jeff Oien ereg_replace ([^0-9],,$string); -- mike cullerton -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] weird behavior with a form
on 8/3/01 6:43 PM, Ben Bleything at [EMAIL PROTECTED] wrote: Whacky. It works now = i seem to remember a thread not that long ago (maybe it was on a different list) similar to this. the conclusion was that netscape and ie (and i'm sure others as well) handle this differently, and one of them (i can't remember which) handles it differently if there is more than one button on the page. i think if the browser is ie and there is only one submit button, hitting enter also returns submit='whatever'. otherwise, no guarantees. it appears that hiddens are the way to go -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] mySQL Autoincrement Field
on 8/2/01 9:01 PM, Ralph Guzman at [EMAIL PROTECTED] wrote: In mySQL, how do I set an auto increment field to start at a certain number-let's say 1? Do I just insert the first record with the desired number I wish to start with? it appears to depend on the table type. i believe you are ok with MyISAM or InnoDB tables. check out the docs on table creation and column types at mysql.com. -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: Phone Number #s Only?
on 8/2/01 9:55 PM, Richard Lynch at [EMAIL PROTECTED] wrote: While the solution given will work, consider the following perfectly valid phone numbers: 312-555-1234x1001 1-800-MY-STUFF Also, once you strip out all the spaces and dashes, nobody but a computer can use it... Do you *really* want to make it difficult for humans to use? good point richard. i never really considered the 1-800-MY-STUFF case. most of my customers seem to want numbers only.. anyway, assuming numbers only and no extensions (you can change this to add extensions pretty easily)... in a form where i want a phone number, i have 3 separate fields of length 3,3,4 respectively. when the form is submitted, i check to make sure there are only numbers. (actually, on some sites i use javascript to check this as well) i have two functions--phone_from_3() and phone_to_3(). i use phone_from_3() to set $phone = $phone1 . $phone2 . $phone3. i then put $phone in the db. when i want to display the phone number somewhere, i use phone_to_3() to turn $phone into $phone1, $phone2, $phone3. i can then format the phone number making it easy to read. hope this helps, mike -- mike cullerton -- 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] thoughts on sessions and members
hey folks, hope the day is treating you well. here's a programming theory/methodology type question for y'all. i am relatively new to programming and very new to object-oriented(ness). suppose i have a site using sessions managed with an object $dog. $dog contains a member object $dog-member and $dog-member contains a memberid $dog-member-memberid. member information (username and encrypted password) are stored in a database. my index file begins require_once(dog.inc); // this is where the objects get defined session_start(); session_register(dog); session_register(dog_member_id); if (!is_object($dog)) $dog = new dog; i can authenticate a user and carry that user along throughout the session within $dog-member. a member can also logout, meaning that $dog-member no longer refers to them. when a member logs out, there is still a session and valid $dog. so, what are the favored ways of allowing folks to auto-login? the approach i've taken is to set a cookie variable $dog_member_id. i assign their memberid to the session variable $dog_member_id and within my index file, i have if (!isset($HTTP_COOKIE_VARS[dog_member_id])) { if (isset($HTTP_SESSION_VARS[dog_member_id])) { setcookie(dog_member_id,$dog_member_id); } } then, i can check to see if $HTTP_COOKIE_VARS[dog_member_id] is set when someone visits my page by having this in my index. if ($HTTP_COOKIE_VARS[dog_member_id] 0) $dog-member = new Member($HTTP_COOKIE_VARS[dog_member_id]); if ((!is_object($dog-member)) || (!$dog-member-is_member())) $dog-member = new Member(-1); whew! i had this all working in an older site not using objects, so i understand the basics of what's going on. i also can get this to work if i check for $HTTP_COOKIE_VARS[dog_member_id] within my index file. i believe i also had this working at one time by checking for $HTTP_COOKIE_VARS[dog_member_id] within the dog object constructor, but of course can't get that to work now :) is this a good approach? is it possible (should i want) to make this check within the dog constructor? what are other approaches? thanks everyone, mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] web traffic report
another vote for analog. on 8/2/01 9:46 PM, Chris Fry at [EMAIL PROTECTED] wrote: analog seems to be the industry standard - use it with the extended log format. http://www.statslab.cam.ac.uk/~sret1/analog/ -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] SQL syntax error in PHP script. dunno what's wrong
hmmm, i am seeing the same thing as tim here. are we doing something wrong? i created a test table, entered some dummy data and then using scott's example of '; DELETE FROM seminar; i tried executing insert into test values (0,''; DELETE FROM test; ',1); and got this error ERROR 1064: You have an error in your SQL syntax near '' at line 1 trying other variations either caused similar errors or added rows to my table. is it possible to sneak in a command in this manner? mike on 8/2/01 2:39 AM, Tim Ward at [EMAIL PROTECTED] wrote: I'd always understood that mysql doesn't allow multiple statements to be submitted so this post obviously worried me. I did some tests and confirmed that this is not a problem in MySQL queries from PHP. If I'm wrong about this please let me know. Tim -- From: scott [gts] [SMTP:[EMAIL PROTECTED]] Sent: 01 August 2001 18:03 To: php Subject: RE: [PHP] SQL syntax error in PHP script. dunno what's wrong no offense to you sam, but please dont ever simply place single quotes around values. you have to escape the values *themselves*. what if someone submitted the form field title as: $title = '; DELETE FROM seminar; if you didn't escape the single quotes in there, it would get interpreted as a valid DELETE statement and your seminar table would get wiped. however, if you escaped $title, you'd end up setting title to \'; DELETE FROM SEMINAR; (rather than have the contents of $title interpreted as SQL commands) -Original Message- From: Sam Masiello [mailto:[EMAIL PROTECTED]] Subject: RE: [PHP] SQL syntax error in PHP script. dunno what's wrong You will need to put single quotes around your variables in your SQL statement. Like this: $sql = UPDATE TABLE seminar SET title='$title',speaker='$speaker',event_date='$tdate',time='$time',bldg='$bu ilding' ,rm='$room' WHERE id='$id'; Without the quotes, SQL doesn't know that Something Amazing is supposed to go together in the same string. HTH -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] What would you want in a PHP web host?
on 8/1/01 11:22 PM, Richard Lynch at [EMAIL PROTECTED] wrote: caveat--if there are some options that most folks would reasonably call 'optional' or 'dangerous', these shouldn't be expected. i am pretty new at programming and php, so i have no idea if things like this exist. i personally only compile in the options i use. There are like 107 PHP third-party extensions. i was really only talking about the features and packages that come with the php distribution (mysql, snmp, gd, imap, etc) i may have misunderstood the question. A couple are pretty new/raw, a couple are pretty defunct, and some are just so damn esoteric or have such a small user-base as to be pointless to install unless you really know a customer wants it... Anticipating what customers want can be tricky, though... :) You can now compile PHP and later on add in PHP Extension Modules which is cool... I've done it with GD once, but it doesn't seem stable, or maybe I'm doing something funky in the PHP code, as it displays one image only 20% (ish) of the time. I'll add GD for real later, but 20% is fine for the proof-of-concept I'm working on right now. Anyway, you may be able to add in new PHP extensions without re-compiling everything, but you'll need to check up on the stability issue. this is cool to know, thanks. -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Adopt A Newbie (ME)
dude, aren't you being a little harsh? I hereby nominate Kyle as the official George W. Bush of the PHP General mailing list. Anyone second it? to dubya, that is :) -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Phone Number #s Only?
on 8/2/01 5:32 PM, Jeff Oien at [EMAIL PROTECTED] wrote: Is there a routine out there to strip all characters from a phone number except the numbers? I was going to write my own but figured there must already be one out there I can use. Thanks. Jeff Oien ereg_replace ([^0-9],,$string); -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] html parsing question
on 8/2/01 5:30 PM, Chuck Barnett at [EMAIL PROTECTED] wrote: Hi I have a question about parsing a page on another server to grab some headlines. I want to search down the page until I find a string -headlines- then I want to grab everything between the next pair of table/table tags. Anyone have a quick solution? i would check out http://php.net/strpos Thanks, Chuck -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] HTTP_SESSION_VARS
if there aren't any session vars, $HTTP_SESSION_VARS won't be an array. i use something like if(isset($HTTP_SESSION_VARS)) { reset($HTTP_SESSION_VARS); while(list($k, $v) = each($HTTP_SESSION_VARS)) { do_something($k,$v); } } on 8/1/01 11:46 AM, Jon Yaggie at [EMAIL PROTECTED] wrote: SORRY i just coppied it wrong the actual code is capitalized while(list($k, $v) = each($HTTP_SESSION_VARS)) -- mike cullerton [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] What would you want in a PHP web host?
just figured that I would ask the PHP community exactly what they wanted. Thank you for any insight that you can give me. well, not much of my knowledge is php related, but what the heck :) --derek -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] fopen(fd, w) doesn't work?
on 8/1/01 8:39 AM, Ibrahim Noor at [EMAIL PROTECTED] wrote: I tried to create file by fopen(fd, w) function, but it didn't work. Permission Denied, server said. maybe you (the user your script is running as) don't have permission to write the file? -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Fun Question - What if...
sometimes i walk aroung outside with my titanium g4 laptop with php installed and watch the dogs poop in the yard while creating a website (php based, of course) of all the pretty flowers http://bakednotfried.com on 8/1/01 1:09 PM, Philip Olson at [EMAIL PROTECTED] wrote: Sometimes I walk outside and wonder why the sky is blue. On Wed, 1 Aug 2001, Michael J. Seely wrote: HI FOLKS, Imagine you had a PC Laptop, PHP installed, and a Ricochet/Sierra Wireless AirCard 400 - 128 kbps NIC card. What boom pow applications can you imagine setting up and running in this environment? What else would you need, if anything? -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] not null
on 8/1/01 12:50 PM, Jeremy Morano at [EMAIL PROTECTED] wrote: Hi, When a field is declared as an integer, not null and is the primary, how would I address it's empty set? nut sure i understand the question. if the field is NOT NULL, how could $value be empty? ex: if($value == ???) { bla bla bla } My condition wants there to be nothing in $value. -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: issues with __sleep() and __wakeup()
cool. you and i were talking about two different things. you are using __sleep and __wakeup by issuing the serialize and unserialize commands yourself. i am using __sleep and __wakeup when php automatically issues them itself when using sessions. it is my experience that if you have an object and you register that object as a session variable, and you do _not_ have a __sleep function, then everything works fine. this is different from having a __sleep function and not returning anything (or the wrong thing) mike on 8/1/01 9:32 AM, scott [gts] at [EMAIL PROTECTED] wrote: i added a (hopefully helpfull) addition to the online notes regarding magic-functions: http://www.php.net/manual/en/language.oop.magic-functions.php Here's what i posted, if anyone's interested: Here is a sample class and some test statements to demonstrate how __sleep() is used. If you do not return anything from __sleep(), your object will *not* be serialized. You must return something from __sleep() to tell serialize what to serialize. ? // to test the class $x = new Scott(); print_r($x); $y = serialize($x); $z = unserialize($y); print_r($z); // Simple class to test __sleep() class Scott { // class variables var $error; var $svar = array(); // constructor function Scott() { $this-svar['Hello'] = World; } function __sleep() { $this-svar['Hello'] = Yawn; // return list of instance-variables to be serialized return array('error', 'svar'); } function __wakeup() { $this-svar['test'] = I'm here!; } }// end class ? -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Attitude of B van Ouwerkerk
on 7/31/01 12:37 PM, scott [gts] at [EMAIL PROTECTED] wrote: there's a fine line between being terse and being nasty. please don't misinterpret this, but i think that we could all benefit from being less sensitive of the style each of us express ourselves in... once again, scott, you seem to have a nice concise way of putting things :) newbies are part of internet communities, as are old curmudgeons. thankfully, so too are the wise, willing to share their knowledge. recently, Brian White mentioned a propsed faq for the headers already sent question. also, Philip Olson mentioned a link at php.faqts. what is up with a faq for this list? is there one? i have been saving good responses to faq type questions with the intent of putting a faq together. now is as good a time as any. i'll post something in a couple days. that way, we can politley say to newcomers. hey, nice to have you around. hope we can help you out some. two places you should go to get started are php.net and link.to.list.faq let me know if there already is one. have a day, mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] issues with __sleep() and __wakeup()
on 7/31/01 1:48 PM, scott [gts] at [EMAIL PROTECTED] wrote: I am having a problem with __sleep(); there mere existance of it is causing my object to not get serialized at all. __wakeup() works fine. i am using PHP v4.0.6 / apache / win2k. If i keep __sleep() in the object, it will not serialize, but if i remove it, it serialized fine. Does anyone know why this happens? i asked this about a month ago and didn't hear anything. i too have never been able to get __sleep to work. i think it's because i couldn't figure out what needed to be returned (or how to return it :) at http://www.php.net/manual/en/language.oop.magic-functions.php it says that __sleep is supposed to return an array with the names of all variables of that object that should be serialized, but there are no examples of this. in a current project, i have an object that is registed as a session variable. it contains three objects and an array. one of the objects is a PEAR db object, and i don't need to serialize it. i do want to maintain the other two objects and the array. i tried a number of ideas inside __sleep, to no avail. without __sleep, it works. with __sleep, i break it. i do use __wakeup to reinitialize my db object, but i just use $db-disconnect(); at the end of my index file to disconnect . does anyone know the proper way to clean up the object in __sleep and how to return the variables that should be serialized? can this even be used when one (or more) of the variables is an object itself? thanks, mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Execute mixed php code from mysql?
the way i have solved this is to have another column of data_type. switch ($data_type) { case php: exec($data); break; case html: include($data); break; } mike on 7/31/01 3:24 PM, Kyle at [EMAIL PROTECTED] wrote: For example I have in a database: - In database: htmlheadtitlewelcome/title/head body ? if ($something == 'hello') { echo 'do somethoing'; }? -- Also in Database: /body/html --- Now how could i make it so that I have another page that has the following: index.php - ? $db = mysql_connect ($dbhost,$dbuser,$dbpass); $query = SELECT code FROM templates WHERE name = 'header'; $result = mysql_db_query($dbtabe,$query); $row = mysql_fetch_array ($result); echo $row[code]; ? Jump out and have some html content ? $db = mysql_connect ($dbhost,$dbuser,$dbpass); $query = SELECT code FROM templates WHERE name = 'footer'; $result = mysql_db_query($dbtabe,$query); $row = mysql_fetch_array ($result); echo $row[code]; ? -- end page -- For some reason it converts the tags on the php code as it pulls it out, i figure echo isn't the right function to do this and echo is converting the '?' to 'lt;?'. I tried eval(), I need a function similar to include(), but can take strings instead of files. If the content that was in the database and I include()'d it, it would have the desired effect. Thanks in advanced - Kyle -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] dumb mysql_connect issue
or, echo $sql and copy/paste it into an sql client and see what it tells you. on 7/31/01 4:21 PM, Philip Olson at [EMAIL PROTECTED] wrote: Try putting mysql_error() in your die statements so : or die(mysql_error()); and see what it tells you. Regards, Philip On Tue, 31 Jul 2001, CGI GUY wrote: Is there anything (add. parameters, etc.) that I'm missing that would possibly explain why the following code won't execute? -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] dumb mysql_connect issue
on 7/31/01 4:10 PM, CGI GUY at [EMAIL PROTECTED] wrote: Is there anything (add. parameters, etc.) that I'm missing that would possibly explain why the following code won't execute? snip in FROM table_name.column_name1,table_name.column_name2 table_name.column_name1 is a column, but FROM expects a table. try select table_name.column_name1,table_name.column_name2 from table_name -- mike cullerton -- 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] include_once vs require_once
hey folks, i'm wondering about the difference between include_once and require_once. the manual says The require_once() statement replaces itself with the specified file The include_once() statement includes and evaluates the specified file so, what is the difference? it's almost like one is a copy/paste and the other is some kind of read. is there any different behavior we should expect in scripts using one method vs another. my first guess was that require_once wouldn't evaluate the file, but i can execute code from within a file using either method. thanks, mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: include_once vs require_once
cool, so the difference is _when_ they happen. ok, another question then. if my script includes the line require_once($file); and $file contains the line include_once($other_file); what happens then? :) thanks, mike on 7/31/01 6:57 PM, Andrew Sterling Hanenkamp at [EMAIL PROTECTED] wrote: Did you look at the difference between include() and require()? Basically, as I understand it, require() and require_once() are replaced during parsing--before code execution. And include() and include_once() are replaced during code execution. Thus, a required file is always imported into the file whereas an included file is only imported if the include() statement is executed. The same is true for the _once() versions except that the statement evaluates to nothing if the file has already been imported by another statement. Cheers, Sterling Mike Cullerton wrote: hey folks, i'm wondering about the difference between include_once and require_once. the manual says The require_once() statement replaces itself with the specified file The include_once() statement includes and evaluates the specified file so, what is the difference? it's almost like one is a copy/paste and the other is some kind of read. is there any different behavior we should expect in scripts using one method vs another. my first guess was that require_once wouldn't evaluate the file, but i can execute code from within a file using either method. thanks, mike -- mike cullerton -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Can't write to file via php, just via ftp...Can anyonehelp?
on 7/30/01 2:58 PM, Stephan Hübner at [EMAIL PROTECTED] wrote: Hello all, hi stephan, another newbie-question, probably... :-) they all are, at first! And sorry for my (possibly) bad english, I'm from Germany. sorry for mine, i'm from virginia :) the problem I noticed is that I have to write to a file on the server. I created a directory where I store the files, upload a data-file into it and tried to write to it via a php-file. But it seems I don't have the right to write to it and somehow I can't change that with the ftp-programm I have (Interarchy on the Mac). So, does anybody know if there is a solution for this? I mean, others have to write to the server too, so there must be a way to do it... (btw, it's a linux or unix server where the pages are on). Thanks for your thoughts. there are a couple of things going on here. first, when you ftp to the server, you are probably logging on as yourself. php is probably running as whatever user the webserver is running as. those are most likely two different users. one option you have is to ftp the file as the same user the webserver runs as. this may not really be a viable option. another option is to create a group on the server, and put your user and the webserver user both in that group. when you ftp the file, you will need to make sure it is group writeable. you can do this from the command line on the server, or from interarchy as well. in interarchy, after you have uploaded the file, select the file and choose Set Permissions... from the Listing diresctory. then make sure the box for group write is checked. Have a nice day, Stephan Huebner hope this helps, mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] mkdir
On Sat, 28 Jul 2001, Jerry Lake wrote: when using mkdir I cant seem to make subdirectories ? $oldumask = umask(0); mkdir('test/test', 0777); umask($oldumask); ? is there any way to do this ? does the first test directory already exist? you may need to make them in two steps. i believe mkidir has a switch to force it to create any needed directories along the way. -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] idiotic question
on 7/27/01 3:46 PM, Jerry Lake at [EMAIL PROTECTED] wrote: for the life of me I can't remember how to convert a string to just the first letter of itself i.e. $string = test ...a function $string_first = t $word = substr($word,0,1); -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] array through url?
on 7/27/01 12:21 PM, [EMAIL PROTECTED] at [EMAIL PROTECTED] wrote: Is it possible to send an array of numbers into a php file through a url? Like if I have a file that adds numbers together, could I send it www.domain.com/add.php?num=2,3,4,5 $num would be an array. www.domain.com/add.php?num[]=2num[]=3num[]=4num[]=5 -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Using Variable Variables...
on 7/26/01 6:46 PM, [EMAIL PROTECTED] at [EMAIL PROTECTED] wrote: $_VARIABLE_ = chkContact.$i; $_VAR_ = $$_VARIABLE_; How do I make this work when $chkContact is a global variable? This returns an empty value because it does not see that $chkContact is a global variable... maybe try global $_VARIABLE_, $$_VARIABLE_; -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] asp to php
on 7/26/01 9:52 AM, kaab kaoutar at [EMAIL PROTECTED] wrote: Does anyone of u has alreday tried successfully converting asp file to php file ? Is it worth doing so or restarting from scratch? Thanks i've only tried this once, but i'd do it again. you will definitely have to edit the code it produces, but you'll find patterns and you can search and replace some. it's a great way to get some of your typing done if nothing else. -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] newbie seeks template info
devshed has an article using fast template http://devshed.com/Server_Side/PHP/PHPFastTemplate/ on 7/25/01 2:06 AM, Daniel Goldin (E-mail) at [EMAIL PROTECTED] wrote: Could somebody point me to a good primer--and I mean PRIMER--that explains how templates work in php. I'm thinking--not too clearly, I admit--about apps like Smarty and PhpLib and Pear, which I've heard so much about. -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] max_execution_time header
on 7/9/01 8:17 AM, Peter Schumacher at [EMAIL PROTECTED] wrote: I still run into the max_execution_time!!! I thought it would be reset as I redirect to another page. within your script ini_set(max_execution_time, $some_bunch_of_seconds); -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] registering objects as session variables
on 7/8/01 5:53 AM, [EMAIL PROTECTED] at [EMAIL PROTECTED] wrote: Hi mike! On Sat, 07 Jul 2001, mike cullerton wrote: hey folks, i'm trying to register an object as a session variable and feel like i'm chasing my tail. i either get the define class before starting session problem or the can't send header error. as soon as i fix one, i cause the other. you are doing something wrong somewhere in the process :) All you need is the class definition before the session starts. That's all. Post some code to see what are you doing. thanks, this is really involved code. (YA weblog program) the index has one include file, but that include file has _many_ includes and lots of interdependence. the object i want to register maintains the page layout, and has a db object and member object as variables. i've got some test code working that doesn't exhibit the problem. now i'm just trying to track it down. :( again, thanks, mike -- teodor -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] can't generate gif!!!
on 7/8/01 10:51 AM, Tom Carter at [EMAIL PROTECTED] wrote: I thought convert was an imagemagick command, rather than unix by default? could be wrong tho... yes, but you can install it on a box without xwindows and still use it. a pretty cool tool. -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] add user from the web interface
on 7/8/01 4:30 AM, INFO (www.trade-revenues.com) at [EMAIL PROTECTED] wrote: Hi, If I want to add a system user from the web interface using Apache + Redhat 6.2. What language should I use. Should I use PHP or Bash or Perl. Which one is the best ?? I know PHP can always exec shell command using exec() function. But, the apache server is set to nobody.. So I can not exec the root command from the web interface. Advice is need in this situation. if you want to use a web interface, you're stuck with the user that apache runs as. (nobody in your case) one option is to have the web application create a file, and then have a cron job as root come by and read the file and add the user(s). -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: when to delete a temporary file ?
on 7/8/01 11:45 AM, Lasse at [EMAIL PROTECTED] wrote: this was the first approach I thought about, but I don't know how to check session IDs other that current one I use session_is_registered() to check for the current session but how can I check for other sessions ? tell me please :) Um... I'm not sure... I've never actually used sessions myself.. :-) I just figured that it would be possible... php session info can be stored a couple differet ways on your server. the default is a file (one for each session) in /tmp. the name of the file includes the session id. http://www.php.net/session -- mike cullerton -- 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] magic functions
hey folks, hope the day is treating you well. i believe i have solved my chasing the tail problem with registering an object as a session variable. now, i'm having trouble with my database connection. in the object i am registering, one of its variables is a pear db object. the first connection to the page works, any subsequent connection gets the following error Warning: Supplied argument is not a valid MySQL-Link resource in DB/mysql.php so, i am wondering how to use __sleep and __wake. there aren't any examples on php.net about this. it mentions something about returning an array of variables to serialize. should i include the db object in this array? anyone have a simple example to start from? any help appreciated, thanks, mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Global Variables -- why not have them?
on 7/8/01 7:57 PM, Brian White at [EMAIL PROTECTED] wrote: I dislike the GLOBAL statement in that many of the bugs that get me scratching my head are to do with when I have forgotten to use it. Then you're probably using it way too often. It is usually for SCRIPT_NAME, or one of the CGI parameters. The CGI parameters are arguable, but I pretty much consider SCRIPT_NAME to be a global constant. php does have constants which are _always_ global. define (SCRIPT_NAME, $passed_in_script); then you refer to it like my_function() { printf(script is %s,SCRIPT_NAME); } notice there are no quotes or '$' or anything. i've recently changed $DEBUG to DEBUG for things like define(DEBUG, 1); my_db_function() { $rid = $db-query($query); if (!DB::isError) { do_something_cool(); } else { if (DEBUG) printf(!-- bummer, query failed : %s --\n,$rid-getMessage()) } -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Question about how to do this...
on 7/8/01 10:58 PM, Steve Werby at [EMAIL PROTECTED] wrote: Ben Bleything [EMAIL PROTECTED] wrote: I believe (and I'm sure someone will correct me if I'm wrong) that whenever you 'include' or 'require' a file, it drops to regular HTML mode... so, yes, you will need to use ?php tags at the beginning and ? tags at the ends = Think of the behavior of include() as copying the exact text from your code in the include'd file and pasting it as is into the calling code...a la paper and scissors. There is no special transformation. So if the code in the include'd file would have needed PHP codes if it was directly within the calling code then it needs it in the include'd file too and if it wouldn't have in the calling code then it won't in the include'd file. from http://php.net/include An important note about how this works is that when a file is include()ed or require()ed, parsing drops out of PHP mode and into HTML mode at the beginning of the target file, and resumes again at the end. For this reason, any code inside the target file which should be executed as PHP code must be enclosed within valid PHP start and end tags. -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Post a form within a running php-script
on 7/8/01 11:17 PM, Bob Horton at [EMAIL PROTECTED] wrote: What if someone wanted to reply to a form but the form was expecting the information to arrive using the POST method (and wasn't explicitly PHP)? Is there any way to do it if you want to submit to a POST method form? Or some way to simulate the entering of the information and clicking of the submit button? i'm not sure if this is what you are asking, but i can have an url like http://mysite.com/?submit=click_meopt=my_option and refer to those inside my program as $submit and $opt -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] chdir() help
i believe the script considers it's own directory as it's current working directory. try calling the files by image/$file_name on 7/7/01 9:38 AM, McShen at [EMAIL PROTECTED] wrote: hi Currently, i am working in e:\work, and there is a folder named image under e:\work, so, the path to image is e:\work\image. I have a script under e:\work, and i wanna display all images under the folder e:\work\image, I use chdir() to change the directory. but it wouldn't work. it still displays the images under e:\work. Why is that? Does chdir() work under win2k pro? here is my script --- ?php $dir_name = e:\work; $dir = opendir($dir_name); while ($file_name=readdir($dir)) { if (($file_name!=. $file_name!=..)) { echo $file_name.\nnbsp;nbsp;; if (chdir('e:\work\image')) { echo current dir is e:\work\image; } echo IMG SRC=$file_name; } } closedir($dir); ? - Please help me to fix the problem. Thanks. -- mike cullerton -- 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] registering objects as session variables
hey folks, i'm trying to register an object as a session variable and feel like i'm chasing my tail. i either get the define class before starting session problem or the can't send header error. as soon as i fix one, i cause the other. what are folks doing about this? roll you own using serialize? maybe i'm missing something easy... mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Question: Processing files in directory and parsing...
on 7/7/01 7:02 PM, Jeff Lewis at [EMAIL PROTECTED] wrote: So I need to know how to process the files in the directory and then how to process a few lines. The structure will always be the same and having the columns starting at the same position each time. first, do the files have all the heading info in them as well, or just the data? ie, are all the lines the same, or are there some that include stuff other than data? if the files cantaon only data, once you get a file in hand, this can parse the lines. $fd = fopen ($file,'r'); $buffer = fgets($fd, 4096); $field1 = substr($buffer,0,x); $field2 = substr($buffer,x,y); $field3 = substr($buffer,x+y,z); ... where x is the length of the first field, y length of the second ... also, you may want to trim() the fields. i'm sure others around here can come up with something better. :) -- mike cullerton -- 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]