473,387 Members | 1,590 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,387 software developers and data experts.

PHP Warning: Unexpected character in input: '\' (ASCII=92)

I keep getting PHP Warning: Unexpected character in input: '\' (ASCII=92)) this error on windows platform. this script works fine on Linux. Can anybody help? This script is supposed to return the most current file in d:\cacti\sqlbak directory.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. $dir = d:\\cacti\\sqlbak;
  4. $pattern = '/sql/';
  5.  
  6. $newstamp = 0;
  7. $newname = "";
  8. $dc = opendir($dir);
  9. while ($fn = readdir($dc)) {
  10.   # Eliminate current directory, parent directory
  11.   if (ereg('^\.{1,2}$',$fn)) continue;
  12.   # Eliminate other pages not in pattern
  13.   if (! ereg($pattern,$fn)) continue;
  14.   $timedat = filemtime("$dir/$fn");
  15.   if ($timedat > $newstamp) {
  16.     $newstamp = $timedat;
  17.     $newname = $fn;
  18.   }
  19. }
  20. # $timedat is the time for the latest file
  21. # $newname is the name of the latest file
  22. echo "the latest file is $newname\n";
  23. ?>
  24.  
  25.  
May 5 '08 #1
4 8577
ronverdonk
4,258 Expert 4TB
Must be statement 2. Do not forget to enclose a character value in a variable within quotes!

Ronald
May 5 '08 #2
$dir = "d:\\cacti\\sqlbak";

still the same error.

PHP Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\perl_
scripts\list_file.php on line 2
PHP Parse error: syntax error, unexpected T_STRING in C:\perl_scripts\list_file
.php on line 2
May 5 '08 #3
Markus
6,050 Expert 4TB
$dir = "d:\\cacti\\sqlbak";

still the same error.

PHP Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\perl_
scripts\list_file.php on line 2
PHP Parse error: syntax error, unexpected T_STRING in C:\perl_scripts\list_file
.php on line 2
PHP isn't liking the back slashes; can these be reformatted?
May 5 '08 #4
Atli
5,058 Expert 4TB
That's weird. That string looks ok.

Have you tried single quotes?
Expand|Select|Wrap|Line Numbers
  1. $dir = 'd:\\cacti\\sqlbak';
  2. // Or even
  3. $dir = 'd:\cacti\sqlbak';
  4.  
May 5 '08 #5

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

Similar topics

3
by: Andrzej Jan Taramina | last post by:
I have a need to convert a number into the character that it represents. For example, if I have: <xsl:variable name="number" select="169"/> I want to be able to convert this to the...
3
by: thomas Armstrong | last post by:
Hi Using Python 2.3.4 + Feedparser 3.3 (a library to parse XML documents) I'm trying to parse a UTF-8 document with special characters like acute-accent vowels: -------- <?xml version="1.0"...
5
by: Alan Cobb | last post by:
Hi, In the managed C++ class below I get compile warning C4677 from VS2003. "signature of non-private function contains assembly private type", even though the managed enum is public. I have...
8
by: vagos | last post by:
Can someone please tell me why i get the following error ?? The strange is that sometimes i get the error and sometimes not !! Also there is no syntax error on line 251 Warning: Unexpected...
55
by: Sameer | last post by:
Hi, when i compile my C programs (even 2 line progs) give the warning, no new line at end of file. What does this mean ? -Regards, Sameer
1
by: Nathan Sokalski | last post by:
Visual Studio 2005 unexpectedly stopped generating the *.designer.vb files for *.aspx and *.ascx files. After a few days of frustration trying to fix this, I noticed that it had the following...
6
by: borophyll | last post by:
Hi Please let me know if I have this clear. The basic source character set is the list of (96) characters that all implementations must have in their vocabulary. All other characters...
1
Lazandra
by: Lazandra | last post by:
Hi guys I have the following error: Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /usr/webdata/kirkwood/config/config.php on line 2 Parse error: syntax error, unexpected...
3
by: swethak | last post by:
hi, i create the one file.At time of creation i insert below contents into the file &lt;?php include("ClassName.class"); $myclass = &new ClassName; echo $myclass->myfunction1(); ?&gt;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.