Re: [PHP] Spaces in filename or path
On 30 April 2011 22:07, Tim Streater t...@clothears.org.uk wrote: Does it matter to PHP filesystem functions if a path/to/file/name contains spaces? IOW, is this handled OK by design or should I replaces such spaces by backslash-space or would doing that present problems? Thanks -- tim On Windows, PHP will happily access files and directories with spaces... ?php file_put_contents('My name is Richard.txt', 'Hello Richard'); ? If you intend to pass the filename to a command line tool, then the filename must be wrapped with double quotes ... ?php exec('tool.exe My name is Richard.txt'); ? If you intend to pass the filename to a command line tool and the tool has spaces in the name too, then you need to wrap both with quotes ... ?php exec('C:\Program Files\tool.exe My name is Richard.txt'); ? If you are using a version of PHP before V5.3.0, please read http://uk.php.net/manual/en/function.exec.php#101579. Your code would need to be ... ?php exec('C:\Program Files\tool.exe My name is Richard.txt'); ? I've added some _ to that so you can easily see the single and double quotes ... (they aren't part of the real code, just there to show you the quotes) ... ?php exec(_'___C:\Program Files\tool.exe__ __My name is Richard.txt___'_); ? -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Spaces in filename or path
On 30 Apr 2011 at 22:33, Richard Quadling rquadl...@gmail.com wrote: On 30 April 2011 22:07, Tim Streater t...@clothears.org.uk wrote: Does it matter to PHP filesystem functions if a path/to/file/name contains spaces? IOW, is this handled OK by design or should I replaces such spaces by backslash-space or would doing that present problems? Thanks -- tim On Windows, PHP will happily access files and directories with spaces... Richard, I'll be doing this under OS X. I will be passing such paths/names to shell scripts too, but AIUI I can use escapeshellarg () there. As long as PHP filesystem functions don't have a problem then I should be OK. Cheers -- tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Spaces in filename or path
Tim Streater t...@clothears.org.uk wrote: On 30 Apr 2011 at 22:33, Richard Quadling rquadl...@gmail.com wrote: On 30 April 2011 22:07, Tim Streater t...@clothears.org.uk wrote: Does it matter to PHP filesystem functions if a path/to/file/name contains spaces? IOW, is this handled OK by design or should I replaces such spaces by backslash-space or would doing that present problems? Thanks -- tim On Windows, PHP will happily access files and directories with spaces... Richard, I'll be doing this under OS X. I will be passing such paths/names to shell scripts too, but AIUI I can use escapeshellarg () there. As long as PHP filesystem functions don't have a problem then I should be OK. Cheers -- tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php MacOS treats spaces the same as Linux. Like Richard said, you can use quotes if you're passing things to the shell, and also a backslash will work too. The only thing I would avoid if possible is spaces in paths that would reach the client side, i.e. in image paths, css files, etc, as I've heard historic browsers have trouble sometimes escaping the spaces automatically. Thanks Ash -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] spaces - not sure if this is a preg_match issue or a regexp issue
what about just writing a utility to manipulate the files names to remove spaces? -- Bastien Cat, the other other white meat Because it's not a separate file. The attachment is encoded as plain text into the nntp message. -- DeadTOm http://www.mtlaners.org [EMAIL PROTECTED] A Linux user since 1999. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] spaces - not sure if this is a preg_match issue or a regexp issue
Hi, I'm working on a script to look for a UUEncoded attachment in an NNTP message. I'm running into problems with spaces in the filename of the attachment. UUEncoded files in the body of a message will start with the word begin, then the size of the file, then the name of the file. Then the encoded file, finaly then a newline with only the word end like so: begin 644 photo.jpg -encoded image- end The script looks for that first line in that order so as not to confuse it with the word begin showing up somewhere else in the message. Here is the particular line of code that searches for that: if (preg_match(/^begin\s+[0-9][0-9][0-9]\s+(.+?)\s*\r?\n/m, $body)) The part where you fetch the file name (.+?)\s* is what is causing the problem as when the file name is a something.jpg then (.+?) matches a then \s matches the space and the rest is skipped. The problem I'm running into is with spaces in the file name. For example, if it starts with this: begin 644 a_nice_photo.jpg it works just fine, decodes the image and places it below the text of the message. But if the line looks like this: begin 644 a nice photo.jpg with spaces in the filename, the script seems to stop looking after the a, thinks this is just normal text in the message and doesn't decode the image. This results in the raw UUEncoded text showing up where the image should. I'm stumped. Any ideas? -Allen -- DeadTOm http://www.mtlaners.org [EMAIL PROTECTED] A Linux user since 1999. Runar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] spaces - not sure if this is a preg_match issue or a regexp issue
On 6/7/08, Runar Olsen [EMAIL PROTECTED] wrote: Hi, I'm working on a script to look for a UUEncoded attachment in an NNTP message. I'm running into problems with spaces in the filename of the attachment. UUEncoded files in the body of a message will start with the word begin, then the size of the file, then the name of the file. Then the encoded file, finaly then a newline with only the word end like so: begin 644 photo.jpg -encoded image- end The script looks for that first line in that order so as not to confuse it with the word begin showing up somewhere else in the message. Here is the particular line of code that searches for that: if (preg_match(/^begin\s+[0-9][0-9][0-9]\s+(.+?)\s*\r?\n/m, $body)) The part where you fetch the file name (.+?)\s* is what is causing the problem as when the file name is a something.jpg then (.+?) matches a then \s matches the space and the rest is skipped. The problem I'm running into is with spaces in the file name. For example, if it starts with this: begin 644 a_nice_photo.jpg it works just fine, decodes the image and places it below the text of the message. But if the line looks like this: begin 644 a nice photo.jpg with spaces in the filename, the script seems to stop looking after the a, thinks this is just normal text in the message and doesn't decode the image. This results in the raw UUEncoded text showing up where the image should. I'm stumped. Any ideas? -Allen -- what about just writing a utility to manipulate the files names to remove spaces? -- Bastien Cat, the other other white meat
Re: [PHP] spaces - not sure if this is a preg_match issue or a regexp issue
DeadTOm wrote: I'm working on a script to look for a UUEncoded attachment in an NNTP message. I'm running into problems with spaces in the filename of the attachment. UUEncoded files in the body of a message will start with the word begin, then the size of the file, then the name of the file. Then the encoded file, finaly then a newline with only the word end like so: begin 644 photo.jpg -encoded image- end The script looks for that first line in that order so as not to confuse it with the word begin showing up somewhere else in the message. Here is the particular line of code that searches for that: if (preg_match(/^begin\s+[0-9][0-9][0-9]\s+(.+?)\s*\r?\n/m, $body)) The following seems to work for me. ?php $body = begin 644 photo.jpg -encoded image- end ; if ( preg_match(/begin\s+[0-9]+\s+.+/, $body, $matches) ) { echo found my pattern; print_r($matches); } ? Is this inside a loop that you are scanning each line of the message? If not, I am guessing that it was your '^' that told the regex to match from the beginning of the string. The problem I'm running into is with spaces in the file name. For example, if it starts with this: begin 644 a_nice_photo.jpg it works just fine, decodes the image and places it below the text of the message. But if the line looks like this: begin 644 a nice photo.jpg with spaces in the filename, the script seems to stop looking after the a, thinks this is just normal text in the message and doesn't decode the image. This results in the raw UUEncoded text showing up where the image should. I'm stumped. Any ideas? -Allen -- DeadTOm http://www.mtlaners.org [EMAIL PROTECTED] A Linux user since 1999. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] spaces in select
I have a select/option that gets populated with countries. The value of these option are also set to the country name. The problem i have is that some countries have spaces in them eg: United States of America. what doe your select loo like? something like this should work select name=country option value=United States of AmericaUnited States of America/option /select -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] spaces in select
I have a select/option that gets populated with countries. The value of these option are also set to the country name. The problem i have is that some countries have spaces in them eg: United States of America. When the form is posted and I echo the country variable out that has been posted. It only shows the first word IE: United. Is there a way to ensure that I can get all the words that the value is set to?IE: United States of America, when the form is posted? Make sure in your option value=blah blah lines that you're putting the quotes around the words, example, option value=United States of America. -Dan Joseph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] spaces in select
Another suggestion is to use country codes - generally accepted by most i.e. uk, us, ch, cn, za etc -Original Message- From: Matt M. [mailto:[EMAIL PROTECTED] Sent: 11 October 2004 15:42 To: Angelo Zanetti Cc: [EMAIL PROTECTED] Subject: Re: [PHP] spaces in select I have a select/option that gets populated with countries. The value of these option are also set to the country name. The problem i have is that some countries have spaces in them eg: United States of America. what doe your select loo like? something like this should work select name=country option value=United States of AmericaUnited States of America/option /select -- 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] spaces in select-SOLVED
ok thanks to those who responded: this is how i got it working: echo(option value=\ . $row['location'] . \ . trim($row['location']) . /option); Angelo Dan Joseph [EMAIL PROTECTED] 10/11/2004 4:43:56 PM I have a select/option that gets populated with countries. The value of these option are also set to the country name. The problem i have is that some countries have spaces in them eg: United States of America. When the form is posted and I echo the country variable out that has been posted. It only shows the first word IE: United. Is there a way to ensure that I can get all the words that the value is set to?IE: United States of America, when the form is posted? Make sure in your option value=blah blah lines that you're putting the quotes around the words, example, option value=United States of America. -Dan Joseph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Disclaimer This e-mail transmission contains confidential information, which is the property of the sender. The information in this e-mail or attachments thereto is intended for the attention and use only of the addressee. Should you have received this e-mail in error, please delete and destroy it and any attachments thereto immediately. Under no circumstances will the Cape Technikon or the sender of this e-mail be liable to any party for any direct, indirect, special or other consequential damages for any use of this e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] spaces in select
Angelo Zanetti wrote: Hi all, I have a select/option that gets populated with countries. The value of these option are also set to the country name. The problem i have is that some countries have spaces in them eg: United States of America. When the form is posted and I echo the country variable out that has been posted. It only shows the first word IE: United. Is there a way to ensure that I can get all the words that the value is set to?IE: United States of America, when the form is posted? Thanks in advance. Make sure your option has a value, ie... option value=United States of America /United States of American Instead of... option value /United States of America -- 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
Re: [PHP] Spaces collapsed in database
perhaps you are parsing out the spaces before inserting the vars in the database? - Original Message - From: Alberto Brea [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 28, 2003 7:58 AM Subject: [PHP] Spaces collapsed in database Hi, list I had certain information in a text file, which showed ok upon fopen() and parsing, but when I put it into a MySQL database, instead of echoing directly into the browser, the spaces in the strings collapsed, so that One Two Three became OneTwoThree in the database table. When I retrieve this the spaces remain collapsed. Can anybody tell me what I did wrong, or what can I do to prevent this from happening? Please find the code below Thank you, Alberto // QUERY 1: INSERT RECORDS INTO TABLE contacts // DEFINE VARIABLES FOR QUERY 1 $sex=$info[1]; $lang=$info[2]; $pretreat=$info[3]; $fname=$info[4]; $lname=$info[5]; $posttreat=$info[6]; $contabbr=$info[9]; $persweb=$info[10]; $idactiv=$info[11]; $unsubscribe=$info[14]; $ent=$info[7]; $city=$info[13]; $email=$info[8]; $random=$info[14]; // DEFINE QUERY 1 $sql1= INSERT INTO contacts SET sex='$sex', lang='$lang', pretreat='$pretreat', fname='$fname', lname='$lname', posttreat='$posttreat', contabbr='$contabbr', persweb='$persweb', idactiv='$idactiv', unsubscribe='$unsubscribe', ent='$ent', city='$city', email='$email', random='$random', date= CURDATE(); // RUN QUERY 1 if(!mysql_query($sql1)): echo(Unable to add contact: . mysql_error() . br); else: echo(Contact added successfullybr); endif; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spaces
replace more than 1 space in a row with a nbsp; OR, when outputing their text place a pre tag around it Andrew - Original Message - From: Stephen To: PHP List Sent: Monday, December 09, 2002 9:25 PM Subject: [PHP] Spaces I have a article submission thing where the user types in whatever they want. I've already made it so that when the user pushes enter, it saves it as a br for HTML but how would I do this for spaces also? I'm storing the contents in a MySQL database... Thanks, Stephen Craton http://www.melchior.us What is a dreamer that cannot persevere? -- http://www.melchior.us -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spaces
So would I just do this? $text = str_replace( , nbsp;, $_POST['input']); - Original Message - From: Andrew Brampton [EMAIL PROTECTED] To: Stephen [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, December 09, 2002 4:30 PM Subject: Re: [PHP] Spaces replace more than 1 space in a row with a nbsp; OR, when outputing their text place a pre tag around it Andrew - Original Message - From: Stephen To: PHP List Sent: Monday, December 09, 2002 9:25 PM Subject: [PHP] Spaces I have a article submission thing where the user types in whatever they want. I've already made it so that when the user pushes enter, it saves it as a br for HTML but how would I do this for spaces also? I'm storing the contents in a MySQL database... Thanks, Stephen Craton http://www.melchior.us What is a dreamer that cannot persevere? -- http://www.melchior.us -- -- 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] Spaces
One more problem I could see is that if the user types in an odd number of spaces like 5 or 7. Wouldn't this replace string only replace spaces all the even spaces like 2, 4, 6, 8, and so on? - Original Message - From: Andrew Brampton [EMAIL PROTECTED] To: Stephen [EMAIL PROTECTED] Sent: Monday, December 09, 2002 5:36 PM Subject: Re: [PHP] Spaces $text = str_replace( , nbsp;nbsp;, $_POST['input']); would be better, since each nbsp; is a space $text = str_replace( , nbsp; , $_POST['input']); might work also, but I'm unsure how browsers handle nbsp; nbsp; nbsp; . Andrew - Original Message - From: Stephen [EMAIL PROTECTED] To: Andrew Brampton [EMAIL PROTECTED] Cc: PHP List [EMAIL PROTECTED] Sent: Monday, December 09, 2002 10:01 PM Subject: Re: [PHP] Spaces So would I just do this? $text = str_replace( , nbsp;, $_POST['input']); - Original Message - From: Andrew Brampton [EMAIL PROTECTED] To: Stephen [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, December 09, 2002 4:30 PM Subject: Re: [PHP] Spaces replace more than 1 space in a row with a nbsp; OR, when outputing their text place a pre tag around it Andrew - Original Message - From: Stephen To: PHP List Sent: Monday, December 09, 2002 9:25 PM Subject: [PHP] Spaces I have a article submission thing where the user types in whatever they want. I've already made it so that when the user pushes enter, it saves it as a br for HTML but how would I do this for spaces also? I'm storing the contents in a MySQL database... Thanks, Stephen Craton http://www.melchior.us What is a dreamer that cannot persevere? -- http://www.melchior.us -- -- -- -- 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] Spaces
This isn't really a PHP question, but look at the pre html tag. Patrick McKinley wrote: Is there a way of getting a php to display all the spaces in a file. i have used this to display an nfo file on my site: ---nfoload.php ? $fol = $_GET['fol']; $nfono = $_GET['nfono']; require(nfo/.$fol./ind.txt) ? title? echo $nfo ?/title body background=images/backg.jpg ? $file = nfo/.$fol./.$nfo.; $fp = fopen($file, r); $fc = fread($fp, filesize($file)); echo nl2br($fc); fclose($fp); ? nfo/$fol/ind.txt (tells the script filenames for the nfo files) ? if $nfono == 1 { $nfo = nfo_file_1.nfo } else if $nfono == 2 { $nfo = nfo_file_2.nfo } ? now since nfo files tend to include a fair bit of of ASCII art in them, i was wandering if there's a way to preserve the spaces in this file, so the ASCII art is preserved. thanks -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spaces
uhm, i feel silly now, ignore my question please :D - Original Message - From: Leif K-Brooks [EMAIL PROTECTED] To: Patrick McKinley [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Saturday, December 07, 2002 8:08 PM Subject: Re: [PHP] Spaces This isn't really a PHP question, but look at the pre html tag. Patrick McKinley wrote: Is there a way of getting a php to display all the spaces in a file. i have used this to display an nfo file on my site: ---nfoload.php ? $fol = $_GET['fol']; $nfono = $_GET['nfono']; require(nfo/.$fol./ind.txt) ? title? echo $nfo ?/title body background=images/backg.jpg ? $file = nfo/.$fol./.$nfo.; $fp = fopen($file, r); $fc = fread($fp, filesize($file)); echo nl2br($fc); fclose($fp); ? nfo/$fol/ind.txt (tells the script filenames for the nfo files) ? if $nfono == 1 { $nfo = nfo_file_1.nfo } else if $nfono == 2 { $nfo = nfo_file_2.nfo } ? now since nfo files tend to include a fair bit of of ASCII art in them, i was wandering if there's a way to preserve the spaces in this file, so the ASCII art is preserved. thanks -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Spaces
now since nfo files tend to include a fair bit of of ASCII art in them, i was wandering if there's a way to preserve the spaces in this file, so the ASCII art is preserved. This is an HTML issue. HTML will only show one space. You can convert all spaces to nbsp; or you can use the pre tags. pre is probably better so everything will line up correctly. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] spaces vs nbsp; in form fields
The problem is that you have special characters that are interfering with the output. I had exactly the same problem a few weeks ago. Try this: $fixedOutputValue = htmlspecialchars($outputValue); print (input type=\text\ value=\$fixedOutputValue\ /); This is how I solved it. Note that putting htmlspecialchars($outputValue) in the value attribute will give you undesirable results. At 01:32 PM 10/29/2001, Greg wrote: However, when I display the value in an input text box on a form, only John appears. The odd thing is that when I view source, the full name appears in the HTML; it just doesn't render that way in IE/Opera. Sliante, Richard S. Crawford http://www.mossroot.com mailto:[EMAIL PROTECTED] AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford It is only with the heart that we see rightly; what is essential is invisible to the eye. --Antoine de Saint Exupéry Push the button, Max! -- 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]