[PHP] PHP 5 limits "readfile" to 1.9 MB?
Hello all, I am new to this list and I have searched the archives to no avail. I am having a peculiar problem when upgrading to PHP 5: My downloads are now limited to the first 1.9 MB of the file in question, with the download either terminating at 1.9 MB or seemingly continuously stuck in a downloading process at 1.9 MB. The code in the PHP script has not changed and all parameters that I could find that are relevant to this problem are given below: the minimal code needed for download: // $file_to_read is the complete path of the file to download header("Content-Type: application/pdf"); header( "Content-Disposition: inline; filename=\"$filename\""); $len = filesize($file_to_read); header("Content-Length: $len"); @readfile($file_to_read); php.ini file for both php version 4 and 5 contain the following settings that may be relevant: allow_url_fopen = On max_execution_time = 300 ; Maximum execution time of each script, in seconds max_input_time = 300; Maximum amount of time each script may spend parsing request data memory_limit = 8M ; Maximum amount of memory a script may consume (8MB) post_max_size = 200M upload_max_filesize = 200M Some additional details: All files less than 1.9 MB download fine It is not a corrupted file, because all files larger than 1.9 MB fail after 1.9 MB The connection is not timing out (download of 1.9 MB takes only ~15 sec) Mac OS X 10.3.9 with Marc Liyanage's PHP 5.0.4 Fails for both Safari and Firefox Fails regardless of "inline" or "attachment" Fails regardless of "pdf" or "ppt" content-type This PHP code ALWAYS works for Marc Liyanage's PHP 4.3.4 with the same settings, above What am I doing wrong??? Any other parameter in php.ini I should have set? Any suggestions are much appreciated. thanks, Jordan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP 5 limits "readfile" to 1.9 MB?
Catalin, Wow, that worked great, thanks. I'm curious why you set a static buffer of 1024768... why not just do filesize($file), as shown at http://www.php.net/fread ? Is it better for memory usage to have a potentially smaller buffer? Also, you may want an fclose($fp) after the file has been downloaded. So is this a bug in PHP 5 or are they just purposely limiting the abilities of the "readfile" command? Jordan On Aug 17, 2005, at 3:36 AM, Catalin Trifu wrote: Hi, I've had a similar problem. The download always stopped at exactly 2.000.000 bytes. You have to work around that with: $fp = fopen($file, 'r'); if($fp) { while(!feof($fp)) { echo fread($fp, 1024768);//see the huge buffer to read into } } else { //whatever error handler } Catalin Jordan Miller wrote: Hello all, I am new to this list and I have searched the archives to no avail. I am having a peculiar problem when upgrading to PHP 5: My downloads are now limited to the first 1.9 MB of the file in question, with the download either terminating at 1.9 MB or seemingly continuously stuck in a downloading process at 1.9 MB. The code in the PHP script has not changed and all parameters that I could find that are relevant to this problem are given below: the minimal code needed for download: // $file_to_read is the complete path of the file to download header("Content-Type: application/pdf"); header( "Content-Disposition: inline; filename=\"$filename \""); $len = filesize($file_to_read); header("Content-Length: $len"); @readfile($file_to_read); php.ini file for both php version 4 and 5 contain the following settings that may be relevant: allow_url_fopen = On max_execution_time = 300 ; Maximum execution time of each script, in seconds max_input_time = 300; Maximum amount of time each script may spend parsing request data memory_limit = 8M ; Maximum amount of memory a script may consume (8MB) post_max_size = 200M upload_max_filesize = 200M Some additional details: All files less than 1.9 MB download fine It is not a corrupted file, because all files larger than 1.9 MB fail after 1.9 MB The connection is not timing out (download of 1.9 MB takes only ~15 sec) Mac OS X 10.3.9 with Marc Liyanage's PHP 5.0.4 Fails for both Safari and Firefox Fails regardless of "inline" or "attachment" Fails regardless of "pdf" or "ppt" content-type This PHP code ALWAYS works for Marc Liyanage's PHP 4.3.4 with the same settings, above What am I doing wrong??? Any other parameter in php.ini I should have set? Any suggestions are much appreciated. thanks, Jordan -- 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] optional argument when creating a function
apparently the ampersand means to treat $link as a reference, not as an optional argument: http://www.softwareprojects.org/php-functions-12.htm I think the way to do it would be to set a default value in your function so that if a value is set by the calling statement that would override it: function doEmail($username, $link = false) { if ($link !=== false) { // "doEmail($arg1, $arg2);" gets sent here print "$link $username"; } else { // "doEmail($arg1);" gets sent here print "$username"; } } haven't tested this, but give it a try. Jordan On Aug 17, 2005, at 10:00 AM, D A GERM wrote: I'm throwing a warning on a function I created. I thought a & in front of the argument was supposed to make it optional. Is there something else I need to do make that argument optional? //I simplified the code function doEmail($username, &$link) { if (isset($link)) { print "$link $username"; } else { print "$username"; } } doEmail($arg1); doEmail($arg1, $arg2); Here is the error: Warning: Missing argument 2 for doemail() in /srv/www/htdocs/test-a/staff/email_scramble.php on line 24 thanks in advance for any help. -- D. Aaron Germ Scarborough Library, Shepherd University (304) 876-5423 "Well then what am I supposed to do with all my creative ideas- take a bath and wash myself with them? 'Cause that is what soap is for" (Peter, Family Guy) -- 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] How Can I delete an Item of one array
you use the unset() function: unset($array[$key]); // http://www.php.net/unset you can reindex the keys if they are numeric with: $reindexedArray = array_values($array); // http://www.php.net/ array_values Jordan On Aug 17, 2005, at 1:12 PM, Tomás Rodriguez Orta wrote: Hi people. How Can I do this. I want to delete an element behind of array?, what function What Can I use? best regards TOMAS -- --- Este correo fue escaneado en busca de virus con el MDaemon Antivirus 2.27 en el dominio de correo angerona.cult.cu y no se encontro ninguna coincidencia. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP 5 limits "readfile" to 1.9 MB?
Ok, just checking (I am new to the fopen() function). That makes sense. Awesome, thanks! Jordan On Aug 17, 2005, at 10:19 AM, Catalin Trifu wrote: Hi, Indeed a fclose($fp) is needed (wrote it as an example :)). 1MB is more than enough as a buffer. If you have a 53MB file, what will happen then ? I have no idea if it's a bug or a feature. Either way I did lose some hair over this when I switched from PHP4 to PHP5. Catalin Jordan Miller wrote: Catalin, Wow, that worked great, thanks. I'm curious why you set a static buffer of 1024768... why not just do filesize($file), as shown at http://www.php.net/fread ? Is it better for memory usage to have a potentially smaller buffer? Also, you may want an fclose($fp) after the file has been downloaded. So is this a bug in PHP 5 or are they just purposely limiting the abilities of the "readfile" command? Jordan On Aug 17, 2005, at 3:36 AM, Catalin Trifu wrote: Hi, I've had a similar problem. The download always stopped at exactly 2.000.000 bytes. You have to work around that with: $fp = fopen($file, 'r'); if($fp) { while(!feof($fp)) { echo fread($fp, 1024768);//see the huge buffer to read into } } else { //whatever error handler } Catalin Jordan Miller wrote: Hello all, I am new to this list and I have searched the archives to no avail. I am having a peculiar problem when upgrading to PHP 5: My downloads are now limited to the first 1.9 MB of the file in question, with the download either terminating at 1.9 MB or seemingly continuously stuck in a downloading process at 1.9 MB. The code in the PHP script has not changed and all parameters that I could find that are relevant to this problem are given below: the minimal code needed for download: // $file_to_read is the complete path of the file to download header("Content-Type: application/pdf"); header( "Content-Disposition: inline; filename= \"$filename \""); $len = filesize($file_to_read); header("Content-Length: $len"); @readfile($file_to_read); php.ini file for both php version 4 and 5 contain the following settings that may be relevant: allow_url_fopen = On max_execution_time = 300 ; Maximum execution time of each script, in seconds max_input_time = 300; Maximum amount of time each script may spend parsing request data memory_limit = 8M ; Maximum amount of memory a script may consume (8MB) post_max_size = 200M upload_max_filesize = 200M Some additional details: All files less than 1.9 MB download fine It is not a corrupted file, because all files larger than 1.9 MB fail after 1.9 MB The connection is not timing out (download of 1.9 MB takes only ~15 sec) Mac OS X 10.3.9 with Marc Liyanage's PHP 5.0.4 Fails for both Safari and Firefox Fails regardless of "inline" or "attachment" Fails regardless of "pdf" or "ppt" content-type This PHP code ALWAYS works for Marc Liyanage's PHP 4.3.4 with the same settings, above What am I doing wrong??? Any other parameter in php.ini I should have set? Any suggestions are much appreciated. thanks, Jordan -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP 5 limits "readfile" to 1.9 MB?
turns out it's a known bug, fixed in CVS already... haven't tried the PHP 5.1 beta release yet. http://bugs.php.net/bug.php?id=32970 On Aug 17, 2005, at 10:19 AM, Catalin Trifu wrote: Hi, Indeed a fclose($fp) is needed (wrote it as an example :)). 1MB is more than enough as a buffer. If you have a 53MB file, what will happen then ? I have no idea if it's a bug or a feature. Either way I did lose some hair over this when I switched from PHP4 to PHP5. Catalin Jordan Miller wrote: Catalin, Wow, that worked great, thanks. I'm curious why you set a static buffer of 1024768... why not just do filesize($file), as shown at http://www.php.net/fread ? Is it better for memory usage to have a potentially smaller buffer? Also, you may want an fclose($fp) after the file has been downloaded. So is this a bug in PHP 5 or are they just purposely limiting the abilities of the "readfile" command? Jordan On Aug 17, 2005, at 3:36 AM, Catalin Trifu wrote: Hi, I've had a similar problem. The download always stopped at exactly 2.000.000 bytes. You have to work around that with: $fp = fopen($file, 'r'); if($fp) { while(!feof($fp)) { echo fread($fp, 1024768);//see the huge buffer to read into } } else { //whatever error handler } Catalin Jordan Miller wrote: Hello all, I am new to this list and I have searched the archives to no avail. I am having a peculiar problem when upgrading to PHP 5: My downloads are now limited to the first 1.9 MB of the file in question, with the download either terminating at 1.9 MB or seemingly continuously stuck in a downloading process at 1.9 MB. The code in the PHP script has not changed and all parameters that I could find that are relevant to this problem are given below: the minimal code needed for download: // $file_to_read is the complete path of the file to download header("Content-Type: application/pdf"); header( "Content-Disposition: inline; filename= \"$filename \""); $len = filesize($file_to_read); header("Content-Length: $len"); @readfile($file_to_read); php.ini file for both php version 4 and 5 contain the following settings that may be relevant: allow_url_fopen = On max_execution_time = 300 ; Maximum execution time of each script, in seconds max_input_time = 300; Maximum amount of time each script may spend parsing request data memory_limit = 8M ; Maximum amount of memory a script may consume (8MB) post_max_size = 200M upload_max_filesize = 200M Some additional details: All files less than 1.9 MB download fine It is not a corrupted file, because all files larger than 1.9 MB fail after 1.9 MB The connection is not timing out (download of 1.9 MB takes only ~15 sec) Mac OS X 10.3.9 with Marc Liyanage's PHP 5.0.4 Fails for both Safari and Firefox Fails regardless of "inline" or "attachment" Fails regardless of "pdf" or "ppt" content-type This PHP code ALWAYS works for Marc Liyanage's PHP 4.3.4 with the same settings, above What am I doing wrong??? Any other parameter in php.ini I should have set? Any suggestions are much appreciated. thanks, Jordan -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail()
Did you install sendmail? http://www.php.net/mail Requirements For the Mail functions to be available, PHP must have access to the sendmail binary on your system during compile time. If you use another mail program, such as qmail or postfix, be sure to use the appropriate sendmail wrappers that come with them. PHP will first look for sendmail in your PATH, and then in the following: /usr/bin:/ usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib. It's highly recommended to have sendmail available from your PATH. Also, the user that compiled PHP must have permission to access the sendmail binary. On Aug 17, 2005, at 11:48 AM, George B wrote: Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() I checked php.ini and everything is open [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 ; For Win32 only. sendmail_from = [EMAIL PROTECTED] SO why does it not work? -- 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] Help correcting a form mailer problem...
wherever you think you are adding data to the gmev array, you are merely adding the "on" string. I would search your script for the string "on" and you will find the problem. what you need is the value in the HTML form to be the text you want inserted into the array, such as: Jordan On Aug 17, 2005, at 3:30 PM, zedleon wrote: thanks for the reply... after using the print_r($_POST['gmev']); and selecting all the checkboxes to send to the form the return is Array ( [0] => on [1] => on [2] => on [3] => on ). So the values are missing. don't really know how to proceed at this point. any help is appreciated. "Joe Wollard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I would first start out by dumping the values of $_POST['gmev'] by using print_r($_POST['gmev']); Sounds to me like you're not getting the data that your expecting from the form for some reason. Maybe $_POST['gmev'] is an array of null values? -Good Luck On Aug 17, 2005, at 12:15 PM, zedleon wrote: I previously built a sticky form with dynamic checkbox array's. The form works beautifully thanks to help from Jochem Mass and Kathleen Ballard. I now have a slightly different problem...I have built an email form to send the form data. I copied and used the following code which works great in the sticky form. if (isset($_POST['gmev']) && is_array($_POST['gmev'])) { foreach ($_POST['gmev'] as $gmev_day) { print "You have registered for the: $gmev_day Good Morning East Valley Event."; } } else { print 'You are not registered for any events!'; } The results is this: "You have registered for the: September 9th Good Morning East Valley Event." Now when I use the same code modified for the form mailer I am getting this result. if (isset($_POST['gmev']) && is_array($_POST['gmev'])) { foreach ($_POST['gmev'] as $gmev_day) { $msg .= "You have registered for the: $gmev_day Good Morning East Valley Event.\n"; } } else { $mgs .= "You are not registered for any events!"; } result is - "You have registered for the: on Good Morning East Valley Event." I am missing the value of the variable even though I am receiving all the instances of the variables from the checkboxes. When they are selected, they are present. I really don't know what to do about correcting the problem. Any guidance here would really be appreciatedand...go easy on me...I am new to PHP Thanks before hand... zedleon -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help correcting a form mailer problem...
Sorry, I believe you are mistaken here... you *can* specify a value for each checkbox and have it come through. I have written scripts that do this, and here is another example: http://www.tizag.com/phpT/examples/formex.php/ all zedleon needs to do is add the correct value parameter to each checkbox. Jordan On Aug 17, 2005, at 3:57 PM, <[EMAIL PROTECTED]> wrote: Sorry I should clarify... checkboxes don't send their values through they send their names and states... so if you have the array: Name="qmev[1]"... name="qmev[2]"... name="qmev[3]" And your array contains [1] => on : [3] => on 1 and 3 are selected -Original Message- From: zedleon [mailto:[EMAIL PROTECTED] Sent: 17 August 2005 21:30 To: php-general@lists.php.net Subject: Re: [PHP] Help correcting a form mailer problem... thanks for the reply... after using the print_r($_POST['gmev']); and selecting all the checkboxes to send to the form the return is Array ( [0] => on [1] => on [2] => on [3] => on ). So the values are missing. don't really know how to proceed at this point. any help is appreciated. "Joe Wollard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I would first start out by dumping the values of $_POST['gmev'] by using print_r($_POST['gmev']); Sounds to me like you're not getting the data that your expecting from the form for some reason. Maybe $_POST['gmev'] is an array of null values? -Good Luck On Aug 17, 2005, at 12:15 PM, zedleon wrote: I previously built a sticky form with dynamic checkbox array's. The form works beautifully thanks to help from Jochem Mass and Kathleen Ballard. I now have a slightly different problem...I have built an email form to send the form data. I copied and used the following code which works great in the sticky form. if (isset($_POST['gmev']) && is_array($_POST['gmev'])) { foreach ($_POST['gmev'] as $gmev_day) { print "You have registered for the: $gmev_day Good Morning East Valley Event."; } } else { print 'You are not registered for any events!'; } The results is this: "You have registered for the: September 9th Good Morning East Valley Event." Now when I use the same code modified for the form mailer I am getting this result. if (isset($_POST['gmev']) && is_array($_POST['gmev'])) { foreach ($_POST['gmev'] as $gmev_day) { $msg .= "You have registered for the: $gmev_day Good Morning East Valley Event.\n"; } } else { $mgs .= "You are not registered for any events!"; } result is - "You have registered for the: on Good Morning East Valley Event." I am missing the value of the variable even though I am receiving all the instances of the variables from the checkboxes. When they are selected, they are present. I really don't know what to do about correcting the problem. Any guidance here would really be appreciatedand...go easy on me...I am new to PHP Thanks before hand... zedleon -- 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 __ NOD32 1.1196 (20050817) Information __ This message was checked by NOD32 antivirus system. http://www.eset.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
Re: [PHP] Help correcting a form mailer problem...
Ted, On your "sticky" page, your checkbox input commands no longer have their corresponding "value" attributes. Just add those back in, and you will be all set (you only have the "value" attribute set on the event_reg.php page, NOT on the event_reg_calc.php page). This is your only problem. i.e. change the code so that the output here: http://www.passeycorp.com/event_reg_calc.php will change from this: to this: checked="checked"/> Jordan On Aug 17, 2005, at 4:52 PM, Support wrote: Thanks for the post... The problem I am having here is that once the "sticky" or dynamic form is created... The checkboxes at that point don't seem to be "passing the value" only the state. So when it is submitted to the send mail form no value appears. I need to make the "sticky" pass the value... How is this done? test form is on http://www.passeycorp.com/event_reg.php check it out and I think you'll see what I mean. The suggestions and help are greatly appreciated. Ted - Original Message - From: "Jordan Miller" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: Sent: Wednesday, August 17, 2005 5:28 PM Subject: Re: [PHP] Help correcting a form mailer problem... Sorry, I believe you are mistaken here... you *can* specify a value for each checkbox and have it come through. I have written scripts that do this, and here is another example: http://www.tizag.com/phpT/examples/formex.php/ all zedleon needs to do is add the correct value parameter to each checkbox. Jordan On Aug 17, 2005, at 3:57 PM, <[EMAIL PROTECTED]> wrote: Sorry I should clarify... checkboxes don't send their values through they send their names and states... so if you have the array: Name="qmev[1]"... name="qmev[2]"... name="qmev[3]" And your array contains [1] => on : [3] => on 1 and 3 are selected -Original Message- From: zedleon [mailto:[EMAIL PROTECTED] Sent: 17 August 2005 21:30 To: php-general@lists.php.net Subject: Re: [PHP] Help correcting a form mailer problem... thanks for the reply... after using the print_r($_POST['gmev']); and selecting all the checkboxes to send to the form the return is Array ( [0] => on [1] => on [2] => on [3] => on ). So the values are missing. don't really know how to proceed at this point. any help is appreciated. "Joe Wollard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I would first start out by dumping the values of $_POST['gmev'] by using print_r($_POST['gmev']); Sounds to me like you're not getting the data that your expecting from the form for some reason. Maybe $_POST['gmev'] is an array of null values? -Good Luck On Aug 17, 2005, at 12:15 PM, zedleon wrote: I previously built a sticky form with dynamic checkbox array's. The form works beautifully thanks to help from Jochem Mass and Kathleen Ballard. I now have a slightly different problem...I have built an email form to send the form data. I copied and used the following code which works great in the sticky form. if (isset($_POST['gmev']) && is_array($_POST['gmev'])) { foreach ($_POST['gmev'] as $gmev_day) { print "You have registered for the: $gmev_day Good Morning East Valley Event."; } } else { print 'You are not registered for any events!'; } The results is this: "You have registered for the: September 9th Good Morning East Valley Event." Now when I use the same code modified for the form mailer I am getting this result. if (isset($_POST['gmev']) && is_array($_POST['gmev'])) { foreach ($_POST['gmev'] as $gmev_day) { $msg .= "You have registered for the: $gmev_day Good Morning East Valley Event.\n"; } } else { $mgs .= "You are not registered for any events!"; } result is - "You have registered for the: on Good Morning East Valley Event." I am missing the value of the variable even though I am receiving all the instances of the variables from the checkboxes. When they are selected, they are present. I really don't know what to do about correcting the problem. Any guidance here would really be appreciatedand...go easy on me...I am new to PHP Thanks before hand... zedleon -- 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 __ NOD32 1.1196 (20050817) Information __ This message was checked by NOD32 antivirus system. http://www.eset.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
Re: [PHP] sending HTML (incl. embedded images) to browser
Hi Jake, You don't have to do anything special, you just have to have standards compliant HTML output. What is the HTML for the IMG tag output to the browser (i.e. go to the web browser, load the page in question, find the img tag, and send us this text). I think maybe your images are just not in the right directory or are not being referenced correctly. also, what is the actual PHP code used to print the img tag? maybe you're not escaping quotes correctly...? Jordan On Aug 17, 2005, at 5:42 PM, Jake Sapirstein wrote: Hi List, I am a PHP newbie, pardon the elementary question - I am starting out with using print() to send HTML to the browser to be rendered. All is well with text and tables and other HTML formatting, but when trying to send IMG tags, my images aren't getting displayed. Is there a good tutorial out there (I can't seem to find it) on how to send HTML to a browser where the HTML includes IMG tags with links to image files? If I need to set up the filepaths with variables I can figure that out, but not sure what functions to use to set the paths up. Thanks for any pointers! -Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: sending HTML (incl. embedded images) to browser
Pardon me, but I don't think he is trying to send an HTML email. I believe he is just asking about making a simple webpage. Relative URLs should be fine and are often preferable for portability. Jordan On Aug 17, 2005, at 7:34 PM, Manuel Lemos wrote: Hello, on 08/17/2005 07:42 PM Jake Sapirstein said the following: > I am a PHP newbie, pardon the elementary question - I am starting out with using print() to send HTML to the browser to be rendered. All is well with text and tables and other HTML formatting, but when trying to send IMG tags, my images aren't getting displayed. > > Is there a good tutorial out there (I can't seem to find it) on how to send HTML to a browser where the HTML includes IMG tags with links to image files? If I need to set up the filepaths with variables I can figure that out, but not sure what functions to use to set the paths up. You need to use absolute URLs for the images. Still, some mail programs and webmail sites disable remote image displaying by default as images may be beacons to spy on users. ALternatively you can embeded images in the actual HTML messages and they always display properly. That is done with MIME multipart/ related messages. You may want to take a look at this MIME message class that can be used to compose messages with embedded images. It comes with an example named test_html_mail_message.php that shows exactly how to do that: http://www.phpclasses.org/mimemessage -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html -- 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] PHP MySQL insert
besides just escaping your strings, i think you are having a quoting error: http://www.php.net/manual/en/language.types.string.php Commas should not have to be escaped, and indeed the mysql_real_escape_string() function will not escape commas. After escaping your input data with this function, I would make the $query text a bit more technically correct: Change this: $query = "insert into testtable6 (indx, col1, col2) values (NULL, '$data1', '$data2')"; to this: $query = "insert into testtable6 (indx, col1, col2) values (NULL, '". $data1."', '".$data2."')"; echo $query."\n"; to ensure proper handling of all data in the sql commands. If you echo your $query before the insert, what do you get? This is always a good practice when you're having trouble. Jordan On Aug 18, 2005, at 12:05 PM, Chris wrote: You need to escape the data, so $data1 = mysql_real_escape_string($data1,$rLink); $data2 = mysql_real_escape_string($data2,$rLink); Jon wrote: Please help with an insert problem. Sometimes $data1 could have a comma and that messes up the insert. how do I get around that? $query = "insert into testtable6 (indx, col1, col2) values (NULL, '$data1', '$data2')"; mysql_db_query("testdb", $query); -- 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] Week Days
Yo, All you need is the mktime() command. do something like: $futureDate = date("Y-m-d", mktime(0, 0, 0, $month, $today+ $daysToAdd, $year)); Jordan http://www.php.net/mktime mktime() is useful for doing date arithmetic and validation, as it will automatically calculate the correct value for out-of-range input. For example, each of the following lines produces the string "Jan-01-1998". On Aug 19, 2005, at 12:57 AM, [EMAIL PROTECTED] wrote: I am trying to add 3 (or a user-defined amount) week days to a certain date.. An example is today 2005-08-18 then adding 3 week days to give me a date of 2005-08-23. I have tried searching online but cannot find an easy way of doing so.
Re: [PHP] build sql query struture and values from form fields
I agree, you must be careful of SQL injection... use mysql_real_escape_string(). To chop off the last character of text use substr(): $sqlstruct = substr($sqlstruct, 0, -1); Jordan http://www.php.net/substr Example 3. Using a negative length On Aug 20, 2005, at 4:55 PM, Greg Donald wrote: On 8/20/05, Andras Kende <[EMAIL PROTECTED]> wrote: I would like to create the mysql insert query for my html form fields, I have a small problem it will have an extra , at the end of $sqlstruct And extra "" at $sqldata.. Anyone can give a hint ? foreach ($_POST as $variable=>$value){ $sqlstruct.=$variable","; $sqldata.=$value."\"','\""; } $query="insert into db ($sqlstruct) VALUES ($sqldata)"; $k = implode( ',', array_keys( $_POST ) ); $v = implode( ',', array_values( $_POST ) ); $sql = "INSERT INTO db ( $k ) VALUES ( $v )"; I'd never do something like this though, just begs for SQL injection. -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.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
Re: [PHP] Special HTML characters question.
Did you try html_entity_decode? http://us2.php.net/html_entity_decode You may want to combine this with mysql_real_escape_string()...? Jordan On Aug 22, 2005, at 8:29 AM, Jay Paulson wrote: I have a problem that I'm sure some of you have run into before, therefore I hope you all know of an easy solution. Some of my users are cutting and pasting text from Word into text fields that are being saved into a database then from that database being displayed on a web page. The problem occurs when some special characters are being used. Double quotes, single quotes, and other characters like accents etc have the special html code like "e; etc replacing the special characters. What methods are being used to combat this issue? Is there a solution out there to run text through some sort of filter before submitting it to the database to look for these special characters and then replacing them? Thanks for any help, Jay -- 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] Problem with SimpleXML
Yes, simplexml can do this easily. See: http://www.php.net/simplexml Example 7. Setting values Data in SimpleXML doesn't have to be constant. The object allows for manipulation of all of its elements. movie[0]->characters->character[0]->name = 'Miss Coder'; echo $xml->asXML(); ?> The above code will output a new XML document, just like the original, except that the new XML will change Ms. Coder to Miss Coder. Uros, it looks like you want to change one of the attributes; you will need to use some of this code to handle the attributes: Example 4. Using attributes So far, we have only covered the work of reading element names and their values. SimpleXML can also access element attributes. Access attributes of an element just as you would elements of an array. nodes of the first movie. * Output the rating scale, too. */ foreach ($xml->movie[0]->rating as $rating) { switch((string) $rating['type']) { // Get attributes as element indices case 'thumbs': echo $rating, ' thumbs up'; break; case 'stars': echo $rating, ' stars'; break; } } ?> regards, Jordan On Aug 24, 2005, at 3:20 AM, Uroš Gruber wrote: Hi! I have XML and I would like to set some values. I almost done the whole thing but have some problems when looping through some tags ... I would like to set value for tag "bar" in some loop and then export this back to XML. Is this even possible or it's better to use SimpleXML only for read and create new XML from it. XML is about 20 rows of data and I'm using PHP 5.0.4 with all XML included. regards Uros -- 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] syntax for two comparison operators
General question, Is there a technical reason why PHP does not allow comparison operator expressions like the following: if (2 < $x <= 4) {} I prefer this concise way as it is common for mathematics expressions, and much easier to grasp physically on first glance. From what I can tell, this expression can currently only be written as: if ( $x > 2 && $x <= 4) {} Would adding this syntax to PHP be incredibly difficult or lead to performance slowdowns? I think I remember reading that PHP always evaluates expressions from right to left, so I guess there may be a considerable codebase change required. Maybe there could be a default function workaround for this or some other way to automagically process these more concise expressions without too much of a slowdown?? Just curious. Jordan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax for two comparison operators
Good to know about expression evaluation. Writing the expression(s) like that (left-to-right and right-to-left) solves my dilemma... thanks! Jordan On Aug 25, 2005, at 2:44 AM, Richard Lynch wrote: I personally would use: ((2 < $x) && ($x <= 4)) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] invert
if you are using mysql, just put the "DESC" (descending) directive at the end of your sql statement (default is no "DESC" directive, meaning ascending). most recent records will be returned first. Jordan On Aug 25, 2005, at 2:21 PM, George B wrote: I have written a shoutbox, and it works great, but I am wondering... When a user posts a shout it goes below the first shout. Like the auto_increment puts the ID up higher. I need it to go about the first shout, so like the auto_increment would invert. Someone told me this is possible through PHP. Is that true? and if so how do you do it? -- 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] invert
you need to provide more information. we cannot tell what you are doing. you should: **PASTE THE RELEVANT SECTION OF YOUR CODE IN YOUR EMAIL** On Aug 25, 2005, at 2:38 PM, George B wrote: Łukasz 'nostra' Wojciechowski wrote: W odpowiedzi na maila (21:21 - 25 sierpnia 2005): I have written a shoutbox, and it works great, but I am wondering... When a user posts a shout it goes below the first shout. Like the auto_increment puts the ID up higher. I need it to go about the first shout, so like the auto_increment would invert. Someone told me this is possible through PHP. Is that true? and if so how do you do it? mysql_query('SELECT * FROM table ORDER BY increment_field DESC'); http://dev.mysql.com/doc/mysql/en/order-by-optimization.html or get all output from DB into array and use array_reverse(); http://us2.php.net/manual/pl/function.array-reverse.php If I do that... then i get this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in myfile name on line 30 and on line 30 it says while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { I dont understand what is problem here... -- 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] Browsing Into Levels
They are called breadcrumbs: http://www.google.com/search?q=php+breadcrumbs Jordan On Aug 30, 2005, at 4:57 AM, areguera wrote: Hi, I been wondering the best way to make the level browsing, I mean, those links up in page which tell you the position you are, and make you able to return sections back, keeping some kind of logic of where you are. I been used the url vars to do this but I arrive some point where there are coincidences and it loose sense, it jumps to other section, where indeed have to, but not where it logically should. any suggestions? thank :) -- 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] Browsing Into Levels
you may not need anything fancy like a class for regular breadcrumbs or these BreadcrumbsExtreme™ that you describe. i usually do simple breadcrumbs with a simple function. for the extreme version, just store an array of recently viewed pages in a session variable, and parse this array when displaying each page. Jordan On Aug 30, 2005, at 11:01 AM, Greg Schnippel wrote: Good answer, I think thats what they were looking for but just in case: Most of the breadcrumb classes out there (at least the ones that showed up in an initial google search) use either the existing directory/file structure or a hard-coded array of your site structure to create the breadcrumbs. What about on non-structured sites like Wikis? For example, on DokuWiki, it keeps track of your last 4-5 clicks in a "breadcrumb" trail on the top of the page. Amazon.com <http://Amazon.com>'s "recently viewed pages" is another good example (though probably patented ;)) What are these kind of breadcrumbs called and which classes would you recommend using to implement them? Thx, - Greg On 8/30/05, Jordan Miller <[EMAIL PROTECTED]> wrote: They are called breadcrumbs: http://www.google.com/search?q=php+breadcrumbs Jordan On Aug 30, 2005, at 4:57 AM, areguera wrote: Hi, I been wondering the best way to make the level browsing, I mean, those links up in page which tell you the position you are, and make you able to return sections back, keeping some kind of logic of where you are. I been used the url vars to do this but I arrive some point where there are coincidences and it loose sense, it jumps to other section, where indeed have to, but not where it logically should. any suggestions? thank :) -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] running process in the background
Oh wait... you are not specifying your $_POST variable. you need to use the key for $_POST. just do a print_r($_POST) to find the key from the $_POST array that you are looking for. also, i would not pass a $_POST variable directly to your shell without escaping it somehow, first... foreach ($_POST[$key] ... Jordan Did you try also sending stderr to /dev/null rather than stdout only? I think the syntax is to add a "2>&1": foreach ($_POST as $kid){ `php run.php param1 param2 > /dev/null 2>&1 &`; } This should put each process in the background and suppress all errors and output. Does that work? Jordan On Aug 31, 2005, at 11:44 AM, Georgi Ivanov wrote: foreach ($_POST as $kid){ `php run.php param1 param2 > /dev/null &`; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nested IFs Problem
why not rewrite it to be more concise... i can't see a problem at the moment. are you sure you can do a "<" comparison operator on the '12:00' and '2005-10-02' string?? Maybe if you are using 24 hr format you could just get rid of the ":" on both sides of the operator to have the "<" properly evaluated... do the same for the date comparison. just try each if statement individually. then, when you find the problem, rewrite like this: if ((putFirstExpressionHere) && (putSecondExpressionHere) && (putThirdExpressionHere)) { // success } else { // failure } Jordan On Aug 31, 2005, at 3:05 PM, Albert Padley wrote: if ($row['date'] < '2005-10-02') { if ($row['time'] < '12:00') { if ($row['field'] == 'P5' ) { echo "Success"; } } } else { echo "Failed"; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help: Get the value of pi up to 200+ digits?
http://us3.php.net/manual/en/ini.core.php#ini.precision precision sets the number of significant digits, *NOT* the number of digits displayed after the decimal point. If you want to get pi out to 16 decimal places you need a precision of *17* because the beginning 3 is a significant digit. Your code does exactly this, displaying pi with 15 decimal places. Jordan On Sep 1, 2005, at 8:06 AM, Wong HoWang wrote: Dear all, I'm trying to do like this but failed: How can I get more digits after . ? Can anyone help? Thx! -- 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] how to divide string
If you are using php 5, don't forget about str_split, with 4 as the second parameter. http://us2.php.net/str_split so you could do: echo implode("", str_split($string, 4)); if you still have php 4 or earlier, look at that page anyway as there is a workaround function in the comments for earlier versions of php. Jordan On Sep 5, 2005, at 6:50 AM, Adi Zebic wrote: Hi, is there any magic function who can give me from: $string = " abcdefghijklmnopqrstuwvxyz"; somthing like this: abcd efgh ijkl mnop qrst uwvx yz (each 'x' letters go to the next line) Thanks a lot, ADI -- 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] Sessions , expiry times and different time zones
Hi Dan, Couldn't you store an expiration time directly in the $_SESSION variable, rather than relying on cookie expiration (if I understand your question correctly)? Each time a page is loaded, update the expiration time in this variable to +24hr from the current time (all times relative to the server's time). Then, it shouldn't matter from which time zone the user is browsing. Jordan On Sep 6, 2005, at 10:37 AM, Dan Rossi wrote: hi there I have run into problems with sessions , cookies and expiryt times with different time zones. Ie our server is in the States however I am browsing from Koala land downunder. I have been trying to get the session to expire in a day, however for ppl in the states this is ok, but for me its already expired so i have been experiencing issues. How do i solve this ? -- 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] Assign values in foreach-loop
Hello, You simply need the $key variable, then you can set a new value for $arr[$key] for each array element: $value) { $arr[$key] = $value * 2; } // $arr is now array(2, 4, 6, 8) ?> http://www.php.net/foreach If you have PHP 5, you can perhaps more efficiently do this: As of PHP 5, you can easily modify array's elements by preceding $value with &. This will assign reference instead of copying the value. Jordan On Sep 7, 2005, at 12:14 PM, Sabine wrote: Hello to all, is it possible to assign values to the array for which I do the foreach-loop? foreach ($_SESSION['arr1'] as $arr1) { foreach ($_SESSION['arr2'] as $arr2) { if ($arr1['id'] == $arr2['id']) { $arr1['selected'] = true; } } } I think $arr1 is only a temp-var, so the assignment won't reflect on $_SESSION['arr1'] . Is that right? Surely I can do it with a for-loop, but those arrays are a bit complex and a foreach would be much easier to read. Thanks in advance for your answers Sabine -- 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] Assign values in foreach-loop
sorry, i didn't fully answer the questions... if i understand your multidimensional array correctly, your code should be something like: foreach ($_SESSION['arr1'] as $key => $arr1) { foreach ($_SESSION['arr2'] as $arr2) { if ($arr1['id'] == $arr2['id']) { $_SESSION['arr1'][$key]['selected'] = true; } } } Jordan On Sep 7, 2005, at 12:22 PM, Jordan Miller wrote: foreach ($_SESSION['arr1'] as $arr1) { foreach ($_SESSION['arr2'] as $arr2) { if ($arr1['id'] == $arr2['id']) { $arr1['selected'] = true; } } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Checking a date for validity
writing a parse script is okay, but it will be very difficult to always ensure they are inputting it correctly. I recommend putting a popup calendar next to the input field. If the field is automatically populated in this way you will have a much easier time parsing it correctly. I can't recommend a good one offhand, but there are several that are DHTML and JS only, so that should be a good starting point for standards compliance. See: http://www.dynarch.com/projects/calendar/ and http://www.google.com/search?q=dhtml+popup+calendar Jordan On Sep 7, 2005, at 5:39 PM, Todd Cary wrote: I need to check the input of a user to make sure the date is valid and correctly formatted. Are there any examples available? Here is one solution I created: /* Is date good */ function is_date_good($date) { if (strtotime($date) == -1) { $retval = 0; } else { if (strpos($date, "/") > 0) { $parts = explode("/", $date); } elseif (strpos($date, "-") > 0) { $parts2 = explode("-", $date); $parts[0] = $parts2[1]; $parts[1] = $parts2[2]; $parts[2] = $parts2[0]; } else { $parts = explode(".", $date); } //print_r($parts); if (checkdate($parts[0], $parts[1], $parts[2]) ) return 1; else return 0; } return $retval; } Is there a simplier solution? Many thanks.. -- 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] Sessions , expiry times and different time zones
As I said, "**rather** than relying on cookie expiration". This *necessarily* means that you will need to set the cookie expiration to sometime way in the future, like next year (or more dynamically, use the date() and mktime() functions to always set the cookie expiration to + 1 yr from "today"). If you do this, you will have no chance of the cookie itself expiring; therefore you can rely solely on the $_SESSION variable. The cookie will contain the session id that the webserver will be able to use to repopulate the $_SESSION variable as long as $_SESSION['expiration'] is still in the future. If $_SESSION['expiration'] is in the past (or is empty) and you issue a session_destroy() and a setcookie(), the cookie can be destroyed, too. I have written something similar to this in the past, and it behaves exactly as you would like and expect. Another benefit is that this is more secure than relying on a cookie-supplied expiration time. Jordan On Sep 6, 2005, at 8:51 PM, Dan Rossi wrote: client cookie expires hence no more session ... On 07/09/2005, at 1:57 AM, Jordan Miller wrote: Hi Dan, Couldn't you store an expiration time directly in the $_SESSION variable, rather than relying on cookie expiration (if I understand your question correctly)? Each time a page is loaded, update the expiration time in this variable to +24hr from the current time (all times relative to the server's time). Then, it shouldn't matter from which time zone the user is browsing. Jordan On Sep 6, 2005, at 10:37 AM, Dan Rossi wrote: hi there I have run into problems with sessions , cookies and expiryt times with different time zones. Ie our server is in the States however I am browsing from Koala land downunder. I have been trying to get the session to expire in a day, however for ppl in the states this is ok, but for me its already expired so i have been experiencing issues. How do i solve this ? -- 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] Better timestamp explanation to the client
methinks you should convert the datetime to a unix timestamp with strtotime(). then you can compare the difference between this timestamp and a unix timestamp of "now" to find if you have logged in within a min. of the previous time. Then, once you know what text to display (e.g. "Less than a minute ago!"), you can format the original datetime timestamp with the date() function to be however you like. You may have to read the manuals for all three of these functions several times. good luck! actually, you may be able to do simple operators (e.g. <, >, or -) with the datetime as is, without having to convert to a unix timestamp. "NOW" in datetime format can be gotten with: $now = date('Y-m-d H:i:s'); i'm not sure though. just try it! Jordan On Sep 8, 2005, at 9:41 AM, Ryan A wrote: Hi, In one of our tables we have these fields: cust_no bigint(20), cust_name varchar(30), last_online datetime, and in that members profile, if someone visits it, on the top of the page we have this: // connect to db, query for record and display it below Last seen: Any ideas on the simplest way to make it look like this: Last seen: Less than a minute ago! Last seen: 25 mins ago Last seen: 2 hours 11 mins ago Last seen: 1 (or 2 or 3) day/s ago else{ echo $last_seen; } I have seen this done on a few sites (Swedish sites actually, I can give you the URLs if you need them) I think it looks much better than: Last seen : 2005-09-07 20:59:01 Thanks! Ryan -- 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] Convert a timestamp to RFC822??
we *just* had a post similar to this. It's easy, just use the date() and strtotime() functions: $timestamp = '2004-05-14 13:24:48'; $RFC_formatted = date('r', strtotime($timestamp)); done! Jordan On Sep 10, 2005, at 11:14 AM, Brian Dunning wrote: I get my timestamp from the db in this format (I don't have control over this): 2004-05-14 13:24:48 I need to convert it to RFC822 to make it a valid RSS pubDate field like this: Wed, 02 Oct 2002 13:00:00 GMT How can I do that? I'm tearing my hair out here (what's left)... :) -- 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] Books / tutorials on Object Oriented Programming with PHP
Here is a thorough review on the Zandstra book: http://books.slashdot.org/article.pl?sid=05/08/16/0434205&tid=169&tid=6 Jordan On Sep 9, 2005, at 6:39 PM, Jason Coffin wrote: On 9/9/05, Vinayakam Murugan <[EMAIL PROTECTED]> wrote: I am learning about Object Oriented Programming with PHP. Can you suggest any good books / tutorials? Greetings, I HIGHLY recommend "PHP 5 Objects, Patterns, and Practice" by Matt Zandstra [http://www.apress.com/book/bookDisplay.html?bID=358]. This was one of the best PHP books I have read and I suspect it is exactly what you are looking for. Yours, Jason Coffin -- 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] Round with ONE-decimal... always...
besides sprintf, number_format will also do it: number_format(6, 1, ',', '');// Outputs '6,0' Jordan On Sep 12, 2005, at 3:52 AM, Gustav Wiberg wrote: Hi there! I want to adjust the round() -function a little... If I put round(6,0) there will be an output of 6 If I put round(6,32) there will be an output of 6,3 I want it to have 6,0 instead of just 6... I guess there is an easy solution to this? Suggestions? /G http://www.varupiraten.se/ -- 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] Deny access from certain hosts
you need to do it like this: Order Allow,Deny Allow from all Deny from 85.65.154 http://httpd.apache.org/docs/1.3/mod/mod_access.html Jordan On Sep 13, 2005, at 2:30 PM, David Pollack wrote: Hello, I have a problem where someone is illegally linking to my site. There site is in another language so I'm having trouble contacting them. Is there any way that I can use PHP or Apache to stop them from linking to these files directly on there website. This is an example of a log entry that I get from their link: 85.65.154.185 - - [04/Sep/2005:06:52:40 -0700] "GET /fonts/images/austrise.jpg HTTP/1.1" 200 6094 "http://www.tipo.co.il/zone/page.asp?zone=41611880647891&pid=1044663"; "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)" I've tried using mod_access with a simple directive in my like: Deny from 85.65.154 And that does not seem to work. I have mod_access installed and PHP 4. I'm sorry if this is more of an apache question but it just seems like it should be so easy and I can't find a single example of how to stop this. -- David Pollack [EMAIL PROTECTED] www.atlspecials.com www.da3.net -- 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] array simple question
please provide code and an example output, and say how this is different than you would like. what you describe is unclear. Jordan On Sep 13, 2005, at 4:04 PM, matt VanDeWalle wrote: hello, I have a simple question, not really a problem this time. I know that the function print_r() will print an array but if that array has sub-arrays it prints everything and if you don't use more command or a pipe of some kind that could be useless in some cases, but I am just wondering, for an array that has several arrays in it, is there a way to print the array names that are contained in the "main array" but not the contents of each? thanks matt -- 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] whats wrong in this program.
I think I finally understand what you are trying to do. I don't see any reason why you need to use the token functions, and I would recommend using array functions instead (also, it is exceedingly easy to sort the elements of an array... see the end). I believe this will do what you are trying to do: //Tokenizer for Babu $str = '10,12,14-18'; $commas = explode(',', $str); // $commas will be an array of three items in this case // Final Values will go into the $final array $final = array(); foreach ($commas as $value) { // If one of the $commas elements contains a dash, we need to get the range between them! if (strstr($value, '-')) { // Explode based on the dash. This code assumes there will only be a single dash $rangeValues = explode('-', $value); foreach (range($rangeValues[0], $rangeValues[1]) as $number) { $final[] = $number; } } else { // If $value does not contain a dash, add it directly to the $final array $final[] = $value; } } echo "All your values in the range $str are ".implode(' ', $final); // Prints "All your values in the range 10,12,14-18 are 10 12 14 15 16 17 18" In your last email, you had some of the values given out of order: 1. 20,21-24 2. 21-24,20 3. 10,20,21-24,25,26,30 To make sure the $final values are always ascending, just do this at the end: sort($final); Done!! Jordan On Sep 13, 2005, at 7:16 PM, babu wrote: $str=10,12,14-18; $tok = strtok($str, ','); while ($tok !== false) { $toks[] = $tok; $tok = strtok(','); } foreach ($toks as $token){ if (strpos($token,'-')){ stringtokenize($token); }else{ $finaltokens[]= $token; } } function stringtokenize($nstr){ $ntok1= strtok($nstr,'-'); $ntok2=strtok('-'); for($i=$ntok1;$i<=$ntok2;$i++){ $finaltokens[]= $i; } } foreach ($finaltokens as $ftoken){ echo $ftoken; echo ""; } the ouput prints only 10,12 but not 14,15,16,17,18. where is the problem. - To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Deny access from certain hosts
if people are allowed to post copyrighted images to your bulletin board, shouldn't you have some sort of password protection anyway? negating that, i would do it with PHP and not Apache. rather than simply serving up the file raw: why not setup a php script to do URL referring blocking: in the getFile.php file, you could check the referring URL, and then present the file, or not. you would need to move the images out of the web tree, though, so people couldn't bypass your script. it sounds like you need to reconsider what you really want, though. Jordan On Sep 13, 2005, at 3:00 PM, Aaron Greenspan wrote: Jordan, I have a similar problem where someone is using copyrighted images on my site in a bulletin board. It's not that one specific host is requesting the files--it's people from all over--but rather that I want to block one referring URL using Apache, rather than PHP, since the images are GIF files. Can you do that with .htaccess? Thanks, Aaron Aaron Greenspan President & CEO Think Computer Corporation http://www.thinkcomputer.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
Re: [PHP] whats wrong in this program.
you need single quotes around $subnum in the sql statement. don't know why you seem to be arbitrarily leaving them off (put them around $uv and $duration, too!). also, you should never insert stuff directly from a user into a database. first escape every variable with: http://www.php.net/mysql_real_escape_string Jordan On Sep 14, 2005, at 6:36 AM, babu wrote: Hi, I tried to use the final array values in a insert statement, but the values are not inserted. the code is foreach ($final as $subnum){ $res = $db->query("INSERT INTO substrate_protocoll (substrate_type,substrate_num,operator,location,solvent,ultrasonic,dur ation,cdate,ctime,comment) VALUES('$substrate_type1', $subnum,'$operator','$location','$solvent',$uv, $duration,'$cdate','$sctime','$comment')"); if(!$res){ echo "insert failed"; } } the values of array ($subnum)are not inserted , can you tell me where the problem is. Jordan Miller <[EMAIL PROTECTED]> wrote: I think I finally understand what you are trying to do. I don't see any reason why you need to use the token functions, and I would recommend using array functions instead (also, it is exceedingly easy to sort the elements of an array... see the end). I believe this will do what you are trying to do: //Tokenizer for Babu $str = '10,12,14-18'; $commas = explode(',', $str); // $commas will be an array of three items in this case // Final Values will go into the $final array $final = array(); foreach ($commas as $value) { // If one of the $commas elements contains a dash, we need to get the range between them! if (strstr($value, '-')) { // Explode based on the dash. This code assumes there will only be a single dash $rangeValues = explode('-', $value); foreach (range($rangeValues[0], $rangeValues[1]) as $number) { $final[] = $number; } } else { // If $value does not contain a dash, add it directly to the $final array $final[] = $value; } } echo "All your values in the range $str are ".implode(' ', $final); // Prints "All your values in the range 10,12,14-18 are 10 12 14 15 16 17 18" In your last email, you had some of the values given out of order: 1. 20,21-24 2. 21-24,20 3. 10,20,21-24,25,26,30 To make sure the $final values are always ascending, just do this at the end: sort($final); Done!! Jordan On Sep 13, 2005, at 7:16 PM, babu wrote: $str=10,12,14-18; $tok = strtok($str, ','); while ($tok !== false) { $toks[] = $tok; $tok = strtok(','); } foreach ($toks as $token){ if (strpos($token,'-')){ stringtokenize($token); }else{ $finaltokens[]= $token; } } function stringtokenize($nstr){ $ntok1= strtok($nstr,'-'); $ntok2=strtok('-'); for($i=$ntok1;$i<=$ntok2;$i++){ $finaltokens[]= $i; } } foreach ($finaltokens as $ftoken){ echo $ftoken; echo " "; } the ouput prints only 10,12 but not 14,15,16,17,18. where is the problem. - To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whats wrong in this program.
heh, i did it too. John, oh, good to know, thanks. $final should be composed of strings, not integers, so i guess that is his problem. i just read that it is best to quote every variable, now I know why... so you can change implementations later and not have to worry about types (and php's autotyping is so great anyway). Jordan On Sep 14, 2005, at 10:54 AM, John Nichel wrote: Jordan Miller wrote: you need single quotes around $subnum in the sql statement. don't know why you seem to be arbitrarily leaving them off (put them around $uv and $duration, too!). It's not needed if those fields are integers. *damnit, that's twice today I've replied to the poster and not the list. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- 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] A tricky little addition
the syntax for variable variables is: $variable= $$add; or alternatively: $variable= ${$add}; Jordan On Sep 14, 2005, at 2:25 PM, Ross wrote: $variable= "$".$add; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Domain Info Possible?
do you have log files? the page you linked to was generated by webalizer. is there a reason you can't use that (or Awstats, or something similar)? you probably don't need to reinvent the wheel here... though you may need to tweak your webserver to put more information in the log files so you can see all the stats you desire. Jordan On Sep 15, 2005, at 11:07 AM, Chirantan Ghosh wrote: Hello, I was wondering if there was way to generate domain statistics by any PHP script? I just need some basic info like: Monthly Traffic( Sites, Kbytes, Visits, Pages, Files, Hits ) Example: http://server18.internetserver.com/stats/1800homecare/ If it is possible can I also create a Log In for that page? I would appreciate any direction. Thanks, C. Ghosh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] email validation regex
What do you mean? What's wrong with top posting? ;) Jordan On Sep 16, 2005, at 11:31 AM, John Nichel wrote: bruce wrote: hi.. looking for a good/working/tested php email validation regex that conforms to the rfc2822 standard. a lot of what i've seen from google breaks, or doesn't follow the standard! any ideas/thoughts/sample code/etc... Didn't we just have this flame war about a month ago? Is it time for it to come up again? Top posting must be right around the corner; damn, I love this time of year. ;) -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- 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] Way for script to discover it's path?
Hey Ken, The variable you want is already a superglobal known as $_SERVER ['SCRIPT_FILENAME']. See: http://www.php.net/reserved.variables Do something like this to get started: echo $_SERVER['SCRIPT_FILENAME']; Good luck. Jordan On Sep 18, 2005, at 4:58 PM, Ken Tozier wrote: I'm working on an auto-include mechanism for some complex scripts and rather than have all the paths to the various components hard coded, I'd like to have the script walk up the hierarchy looking for it's specified includes. Is it possible to do this? I looked at the various file related php functions but didn't see anything resembling 'my_path()' Thanks Ken -- 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] Can I install versions of PHP/MySQL that will be compatible with my host server?
On Sep 19, 2005, at 8:31 AM, Jochem Maas wrote: e.g: $var = array_pop( explode('-', '1-2-3-4-5') ); .. is bad code (read the manual page for array_pop very carefully) and would work in older versions but the engine has been tightened up to disallow such fauxpas. Jochem, Whoa... what do you mean by this, exactly? I am running PHP 5.0.4 and $var is correctly set with the code you give above. I could not find anything like you describe in the array_pop manual (see below). Please elaborate on why this is "bad" code. Jordan array_pop (PHP 4, PHP 5) array_pop -- Pop the element off the end of array Description mixed array_pop ( array &array ) array_pop() pops and returns the last value of the array, shortening the array by one element. If array is empty (or is not an array), NULL will be returned. Note: This function will reset() the array pointer after use. Example 1. array_pop() example After this, $stack will have only 3 elements: Array ( [0] => orange [1] => banana [2] => apple ) and raspberry will be assigned to $fruit. See also array_push(), array_shift(), and array_unshift(). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can I install versions of PHP/MySQL that will be compatible with my host server?
That is very interesting, thank you. We cannot escape politics, eh? Jordan On Sep 19, 2005, at 9:32 AM, Jochem Maas wrote: Jordan Miller wrote: On Sep 19, 2005, at 8:31 AM, Jochem Maas wrote: e.g: $var = array_pop( explode('-', '1-2-3-4-5') ); .. is bad code (read the manual page for array_pop very carefully) and would work in older versions but the engine has been tightened up to disallow such fauxpas. Jochem, Whoa... what do you mean by this, exactly? I am running PHP 5.0.4 and what I meant an what I wrote apparently don't match up very well :-) I meant to give a valid example of when you can't pass the return value from a function to another function due to the fact that a reference is expected and in some situation the var you are passing is a reference to 'nothing' - which works in older version of php but is also the cause of a couple of weird/nasty & inexplicable potential seg faults ... it was fixed, Derick opened his mouth, alot of people got angry - personally I don't give a shit because I only use 5.0.x (I'll be waiting until the shitstorm has died down before trying out 5.0.5 or 5.1 :-) maybe this helps to explain (alot) better what I was talking about ... http://phplens.com/phpeverywhere/?q=node/view/214 anyway thanks for the catch Jordan. $var is correctly set with the code you give above. I could not find anything like you describe in the array_pop manual (see below). Please elaborate on why this is "bad" code. Jordan array_pop (PHP 4, PHP 5) array_pop -- Pop the element off the end of array Description mixed array_pop ( array &array ) array_pop() pops and returns the last value of the array, shortening the array by one element. If array is empty (or is not an array), NULL will be returned. Note: This function will reset() the array pointer after use. Example 1. array_pop() example After this, $stack will have only 3 elements: Array ( [0] => orange [1] => banana [2] => apple ) and raspberry will be assigned to $fruit. See also array_push(), array_shift(), and array_unshift(). -- 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] Easy question - delete strings from the beginning of space...
to get rid of potential double spaces after the explode, you could do: foreach ($words as $word) { if (!empty($word)) { $first = $word; break; } } echo $first; This will always return the first word. Jordan On Sep 20, 2005, at 7:24 AM, Jochem Maas wrote: how much easier do you want it? oh and guessing kinda sucks. $str = "Hello World"; $words = explode(" ", $str); echo $words[0]; ... but what if you have double spaces, or a space at the beginning? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] why does this not work?
javascript is a client-side language, while php is a server-side language... the value you are passing to $width only exists on the client side, therefore the php server-side boolean fails. i think you will have to pass the client-side calculated variable of screen.width to the php server before you can do this properly, probably through a POST form or GET request. nice idea, though (dynamically loading css based on screen resolution). see: http://forums.devshed.com/t3846/s.html Jordan On Sep 27, 2005, at 3:20 AM, Ross wrote: This returns the correct value for $width but falls down on the boolean. I have tried intval/srtval but nothing seems to work. Maybe it is too early! $width = " document.write(screen.width); "; //$ross= intval($width); echo $width; if ($width < 1064) { echo "lower"; $style= "style1.css"; } else { $style= "style2.css"; } R. -- 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] Funky array question
Hello, what have you been trying for comparison so far that has not been working? if you have php 5, you would want to use stripos, which is case- INsensitive, not strpos, which is the opposite. Also, note the warning on the man page. you would want to use a triple equals sign "!===false" because stripos could return a zero or an empty string which is actually "==false". http://www.php.net/stripos/ if you do not have php 5, i would use regex so you can get case insensitivity. Jordan On Oct 16, 2005, at 11:18 PM, Minuk Choi wrote: Assuming that you are also accepting partial matches... (e.g. if you had a sentence with something like, "Mr. LeBlue says hello", and that should be a match for "blue") If $mysqlString contains 1 sentence from the mySQL database(I assume you've a loop or something that'll fetch 1 string per iteration) $resultStr = $mysqlString; $bFound=false; foreach ($myArray as $colorArray) { $firstTerm = $colorArray[0]; $secondTerm = $colorArray[1]; if (strpos($resultStr, $firstTerm)!==false) { $resultStr = $secondTerm; $bFound=true; } if ($bFound) break; } $mysqlString = $resultStr; Try that. Brian Dunning wrote: I want to create an array like this: $myArray=array( array('orange','A very bright color'), array('blue','A nice color like the ocean'), array('yellow','Very bright like the sun') ...etc... ) Sort of like a small database in memory. Then I want to compare each of the rows coming out of a MySQL call, which are sentences, against this array to see if the FIRST TERM in each array element is present in the sentence, and then display the SECOND TERM from the array for each sentence. Make sense? So for these two sentences, and the above array, here's how I want it to output: "He used blue paint" - A nice color like the ocean. "The flower was yellow" - Very bright like the sun. Can someone help me out with the code needed to search the sentence to which FIRST TERM appears in it, and retrieve the SECOND TERM? I've tried too many things and now my brain is tied in a knot. -- 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] Funky array question
sorry, I am mistaken here. I forgot that "!==" is the same functionality as a "===", in that the comparison is made by value *and* type. On Oct 16, 2005, at 11:26 PM, Jordan Miller wrote: Also, note the warning on the man page. you would want to use a triple equals sign "!===false" because stripos could return a zero or an empty string which is actually "==false". -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Funky array question
one more thing... if you have php <5 and >= 3.0.6, you could use stristr for case insensitive comparison without having to deal with the slower and more cumbersome regex. On Oct 16, 2005, at 11:18 PM, Minuk Choi wrote: Assuming that you are also accepting partial matches... (e.g. if you had a sentence with something like, "Mr. LeBlue says hello", and that should be a match for "blue") If $mysqlString contains 1 sentence from the mySQL database(I assume you've a loop or something that'll fetch 1 string per iteration) $resultStr = $mysqlString; $bFound=false; foreach ($myArray as $colorArray) { $firstTerm = $colorArray[0]; $secondTerm = $colorArray[1]; if (strpos($resultStr, $firstTerm)!==false) { $resultStr = $secondTerm; $bFound=true; } if ($bFound) break; } $mysqlString = $resultStr; Try that. Brian Dunning wrote: I want to create an array like this: $myArray=array( array('orange','A very bright color'), array('blue','A nice color like the ocean'), array('yellow','Very bright like the sun') ...etc... ) Sort of like a small database in memory. Then I want to compare each of the rows coming out of a MySQL call, which are sentences, against this array to see if the FIRST TERM in each array element is present in the sentence, and then display the SECOND TERM from the array for each sentence. Make sense? So for these two sentences, and the above array, here's how I want it to output: "He used blue paint" - A nice color like the ocean. "The flower was yellow" - Very bright like the sun. Can someone help me out with the code needed to search the sentence to which FIRST TERM appears in it, and retrieve the SECOND TERM? I've tried too many things and now my brain is tied in a knot. -- 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] RE: php-general Digest 17 Oct 2005 10:35:46 -0000 Issue 3742
if you have compiled php with pdflib support, you can do this fairly easily. see the manual: http://www.php.net/pdf Jordan On Oct 17, 2005, at 6:06 AM, Aftab Alam wrote: hi, any one can help me i want to generate Pdf file using php. how can i & what tools is required for this. Regards, _ Aftab Alam -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, October 17, 2005 4:06 PM To: php-general@lists.php.net Subject: php-general Digest 17 Oct 2005 10:35:46 - Issue 3742 php-general Digest 17 Oct 2005 10:35:46 - Issue 3742 Topics (messages 224207 through 224218): Funky array question 224207 by: Brian Dunning 224209 by: Minuk Choi 224210 by: Jordan Miller 224211 by: Jordan Miller 224212 by: Jordan Miller Re: editor 224208 by: yangshiqi1089 a couple of problems with PHP form 224213 by: Bruce Gilbert 224218 by: Mark Rees Re: OPTIMIZING - The fastest way to open and show a file 224214 by: Ruben Rubio Rey 224215 by: Ruben Rubio Rey 224216 by: ac can't get IIS to run php if the script is not directly under wwwroot 224217 by: tony yau Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: php-general@lists.php.net -- -- 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] Recommended Reading?
Zandstra's "PHP 5 objects patterns practice" has been getting excellent reviews. i also recommend it. http://www.amazon.com/gp/product/1590593804/ On Oct 18, 2005, at 1:43 PM, Alan Lord wrote: Hi all, Forgive this long diatribe, a bit off-topic I know, but it might stimulate a good discussion... I have built a few small apps in PHP before and, whilst they work, I can't but help feeling that I go about the whole thing the WRONG way... I am not a professional software person (far from it) but I am reasonably competent in most things "technical". I trained in Electronics, build my own PCs and Linux systems from scratch, have used - just for fun - Java, Delphi, Visual Basic, PHP and a little C/C++. I am now wanting to write my own application (using PHP of course) to do something "really useful". And I am looking for some recommendations on reading [books or links] about "how to design" my application and how to think about the design in it's abstract form before I start writing code. Normally I end up writing little bits of code to solve small problems and then sort of kludging them together to do something useful. I would really like to try and go about this one the RIGHT way. Thanks in advance. Al -- 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] Trapping for an uploaded file that's too large?
On Oct 20, 2005, at 6:29 PM, Brian Dunning wrote: In my File Upload form, if the file is >=2MB, the user just gets a blank "error opening file" screen, almost immediately after the upload starts. I don't know how to trap for this to give a more user-friendly experience. Can anyone point me in the right direction? are you using PHP 5? If so, maybe check out this, below. Jordan From: [EMAIL PROTECTED] Subject: Re: [PHP] Re: PHP 5 limits "readfile" to 1.9 MB? Date: August 17, 2005 10:26:40 AM CDT To: [EMAIL PROTECTED] Cc: php-general@lists.php.net In-Reply-To: <[EMAIL PROTECTED]> Ok, just checking (I am new to the fopen() function). That makes sense. Awesome, thanks! Jordan On Aug 17, 2005, at 10:19 AM, Catalin Trifu wrote: Hi, Indeed a fclose($fp) is needed (wrote it as an example :)). 1MB is more than enough as a buffer. If you have a 53MB file, what will happen then ? I have no idea if it's a bug or a feature. Either way I did lose some hair over this when I switched from PHP4 to PHP5. Catalin Jordan Miller wrote: Catalin, Wow, that worked great, thanks. I'm curious why you set a static buffer of 1024768... why not just do filesize($file), as shown at http://www.php.net/fread ? Is it better for memory usage to have a potentially smaller buffer? Also, you may want an fclose($fp) after the file has been downloaded. So is this a bug in PHP 5 or are they just purposely limiting the abilities of the "readfile" command? Jordan On Aug 17, 2005, at 3:36 AM, Catalin Trifu wrote: Hi, I've had a similar problem. The download always stopped at exactly 2.000.000 bytes. You have to work around that with: $fp = fopen($file, 'r'); if($fp) { while(!feof($fp)) { echo fread($fp, 1024768);//see the huge buffer to read into } } else { //whatever error handler } Catalin Jordan Miller wrote: Hello all, I am new to this list and I have searched the archives to no avail. I am having a peculiar problem when upgrading to PHP 5: My downloads are now limited to the first 1.9 MB of the file in question, with the download either terminating at 1.9 MB or seemingly continuously stuck in a downloading process at 1.9 MB. The code in the PHP script has not changed and all parameters that I could find that are relevant to this problem are given below: the minimal code needed for download: // $file_to_read is the complete path of the file to download header("Content-Type: application/pdf"); header( "Content-Disposition: inline; filename= \"$filename \""); $len = filesize($file_to_read); header("Content-Length: $len"); @readfile($file_to_read); php.ini file for both php version 4 and 5 contain the following settings that may be relevant: allow_url_fopen = On max_execution_time = 300 ; Maximum execution time of each script, in seconds max_input_time = 300; Maximum amount of time each script may spend parsing request data memory_limit = 8M ; Maximum amount of memory a script may consume (8MB) post_max_size = 200M upload_max_filesize = 200M Some additional details: All files less than 1.9 MB download fine It is not a corrupted file, because all files larger than 1.9 MB fail after 1.9 MB The connection is not timing out (download of 1.9 MB takes only ~15 sec) Mac OS X 10.3.9 with Marc Liyanage's PHP 5.0.4 Fails for both Safari and Firefox Fails regardless of "inline" or "attachment" Fails regardless of "pdf" or "ppt" content-type This PHP code ALWAYS works for Marc Liyanage's PHP 4.3.4 with the same settings, above What am I doing wrong??? Any other parameter in php.ini I should have set? Any suggestions are much appreciated. thanks, Jordan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Declaring vars as INT ?
Hello, you could treat your variable as a string, and use the is_numeric() function (but this will include floats, too). To answer your question precisely and accurately, you may have to do regex matching since you are out of the bounds of int. However, why, *exactly*, are you trying to confirm that your string is an integer? It seems to me kind of cumbersome and unnecessary. If you provide more explicit information on what you are trying to do, your overarching goal for the script, including what are your inputs and intended outputs, along with some real code, we can probably find a solution that will do what you want without mucking about like this. Just my two cents. Jordan On Oct 21, 2005, at 2:39 PM, Chris Knipe wrote: Hi, Uhm... Let's take the below quickly: Function DoSomething($Blah) { $Blah = (int) $Blah; return $Blah } $Blah, cannot be larger than 2147483647, and sometimes, I get negative integers back from the above function. This is with PHP 4.4.0 on FreeBSD 5.4-STABLE. Can anyone else perhaps confirm this, and if it is indeed true, is this a bug, or a limitation somewhere on PHP? Any other ways to confirm that *large* numbers, are indeed integers? I'm working with numbers in the form of mmddsss (20051025001 for today for example) Thanks, Chris. -- 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] Declaring vars as INT ?
Also, look at this function: http://www.php.net/ctype_digit Jordan On Oct 21, 2005, at 2:39 PM, Chris Knipe wrote: Hi, Uhm... Let's take the below quickly: Function DoSomething($Blah) { $Blah = (int) $Blah; return $Blah } $Blah, cannot be larger than 2147483647, and sometimes, I get negative integers back from the above function. This is with PHP 4.4.0 on FreeBSD 5.4-STABLE. Can anyone else perhaps confirm this, and if it is indeed true, is this a bug, or a limitation somewhere on PHP? Any other ways to confirm that *large* numbers, are indeed integers? I'm working with numbers in the form of mmddsss (20051025001 for today for example) Thanks, Chris. -- 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] Ugh, w32 anything is making me want to drink!
I agree with John. It looks like you either need a hammer or the rooftop of a 5-story building... Jordan On Oct 21, 2005, at 3:26 PM, Jay Blanchard wrote: [snip] I just noticed that extension_dir in phpinfo is c:\php4 THAT AIN'T RIGHT! Why is PHP not loading the proper ini file? This is probably the source of my problems all along! ACK! This is what happens when you go over to the dark side. [/snip] It's not my fault! How do I fix this? -- 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] Why this doesn't work ?
why don't you just echo your $query to see if it is coming out correctly, before even trying to mess with mysql_query()? I think you should be able to see the problem from there. Jordan On Oct 24, 2005, at 12:44 PM, Mário Gamito wrote: Hi, Make this line instead $result = mysql_query($query) or die(mysql_error() . " with the query $query"; and you'll likely see the error. Here it goes: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(login) FROM formacao WHERE login = 'a'' at line 1" Regards, Mário Gamito -- 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