473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

ERRORS when escaping \ while writing files and echoing to screen

Here I am trying to write a file with a directory path like d:\\$directory1\$directory2\$file.txt
So I have variables in between backslashes and I keep getting errors like:
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/4/4/a/2769/2769/public_html/upload/a/thankyou.php on line 69

I would like put the values in a literal string variable like:
Expand|Select|Wrap|Line Numbers
  1. $str="d:\\$directory1\$directory2\$file.txt" 
BUT
I believe this might not be possible so in the meantime I have been writing each component to the file one piece at a time :
Expand|Select|Wrap|Line Numbers
  1. $str ="d:\\"
  2. fwrite(fp, $str);
  3. $str=$directory1;
  4. fwrite(fp, $str);
  5. $str="\\";
  6. fwrite(fp, $str);
...and so on, that isn't working right either, I keep getting a \\ in the file instead of \ or errors depending on my syntax.
Oct 15 '08 #1
1 1084
Dormilich
8,658 Expert Mod 8TB
you could escape the backslashes or put the backslashes in single quotation marks (ie. they will not be parsed as escape character)

regards
Oct 15 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: lawrence | last post by:
I've had buffer problems before where a script dies silently but no error message ever reaches my screen, because of buffering issues. Perhaps that is happening now. The other possibility, which I...
14
by: Jon Maz | last post by:
Hi, I have been getting hopelessly confused with escaping escape characters in JScript! All I want to do is write a simple funtion: function DoubleUpBackSlash(inputString) { ??????? }
8
by: jon morgan | last post by:
OK, I'm going to be brave. There is a bug in VS.Net 1.1 that causes random compiler errors. I have raised this issue in posts at least three time in the past couple of months without attracting...
12
by: Russ | last post by:
Hello. My new dev machine is running XP Pro. In the past all equipment has only used Windows 2000. I have had a lot of problems getting my projects up and running on the new machine. The current...
3
by: fbwhite | last post by:
I am having an issue (maybe two issues) in my application regarding a stylesheet not loading and I am getting Javascript Errors. If I clean out a client's temporary internet files and then browse...
11
by: Geoff Caplan | last post by:
Hi folks, The thread on injection attacks was very instructive, but seemed to run out of steam at an interesting point. Now you guys have kindly educated me about the real nature of the issues,...
78
by: Robert Baer | last post by:
The homepage i have had up and seemingly working is: http://oil4lessllc.com/ However, the validator has so many complaints, and being so incompetent, i have no clue as to how to fix it all. Would...
2
by: =?Utf-8?B?UmFscGggSQ==?= | last post by:
OK, Dell inspirion 9300 - 100 gb hd partitioned into 3 drives C: OS 10 gb D: Programs 20 gb E: Data 70 GB Page Files 0 on C: 4092 on D: 3070 on E:
14
by: Martin Wells | last post by:
When I have errors in a program, whether they be compiler errors, linker errors, or if the program crashes when running, I have a list of things I check for initially. If I get an error for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.