[PHP] Quick question.
Hi everyone. I asked this a week or so ago but i am unsure if it got to the list, so here we go again. I am trying to get a remote file to be copied onto my own web server, I have looked at fopen() and fread() and fwrite() and get the general idea of each, but im wondering how to join the commandes to get the file i want from the remote ftp server, copied and written onto my own server. -- Cheers - Simon Angell Canberra ACT www.canberra-wx.com - Member of: Australian Severe Weather Association. www.severeweather.asn.au - This email is virus free. Scanned before leaving my mailbox using Norton Antivirus 2002 for Win2k Scanned with the latest definition File. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question.
Everything you need: http://www.php.net/ftp Adam Voigt [EMAIL PROTECTED] On Tue, 2002-10-01 at 11:50, Simon Angell wrote: Hi everyone. I asked this a week or so ago but i am unsure if it got to the list, so here we go again. I am trying to get a remote file to be copied onto my own web server, I have looked at fopen() and fread() and fwrite() and get the general idea of each, but im wondering how to join the commandes to get the file i want from the remote ftp server, copied and written onto my own server. -- Cheers - Simon Angell Canberra ACT www.canberra-wx.com - Member of: Australian Severe Weather Association. www.severeweather.asn.au - This email is virus free. Scanned before leaving my mailbox using Norton Antivirus 2002 for Win2k Scanned with the latest definition File. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question.
Simon Angell wrote: Hi everyone. I asked this a week or so ago but i am unsure if it got to the list, so here we go again. I am trying to get a remote file to be copied onto my own web server, I have looked at fopen() and fread() and fwrite() and get the general idea of each, but im wondering how to join the commandes to get the file i want from the remote ftp server, copied and written onto my own server. Something like the following might work (not tested AT ALL): $rContents = implode( \n, file( 'ftp://www.foo.bar/me/my/data.txt' ) ); if( ($fp = fopen( '/tmp/myFile.txt', 'w+' )) !== false ) { fputs( $fp, $rContents ); fclose( $fp ); } -- .-. | Robert Cummings | :-`. | Webdeployer - Chief PHP and Java Programmer | :--: | Mail : mailto:[EMAIL PROTECTED] | | Phone : (613) 731-4046 x.109 | :--: | Website : http://www.webmotion.com | | Fax : (613) 260-9545 | `--' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question.
i tried that ine and got this... Warning: fopen(/test/canberra.txt, w+) - No such file or directory in C:\Xitami\webpages\bomonster\test2.php on line 4 code.. ?php $rContents = implode( \n, file( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' ) ); if( ($fp = fopen( '/test/canberra.txt', 'w+' )) !== false ) { fputs( $fp, $rContents ); fclose( $fp ); } ? I think i know what the probelm is. .if( ($fp = fopen( '/test/canberra.txt', 'w+' )) !== false ) should be if( ($fp = fopen( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' , 'w+' )) !== false ) But, where do i put the file name and directory to write? -- Cheers - Simon Angell Canberra ACT www.canberra-wx.com - Member of: Australian Severe Weather Association. www.severeweather.asn.au - This email is virus free. Scanned before leaving my mailbox using Norton Antivirus 2002 for Win2k Scanned with the latest definition File. Robert Cummings [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Simon Angell wrote: Hi everyone. I asked this a week or so ago but i am unsure if it got to the list, so here we go again. I am trying to get a remote file to be copied onto my own web server, I have looked at fopen() and fread() and fwrite() and get the general idea of each, but im wondering how to join the commandes to get the file i want from the remote ftp server, copied and written onto my own server. Something like the following might work (not tested AT ALL): $rContents = implode( \n, file( 'ftp://www.foo.bar/me/my/data.txt' ) ); if( ($fp = fopen( '/tmp/myFile.txt', 'w+' )) !== false ) { fputs( $fp, $rContents ); fclose( $fp ); } -- .-. | Robert Cummings | :-`. | Webdeployer - Chief PHP and Java Programmer | :--: | Mail : mailto:[EMAIL PROTECTED] | | Phone : (613) 731-4046 x.109 | :--: | Website : http://www.webmotion.com | | Fax : (613) 260-9545 | `--' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question.
You're a Windows guy so probably you need the directory delimiters facing the other way :) Try this one (not tested AT ALL): $rContents = implode( \n, file( 'ftp://www.foo.bar/me/my/data.txt' ) ); if( ($fp = fopen( 'c:\path\to\directory\outfile.txt', 'wb+' )) !== false ) { fputs( $fp, $rContents ); fclose( $fp ); } Make sure the directry path in the fopen() statement already exists since it won't try to make the directory structure. Cheers, Rob. Simon Angell wrote: i tried that ine and got this... Warning: fopen(/test/canberra.txt, w+) - No such file or directory in C:\Xitami\webpages\bomonster\test2.php on line 4 code.. ?php $rContents = implode( \n, file( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' ) ); if( ($fp = fopen( '/test/canberra.txt', 'w+' )) !== false ) { fputs( $fp, $rContents ); fclose( $fp ); } ? I think i know what the probelm is. .if( ($fp = fopen( '/test/canberra.txt', 'w+' )) !== false ) should be if( ($fp = fopen( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' , 'w+' )) !== false ) But, where do i put the file name and directory to write? -- Cheers - Simon Angell Canberra ACT www.canberra-wx.com - Member of: Australian Severe Weather Association. www.severeweather.asn.au - This email is virus free. Scanned before leaving my mailbox using Norton Antivirus 2002 for Win2k Scanned with the latest definition File. Robert Cummings [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Simon Angell wrote: Hi everyone. I asked this a week or so ago but i am unsure if it got to the list, so here we go again. I am trying to get a remote file to be copied onto my own web server, I have looked at fopen() and fread() and fwrite() and get the general idea of each, but im wondering how to join the commandes to get the file i want from the remote ftp server, copied and written onto my own server. Something like the following might work (not tested AT ALL): $rContents = implode( \n, file( 'ftp://www.foo.bar/me/my/data.txt' ) ); if( ($fp = fopen( '/tmp/myFile.txt', 'w+' )) !== false ) { fputs( $fp, $rContents ); fclose( $fp ); } -- .-. | Robert Cummings | :-`. | Webdeployer - Chief PHP and Java Programmer | :--: | Mail : mailto:[EMAIL PROTECTED] | | Phone : (613) 731-4046 x.109 | :--: | Website : http://www.webmotion.com | | Fax : (613) 260-9545 | `--' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question.
i removed a / and it worked :) ?php $rContents = implode( \n, file( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' ) ); if( ($fp = fopen( 'test/canberratest.txt', 'w+' )) !== false ) { fputs( $fp, $rContents ); fclose( $fp ); } ? Now the format of the content is no longer, can this be fixed? This is how it is originally. IDN10035 BUREAU OF METEOROLOGY CANBERRA METEOROLOGICAL OFFICE FORECAST FOR THE ACT Issued at 3:34pm on Tuesday the 1st of October 2002 SITUATION: AND this is how the text file writes IDN10035BUREAU OF METEOROLOGYCANBERRA METEOROLOGICAL OFFICEFORECAST FOR THE ACTIssued at 3:34pm on Tuesday the 1st of October 2002SITUATION: with all through it where a new line is suppose to be. Can this be fixed, or will i just need to work around it? -- Cheers - Simon Angell Canberra ACT www.canberra-wx.com - Member of: Australian Severe Weather Association. www.severeweather.asn.au - This email is virus free. Scanned before leaving my mailbox using Norton Antivirus 2002 for Win2k Scanned with the latest definition File. Simon Angell [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... i tried that ine and got this... Warning: fopen(/test/canberra.txt, w+) - No such file or directory in C:\Xitami\webpages\bomonster\test2.php on line 4 code.. ?php $rContents = implode( \n, file( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' ) ); if( ($fp = fopen( '/test/canberra.txt', 'w+' )) !== false ) { fputs( $fp, $rContents ); fclose( $fp ); } ? I think i know what the probelm is. .if( ($fp = fopen( '/test/canberra.txt', 'w+' )) !== false ) should be if( ($fp = fopen( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' , 'w+' )) !== false ) But, where do i put the file name and directory to write? -- Cheers - Simon Angell Canberra ACT www.canberra-wx.com - Member of: Australian Severe Weather Association. www.severeweather.asn.au - This email is virus free. Scanned before leaving my mailbox using Norton Antivirus 2002 for Win2k Scanned with the latest definition File. Robert Cummings [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Simon Angell wrote: Hi everyone. I asked this a week or so ago but i am unsure if it got to the list, so here we go again. I am trying to get a remote file to be copied onto my own web server, I have looked at fopen() and fread() and fwrite() and get the general idea of each, but im wondering how to join the commandes to get the file i want from the remote ftp server, copied and written onto my own server. Something like the following might work (not tested AT ALL): $rContents = implode( \n, file( 'ftp://www.foo.bar/me/my/data.txt' ) ); if( ($fp = fopen( '/tmp/myFile.txt', 'w+' )) !== false ) { fputs( $fp, $rContents ); fclose( $fp ); } -- .-. | Robert Cummings | :-`. | Webdeployer - Chief PHP and Java Programmer | :--: | Mail : mailto:[EMAIL PROTECTED] | | Phone : (613) 731-4046 x.109 | :--: | Website : http://www.webmotion.com | | Fax : (613) 260-9545 | `--' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question.
Windows makes me cry... this will fix the problem... Change: $rContents = implode( \n, file( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' ) ); To: $rContents = implode( \r\n, file( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' ) ); If that doesn't work: To: $rContents = implode( \n\r, file( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' ) ); I can never remember the order :) Cheers, Rob. Simon Angell wrote: i removed a / and it worked :) ?php $rContents = implode( \n, file( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' ) ); if( ($fp = fopen( 'test/canberratest.txt', 'w+' )) !== false ) { fputs( $fp, $rContents ); fclose( $fp ); } ? Now the format of the content is no longer, can this be fixed? This is how it is originally. IDN10035 BUREAU OF METEOROLOGY CANBERRA METEOROLOGICAL OFFICE FORECAST FOR THE ACT Issued at 3:34pm on Tuesday the 1st of October 2002 SITUATION: AND this is how the text file writes IDN10035BUREAU OF METEOROLOGYCANBERRA METEOROLOGICAL OFFICEFORECAST FOR THE ACTIssued at 3:34pm on Tuesday the 1st of October 2002SITUATION: with all through it where a new line is suppose to be. Can this be fixed, or will i just need to work around it? -- Cheers - Simon Angell Canberra ACT www.canberra-wx.com - Member of: Australian Severe Weather Association. www.severeweather.asn.au - This email is virus free. Scanned before leaving my mailbox using Norton Antivirus 2002 for Win2k Scanned with the latest definition File. Simon Angell [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... i tried that ine and got this... Warning: fopen(/test/canberra.txt, w+) - No such file or directory in C:\Xitami\webpages\bomonster\test2.php on line 4 code.. ?php $rContents = implode( \n, file( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' ) ); if( ($fp = fopen( '/test/canberra.txt', 'w+' )) !== false ) { fputs( $fp, $rContents ); fclose( $fp ); } ? I think i know what the probelm is. .if( ($fp = fopen( '/test/canberra.txt', 'w+' )) !== false ) should be if( ($fp = fopen( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' , 'w+' )) !== false ) But, where do i put the file name and directory to write? -- Cheers - Simon Angell Canberra ACT www.canberra-wx.com - Member of: Australian Severe Weather Association. www.severeweather.asn.au - This email is virus free. Scanned before leaving my mailbox using Norton Antivirus 2002 for Win2k Scanned with the latest definition File. Robert Cummings [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Simon Angell wrote: Hi everyone. I asked this a week or so ago but i am unsure if it got to the list, so here we go again. I am trying to get a remote file to be copied onto my own web server, I have looked at fopen() and fread() and fwrite() and get the general idea of each, but im wondering how to join the commandes to get the file i want from the remote ftp server, copied and written onto my own server. Something like the following might work (not tested AT ALL): $rContents = implode( \n, file( 'ftp://www.foo.bar/me/my/data.txt' ) ); if( ($fp = fopen( '/tmp/myFile.txt', 'w+' )) !== false ) { fputs( $fp, $rContents ); fclose( $fp ); } -- .-. | Robert Cummings | :-`. | Webdeployer - Chief PHP and Java Programmer | :--: | Mail : mailto:[EMAIL PROTECTED] | | Phone : (613) 731-4046 x.109 | :--: | Website : http://www.webmotion.com | | Fax : (613) 260-9545 | `--' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question.
Thanks for that Robert *it works*, now i have 1 more problem, after uploading to my web server i get this... Warning: fopen(wtest.txt, wb+) - Permission denied in /home/canberra/public_html/bomonster/canberra.php on line 6 Dunno why either, the directory is not protected, can you help me with that one? -- Cheers - Simon Angell Canberra ACT www.canberra-wx.com - Member of: Australian Severe Weather Association. www.severeweather.asn.au - This email is virus free. Scanned before leaving my mailbox using Norton Antivirus 2002 for Win2k Scanned with the latest definition File. Robert Cummings [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Windows makes me cry... this will fix the problem... Change: $rContents = implode( \n, file( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' ) ); To: $rContents = implode( \r\n, file( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' ) ); If that doesn't work: To: $rContents = implode( \n\r, file( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' ) ); I can never remember the order :) Cheers, Rob. Simon Angell wrote: i removed a / and it worked :) ?php $rContents = implode( \n, file( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' ) ); if( ($fp = fopen( 'test/canberratest.txt', 'w+' )) !== false ) { fputs( $fp, $rContents ); fclose( $fp ); } ? Now the format of the content is no longer, can this be fixed? This is how it is originally. IDN10035 BUREAU OF METEOROLOGY CANBERRA METEOROLOGICAL OFFICE FORECAST FOR THE ACT Issued at 3:34pm on Tuesday the 1st of October 2002 SITUATION: AND this is how the text file writes IDN10035BUREAU OF METEOROLOGYCANBERRA METEOROLOGICAL OFFICEFORECAST FOR THE ACTIssued at 3:34pm on Tuesday the 1st of October 2002SITUATION: with all through it where a new line is suppose to be. Can this be fixed, or will i just need to work around it? -- Cheers - Simon Angell Canberra ACT www.canberra-wx.com - Member of: Australian Severe Weather Association. www.severeweather.asn.au - This email is virus free. Scanned before leaving my mailbox using Norton Antivirus 2002 for Win2k Scanned with the latest definition File. Simon Angell [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... i tried that ine and got this... Warning: fopen(/test/canberra.txt, w+) - No such file or directory in C:\Xitami\webpages\bomonster\test2.php on line 4 code.. ?php $rContents = implode( \n, file( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' ) ); if( ($fp = fopen( '/test/canberra.txt', 'w+' )) !== false ) { fputs( $fp, $rContents ); fclose( $fp ); } ? I think i know what the probelm is. .if( ($fp = fopen( '/test/canberra.txt', 'w+' )) !== false ) should be if( ($fp = fopen( 'ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10035.txt' , 'w+' )) !== false ) But, where do i put the file name and directory to write? -- Cheers - Simon Angell Canberra ACT www.canberra-wx.com - Member of: Australian Severe Weather Association. www.severeweather.asn.au - This email is virus free. Scanned before leaving my mailbox using Norton Antivirus 2002 for Win2k Scanned with the latest definition File. Robert Cummings [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Simon Angell wrote: Hi everyone. I asked this a week or so ago but i am unsure if it got to the list, so here we go again. I am trying to get a remote file to be copied onto my own web server, I have looked at fopen() and fread() and fwrite() and get the general idea of each, but im wondering how to join the commandes to get the file i want from the remote ftp server, copied and written onto my own server. Something like the following might work (not tested AT ALL): $rContents = implode( \n, file( 'ftp://www.foo.bar/me/my/data.txt' ) ); if( ($fp = fopen( '/tmp/myFile.txt', 'w+' )) !== false ) { fputs( $fp, $rContents ); fclose( $fp ); } -- .-. | Robert Cummings | :-`. | Webdeployer - Chief PHP and Java Programmer | :--: | Mail : mailto:[EMAIL PROTECTED] | | Phone : (613)
[PHP] quick question
hey people, I have been seeing something in a few php scripts i've been playing with and i really dont know what it means or does. I'm only new to php so maybe someone could explain. i have been seeing -...e.g. while($file = $dir - read()) what does the - mean and do. thanks heaps -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] quick question
basically it is used for accessing a variable in an array. Adam On Wed, 14 Aug 2002, Chris Barnes wrote: hey people, I have been seeing something in a few php scripts i've been playing with and i really dont know what it means or does. I'm only new to php so maybe someone could explain. i have been seeing -...e.g. while($file = $dir - read()) what does the - mean and do. thanks heaps -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Quick Question
I'm currently developing a Remote CMS for a site. I'm working on the image upload and want to create a smaller thumbnail type image (thought 200x180 instead of 50x50) I know I'm going to need either imagecopyresize() or imagecopyresample(). I don't know which would be better for this purpose or what the main difference is in terms of quality and run time. Any comments or assistance is gladly welcome. Thank you in advance for your time, Nicholas D. Mercier -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick Question
On Wednesday 24 July 2002 15:48, Nicholas Mercier wrote: I'm currently developing a Remote CMS for a site. I'm working on the image upload and want to create a smaller thumbnail type image (thought 200x180 instead of 50x50) I know I'm going to need either imagecopyresize() or imagecopyresample(). I don't know which would be better for this purpose or what the main difference is in terms of quality and run time. Any comments or assistance is gladly welcome. imagecopyresample() gives better results but probably takes a tad longer to perform. Presumably your thumbnails will be produced on a one-off basis (ie not generated on-the-fly each time it is needed) so the extra time taken by using imagecopyresample() is more than made up for by the better quality. Of course the best thing is to try both and see which is better for your needs. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Did you know that if you took all the economists in the world and lined them up end to end, they'd still point in the wrong direction? */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Quick question
I have a form, and if someone doesnt fill in a field it returns and asks them to filling in the missing field. I have made it so that the person doesnt lose everything, currently they will lose radio button information or checkbox information. Can someone tell me how to best keep it so the checkboxes stay checked or radio buttons stay selected. thanks, dan __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question
Quick answer: input type=checkbox name=name value=value?= ( $HTTP_POST_VARS['name']=='value' ? ' checked' : '' ) ? the same for radio boxes. Dan McCullough wrote: I have a form, and if someone doesnt fill in a field it returns and asks them to filling in the missing field. I have made it so that the person doesnt lose everything, currently they will lose radio button information or checkbox information. Can someone tell me how to best keep it so the checkboxes stay checked or radio buttons stay selected. thanks, dan __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question
Hello Dan, Please try this.Let me know if you have any problem. HTML HEAD TITLE/TITLE /HEAD BODY BGCOLOR=#FF TEXT=#00 LINK=#FF VLINK=#800080 script language=JavaScript function setChecked() { document.forms[0].r1value.value='on'; } function checkr1() { if(document.forms[0].r1value.value=='on') { alert(One of your radio button is selected); return false; } else { alert(Please select one of the radio button); return false; } } /script form onsubmit=checkr1() input type=radio name=r1 onclick=setChecked() input type=radio name=r1 onclick=setChecked() input type=radio name=r1 onclick=setChecked() input type=hidden name=r1value value=off input type=submit /form /BODY /HTML regards, SenthilVellan.P - Original Message - From: Dan McCullough [EMAIL PROTECTED] To: PHP General List [EMAIL PROTECTED] Sent: Friday, June 14, 2002 7:49 PM Subject: [PHP] Quick question I have a form, and if someone doesnt fill in a field it returns and asks them to filling in the missing field. I have made it so that the person doesnt lose everything, currently they will lose radio button information or checkbox information. Can someone tell me how to best keep it so the checkboxes stay checked or radio buttons stay selected. thanks, dan __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Quick Question about Classes
When you define a new class can you do the following? $className = Parent; class $className { }; Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Quick Question about Classes
You need to call new operator to create the object. Thank you, RAY HUNTER -Original Message- From: Jay [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 06, 2002 2:22 PM To: Php-General (E-mail) Subject: [PHP] Quick Question about Classes When you define a new class can you do the following? $className = Parent; class $className { }; Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] quick question
-Original Message- From: Erik Price [mailto:[EMAIL PROTECTED]] Sent: 10 January 2002 15:44 I thought that $_GET[] and $_POST[] could be used in place of regular variables... that is, $sql = SELECT * FROM tablename WHERE tablename.column=$_GET['criteria_integer']; but unfortunately, this isn't working. No, of course not -- I repeat: On Thursday, January 10, 2002, at 08:18 AM, Ford, Mike [LSS] wrote: But, if you insist on the quotes, it needs to be: case {$_POST['insert']} to ensure that the array index gets processed properly. Please note the {}, which you *MUST* include to get the array index processed properly. If you write: $_POST['insert'] PHP will try to interpret this as the variable called $_POST followed by the string ['insert'], which is clearly not what you want. including the {} forces it to use the value of $_POST['insert'], which *is* what you want. Incidentally, I've occasionally had problems including a variable name containing an underscore in a double-quoted string (e.g. $num_recs records retrieved), where PHP tries to insert the value of $num followed by the string _recs, so I always {} those as well, just to be on the safe side ({$num_recs} ... or ${num_recs} ... both work. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- 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] quick question
$sql = SELECT * FROM tablename WHERE tablename.column=$_GET['criteria_integer']; but unfortunately, this isn't working. On a related note, outside of strings one should always surround keys with quotes, so: $arr = array('a' = 'apple', 'b' = 'banana'); print $arr['a']; // apple print $arr[a]; // apple BUT this is bad Without the quotes is bad because PHP first: a) looks for the constant named 'a' b) if constant 'a' is not found, an error of type E_NOTICE is thrown. So, let's do this: define('a','b'); print $arr['a']; // apple print $arr[a]; // banana (no error) Because constants are not looked for within strings, the following is appropriate: print an $arr[a]; // an apple As are: print an {$arr['a']}; // an apple print an . $arr['a']; // an apple Anyway, maybe that helps explain a few things :) Regards, Philip Olson -- 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] both work? (was Re: [PHP] quick question)
On Friday, January 11, 2002, at 06:05 AM, Ford, Mike [LSS] wrote: Incidentally, I've occasionally had problems including a variable name containing an underscore in a double-quoted string (e.g. $num_recs records retrieved), where PHP tries to insert the value of $num followed by the string _recs, so I always {} those as well, just to be on the safe side ({$num_recs} ... or ${num_recs} ... both work. You mentioned that {$num_recs} and ${num_recs} both work -- I'm familiar with the second form from bash shell scripting, but not the first. Do they both work in all instances, or is one preferred over the other? Thanks Mike And sorry for making you repeat yourself (the first email I sent was incomplete but for some reason got sent, which you replied to and then the second, intended, email went out and that is when you wrote your second reply :). I have a better understanding of using associative indexes from arrays in double-quoted statements now. Erik -- 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] quick question
It seems that you are saying that not using quotes is bad (first), but then later you show that omitting the quotes does not result in an error. Or are you saying that the quotes can be omitted if the array element is being used in a string (between quotes), but generally the quotes around the constant are needed to perform non-string operations? Thank you, Erik On Friday, January 11, 2002, at 01:06 PM, Philip Olson wrote: $sql = SELECT * FROM tablename WHERE tablename.column=$_GET['criteria_integer']; but unfortunately, this isn't working. On a related note, outside of strings one should always surround keys with quotes, so: $arr = array('a' = 'apple', 'b' = 'banana'); print $arr['a']; // apple print $arr[a]; // apple BUT this is bad Without the quotes is bad because PHP first: a) looks for the constant named 'a' b) if constant 'a' is not found, an error of type E_NOTICE is thrown. So, let's do this: define('a','b'); print $arr['a']; // apple print $arr[a]; // banana (no error) Because constants are not looked for within strings, the following is appropriate: print an $arr[a]; // an apple As are: print an {$arr['a']}; // an apple print an . $arr['a']; // an apple Anyway, maybe that helps explain a few things :) Regards, Philip Olson -- 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] quick question
-Original Message- From: Erik Price [mailto:[EMAIL PROTECTED]] Sent: 09 January 2002 19:22 I'm trying to write my code in accordance with the PHP 4.1.0 security advisory -- that is, I want to use the $_GET and $_POST arrays when grabbing variables passed with GET and POST forms. But how should I construct the variables for a switch statement? I'm left confused, since these aren't written with the $ prefix as most variables are... Err -- yes, they are! Should it be: case _POST['insert'] or should it be: case $_POST['select'] What's wrong with: case $_POST['insert'] But, if you insist on the quotes, it needs to be: case {$_POST['insert']} to ensure that the array index gets processed properly. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- 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] quick question
I thought that $_GET[] and $_POST[] could be used in place of regular variables... that is, $sql = SELECT * FROM tablename WHERE tablename.column=$_GET['criteria_integer']; but unfortunately, this isn't working. On Thursday, January 10, 2002, at 08:18 AM, Ford, Mike [LSS] wrote: -Original Message- From: Erik Price [mailto:[EMAIL PROTECTED]] Sent: 09 January 2002 19:22 I'm trying to write my code in accordance with the PHP 4.1.0 security advisory -- that is, I want to use the $_GET and $_POST arrays when grabbing variables passed with GET and POST forms. But how should I construct the variables for a switch statement? I'm left confused, since these aren't written with the $ prefix as most variables are... Err -- yes, they are! Should it be: case _POST['insert'] or should it be: case $_POST['select'] What's wrong with: case $_POST['insert'] But, if you insist on the quotes, it needs to be: case {$_POST['insert']} to ensure that the array index gets processed properly. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- 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] quick question
I thought that $_GET[] and $_POST[] could be used in place of regular variables... that is, $sql = SELECT * FROM tablename WHERE tablename.column=$_GET['criteria_integer']; but unfortunately, this isn't working. It resulted in the following error message in the browser: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/eprice/public_html/people3.php on line 150 Yes, line 150 is exactly where I have this. It does seem to work if I do this: $criteria_integer = $_GET['criteria_integer']; $sql = SELECT * FROM tablename WHERE tablename.column=$criteria_integer; But I thought that the $_GET variable could be used in the same way that I historically used the simple variable name $criteria_integer . Can anyone shed some light on how these predefined variables work in this instance? Erik On Thursday, January 10, 2002, at 08:18 AM, Ford, Mike [LSS] wrote: -Original Message- From: Erik Price [mailto:[EMAIL PROTECTED]] Sent: 09 January 2002 19:22 I'm trying to write my code in accordance with the PHP 4.1.0 security advisory -- that is, I want to use the $_GET and $_POST arrays when grabbing variables passed with GET and POST forms. But how should I construct the variables for a switch statement? I'm left confused, since these aren't written with the $ prefix as most variables are... Err -- yes, they are! Should it be: case _POST['insert'] or should it be: case $_POST['select'] What's wrong with: case $_POST['insert'] But, if you insist on the quotes, it needs to be: case {$_POST['insert']} to ensure that the array index gets processed properly. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- 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] quick question
Yes, but $sql is passed to the database, which has no understanding of $_GET. Will it take PHP that much longer to make this assignment: $criteria_integer = $_GET['criteria_integer']; With the benefit that the SQL is much easier to read $sql = SELECT * FROM tablename WHERE tablename.column='$criteria_integer' ; Or maybe you need another layer of quotes, but I'd vote for clarity. Miles Thompson At 10:44 AM 1/10/2002 -0500, Erik Price wrote: I thought that $_GET[] and $_POST[] could be used in place of regular variables... that is, $sql = SELECT * FROM tablename WHERE tablename.column=$_GET['criteria_integer']; but unfortunately, this isn't working. On Thursday, January 10, 2002, at 08:18 AM, Ford, Mike [LSS] wrote: -Original Message- From: Erik Price [mailto:[EMAIL PROTECTED]] Sent: 09 January 2002 19:22 I'm trying to write my code in accordance with the PHP 4.1.0 security advisory -- that is, I want to use the $_GET and $_POST arrays when grabbing variables passed with GET and POST forms. But how should I construct the variables for a switch statement? I'm left confused, since these aren't written with the $ prefix as most variables are... Err -- yes, they are! Should it be: case _POST['insert'] or should it be: case $_POST['select'] What's wrong with: case $_POST['insert'] But, if you insist on the quotes, it needs to be: case {$_POST['insert']} to ensure that the array index gets processed properly. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] quick question
Erik, Although, I've not proved this I think the PHP parser gets confused when it sees a complex variable reference, $_GET[ 'criteria_integer' ] embedded within double quotes. I've run into similar error messages so I've been breaking out the variable from the double quotes as follows: $sql = SELECT * FROM tablename WHERE tablename.column= . $_GET['criteria_integer']; or: $A = $_GET['criteria_integer']; $sql = SELECT * FROM tablename WHERE tablename.column=$A; Erik Price wrote: I thought that $_GET[] and $_POST[] could be used in place of regular variables... that is, $sql = SELECT * FROM tablename WHERE tablename.column=$_GET['criteria_integer']; but unfortunately, this isn't working. It resulted in the following error message in the browser: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/eprice/public_html/people3.php on line 150 Yes, line 150 is exactly where I have this. It does seem to work if I do this: $criteria_integer = $_GET['criteria_integer']; $sql = SELECT * FROM tablename WHERE tablename.column=$criteria_integer; But I thought that the $_GET variable could be used in the same way that I historically used the simple variable name $criteria_integer . Can anyone shed some light on how these predefined variables work in this instance? Erik On Thursday, January 10, 2002, at 08:18 AM, Ford, Mike [LSS] wrote: -Original Message- From: Erik Price [mailto:[EMAIL PROTECTED]] Sent: 09 January 2002 19:22 I'm trying to write my code in accordance with the PHP 4.1.0 security advisory -- that is, I want to use the $_GET and $_POST arrays when grabbing variables passed with GET and POST forms. But how should I construct the variables for a switch statement? I'm left confused, since these aren't written with the $ prefix as most variables are... Err -- yes, they are! Should it be: case _POST['insert'] or should it be: case $_POST['select'] What's wrong with: case $_POST['insert'] But, if you insist on the quotes, it needs to be: case {$_POST['insert']} to ensure that the array index gets processed properly. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- 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] -- Do you need a Web-based Content Publishing System ? Call me for more details. Ed Swartz ColdFusion and PHP Development 978.772.0888 http://www.sandypondconsulting.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]
[PHP] quick question
Just a quick question -- I'm temporarily unsubbed so if anyone could CC me directly that would be great. I'm trying to write my code in accordance with the PHP 4.1.0 security advisory -- that is, I want to use the $_GET and $_POST arrays when grabbing variables passed with GET and POST forms. But how should I construct the variables for a switch statement? I'm left confused, since these aren't written with the $ prefix as most variables are... Should it be: case _POST['insert'] or should it be: case $_POST['select'] ? Thanks very much! Erik PS: I can't test it myself b/c my php.ini file is register_globals=on so I won't know the difference, but I'm curious for all future code I write to be compatible. -- 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] Quick question about recompiling with GD library
Hello, I have png/jpeg support and gd 1.8.3 I see, however, some linux ./configure examples that just use --with-gd and no --with=/usr/local/png or whatever the question is, would --with-gd be enough to create/add text to jpeg/png or *only* if they are included? Just want to double check Thanks Joel Ps. Is there a way php can access the .so file without compiling that library? I saw an example where they connected to the ming (To create flash files) .so file, is that a workaround from having to ./configure and is it bad practice?
[PHP] Quick Question about Variables
I have a form with checkboxes and they have a name of associate_id. How can I call these variables (or other ideas of getting ID numbers from check boxes)? In PERL i know you can use ${associate_.$id} but I cant seem to find the equivalent for PHP. I could then get a list of id's and check if each one is on. I think this would be the easiest, but maybe someone else has another idea. Thanks in advanced, Matthew Walkup [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] Quick Question about Variables --- NEVERMIND
Hah, I saw parse error and assumed it was because i was trying to use a function that didnt exist. Little did I know I mistyped something. It works now, sorry for the inconvience. Thanks, Matt -Original Message- From: Matthew Walkup [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 12, 2001 1:27 AM To: [EMAIL PROTECTED] Subject: [PHP] Quick Question about Variables I have a form with checkboxes and they have a name of associate_id. How can I call these variables (or other ideas of getting ID numbers from check boxes)? In PERL i know you can use ${associate_.$id} but I cant seem to find the equivalent for PHP. I could then get a list of id's and check if each one is on. I think this would be the easiest, but maybe someone else has another idea. Thanks in advanced, Matthew Walkup [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] -- 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] Quick question about no result
I want to show a default piece of information if my query returns no result, and what I mean by no result is the query for a store in a certain state doesnt exist. thanks dan = Dan McCullough --- Theres no such thing as a problem unless the servers are on fire! h: 603.444.9808 w: McCullough Family w: At Work __ Do You Yahoo!? Find the one for you at Yahoo! Personals http://personals.yahoo.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]
[PHP] quick question.
I was just wondering if I could call some functions out side of the class I'm making? The reason why I want to do this is so that I don't have to rewrite the functions as methods in the class and I don't want to get too far into what I'm doing before I find out it doesn't work. Thanks, Jay -- 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] quick question.
: I was just wondering if I could call some functions out side of the class : I'm making? The reason why I want to do this is so that I don't have to : rewrite the functions as methods in the class and I don't want to get too : far into what I'm doing before I find out it doesn't work. Sure you can. All functions in the Global scope can be called from inside the class. Joel -- 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] quick question: frames OT
Hi Romulo Roberto Pereira, Wednesday, May 09, 2001, 7:11:38 AM, you wrote: Romulo Hello! Romulo Just a quick ot question: Romulo From a php script I open a frameset this divides the browser window in two Romulo rows. How do I do to get rid of the frameset without closing the window? try a link like this: a href=nonframepage.html target=_topExit Frames/a --- EnjoY, Adaran ([EMAIL PROTECTED]) check http://www.adaran.net -- 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] quick question: frames OT
Hello! Just a quick ot question: From a php script I open a frameset this divides the browser window in two rows. How do I do to get rid of the frameset without closing the window? TIA Rom -- 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] quick question on the passed variables between scripts
Hello! I have one script that has a bunch of checkboxes in a form, all them with different names. As you know the form only submit the ones that are checked. I would like to know witch ones the user checked (they will come in the path as variables I suppose) because I need to make a sum of the ones that are checked, and right now I am using isset() to verify before I sum. This is way too bad, because as I have 48 checkboxes I have too many IFs. Please help! Rom Example: this is what I am doing: script 1: form action=script2.php input type=checkbox name=cb01 value=729 input type=checkbox name=cb02 value=815 input type=checkbox name=cb03 value=36 input type=checkbox name=cb04 value=988 input type=checkbox name=cb05 value=215 input type=checkbox name=cb06 value=45446 input type=checkbox name=cb07 value=22 input type=checkbox name=cb08 value=52564 input type=checkbox name=cb09 value=455 input type=checkbox name=cb10 value=21132 /form script 2: $sum = 0; if (isset($cb01)) $sum = $sum + $cb01; if (isset($cb02)) $sum = $sum + $cb02; if (isset($cb03)) $sum = $sum + $cb03; if (isset($cb04)) $sum = $sum + $cb04; if (isset($cb05)) $sum = $sum + $cb05; if (isset($cb06)) $sum = $sum + $cb06; if (isset($cb07)) $sum = $sum + $cb07; if (isset($cb08)) $sum = $sum + $cb08; if (isset($cb09)) $sum = $sum + $cb09; if (isset($cb10)) $sum = $sum + $cb10; echo $sum; -- 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]