Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading csv file with php problem 1

Status
Not open for further replies.

mrmtek

Programmer
Oct 13, 2002
109
AU
using following code to load a csv into php, when hard coded works fine, however when I echo the path I get the following:

f:\\pathname\\filename.csv

the php code work fine when hard coded however I found extra \\ between each path seperator

the code:

$path=$_POST['csvselect'];
$file_path=$csv_file['path'];
$file = @fopen($file_path, "r")
or die("CSV file not found.");

can anyone assit??
 
That would be because PHP, although platform agnostic, is developed on a Unix-like operating system. Unix-like operating systems use "/" (forward slash) as a pathname separator and typically use "\" (backslash) as an escape character. Examples are "\n" for a newline and "\t" for a tab. Double backslash ("\\") is an escaped character that represents a backslash.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
thank you, however how do I get around this problem??
 
look at
stripslashes() and addslashes()... stripslashes takes slashes out of things comming from files and databases, addslashes escapes chars that are meaningful to certian languages like the returns into \n for newlines, \'[/green] for ''s \" for "'s and \\ for\.

Alternitivly PHP mught let you use linux XPATH style to spesify a file name using /'s instread of \'s
 
by using the correct synatx got the first problem corrected and looks ok now , however when loading get the following error message:

Warning: fopen(F:\admin\import\data\blext.csv): failed to open stream: Success in /home/import/implot_inc.php on line 42

could you point me in the correct direction again please.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top