![]() |
|
|
|
#1
|
||||
|
||||
File Name Question
I have a script that uses a certain field to look for a file name on a server.
If the field reads: Cats it looks for Cats.php If the field reads: Cats and Dogs it looks for Cats and Dogs.php This all works like a charm and I love it. Here's the question. If the field reads: 3" Wide Boxes I can't make the file called 3" Wide Boxes because it won't let me on account of the quote. Is there a way around this? Thanks, Pete |
#2
|
||||
|
||||
Here's the code that looks for the file based on the field:
$category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'"); $category = tep_db_fetch_array($category_query); $filename = 'includes/descriptions/'.$category['categories_name'].'.php'; if (file_exists($filename)) { include( $filename ); } ?> ?> Here's my thoughts: Yes... and description is inserted here: $category['categories_name'] so it looks for a file names, for exaple 3" Wide Boxes and it can't find it because I wasn't able to save a file called 3" Wide Boxes... if there was a way to substitute an accepted character (or omit it) whenever it runs into an unaccepted character that would work. So when it gets a description of: 3" Wide Boxes it would look for 3 Wide Boxes That *would* work. I know I'm on the right path... Last edited by GottaDiesel; 04-17-2006 at 03:28 PM. |
#3
|
||||
|
||||
Here's what I was told on another forum...
Dang if I know what it means: look into str_replace() or use a regular expression function (preg_replace()) to convert multiple "bad" characters to "good" characters (or omit them) |
#4
|
||||
|
||||
Rename your file to "3 inch wide boxes" so you don't have to mess aorund trying to get the system to recognize the ' " ' symbol.
__________________
Mike Tangas '73 280SEL 4.5 (9/72)- RIP ![]() Only 8,173 units built from 5/71 thru 11/72 '02 CLK320 Cabriolet - wifey's mid-life crisis 2012 VW Jetta Sportwagon TDI...at least its a diesel Non illegitemae carborundum. |
#5
|
||||
|
||||
Learned about this cool command today:
rawurlencode() So I did: 'includes/descriptions/'.rawurlencode($category['categories_name']).'.php'; and now my file names have to look like this: 3%22Inch%20Box.php BUT... guess what... IT WORKS PERFECTLY!!!!!! ![]() ![]() ![]() Pete |
![]() |
Bookmarks |
|
|