Parts Catalog Accessories Catalog How To Articles Tech Forums
Call Pelican Parts at 888-280-7799
Shopping Cart Cart | Project List | Order Status | Help



Go Back   PeachParts Mercedes-Benz Forum > General Discussions > Off-Topic Discussion

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 04-17-2006, 09:34 AM
GottaDiesel's Avatar
Banned
 
Join Date: Sep 2003
Location: New Jersey
Posts: 1,564
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

Reply With Quote




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.
Reply With Quote
  #2  
Old 04-17-2006, 09:52 AM
GottaDiesel's Avatar
Banned
 
Join Date: Sep 2003
Location: New Jersey
Posts: 1,564
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 );
} ?>
?>
  #3  
Old 04-17-2006, 03:11 PM
GottaDiesel's Avatar
Banned
 
Join Date: Sep 2003
Location: New Jersey
Posts: 1,564
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)
Reply With Quote
  #4  
Old 04-17-2006, 05:24 PM
MikeTangas's Avatar
Senior Member
 
Join Date: Apr 2000
Location: So. Cal
Posts: 4,430
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.
Reply With Quote
  #5  
Old 04-17-2006, 05:32 PM
GottaDiesel's Avatar
Banned
 
Join Date: Sep 2003
Location: New Jersey
Posts: 1,564
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

Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:59 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0
Copyright 2024 Pelican Parts, LLC - Posts may be archived for display on the Peach Parts or Pelican Parts Website -    DMCA Registered Agent Contact Page