Solved

I need help !

Posted on 2013-12-31
8
230 Views
Last Modified: 2013-12-31
Hello The problem is :

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\AppServ\www\phpinfo.php on line 9

<?
 set_time_limit(0);
$f=file_get_contents("1.xml");
$reg  = '|<Email>(.*)</Email>.*<Address1>(.*)</Address1>.*<FirstName>(.*)</FirstName>.*<LastName>(.*)<\/LastName>|isU';
preg_match_all($reg,$f,$a);
$fh2 = fopen("tblcustomers.txt", 'a') ;
for ($i=0;$i<count($a[1]);$i++)
{
 fwrite($fh2,$a[1][$i]."|".$a[2][$i]."|".$a[3][$i]."|".$a[4][$i]"\n");
}
fclose($fh2);

Open in new window

0
Comment
Question by:DZphpLearn
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 31

Assisted Solution

by:Marco Gasi
Marco Gasi earned 125 total points
ID: 39748331
You have to escape all forward slashes not only the last one :)

$reg  = '|<Email>(.*)<\/Email>.*<Address1>(.*)<\/Address1>.*<FirstName>(.*)<\/FirstName>.*<LastName>(.*)<\/LastName>|isU';

Open in new window

0
 

Author Comment

by:DZphpLearn
ID: 39748345
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\AppServ\www\phpinfo.php on line 8

Same problem even when i slashed the orders
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39748351
What is line 8 in the snippet above?
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:DZphpLearn
ID: 39748358
it's new problem ,



<?
 set_time_limit(0);
$f=file_get_contents("1.xml");
$reg  = '|<Email>(.*)<\/Email>.*<Address1>(.*)<\/Address1>.*<FirstName>(.*)<\/FirstName>.*<LastName>(.*)<\/LastName>|isU';preg_match_all($reg,$f,$a);
$fh2 = fopen("tblcustomers.txt", 'a') ;
for ($i=0;$i<count($a[1]);$i++)
{
 fwrite($fh2,$a[1][$i]."|".$a[2][$i]."|".$a[3][$i]."|".$a[4][$i]"\n");
}
fclose($fh2);

Open in new window

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\AppServ\www\phpinfo.php on line 8
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 250 total points
ID: 39748363
You have to escape all forward slashes not only the last one :)
Actually, since the pattern delimiter character was changed, I don't think that's necessary.

You are missing a concatenation operator ( . ) in line 8, just before the newline. Don't know if that will solve the issue entirely.
0
 

Author Comment

by:DZphpLearn
ID: 39748394
Where exactly ?

 fwrite($fh2,$a[1][$i]."|".$a[2][$i]."|".$a[3][$i]."|".$a[4][$i]"\n");

Open in new window

0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 39748402
                                                              Here
                                                               |
fwrite($fh2,$a[1][$i]."|".$a[2][$i]."|".$a[3][$i]."|".$a[4][$i] "\n");

Open in new window

0
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 125 total points
ID: 39748404
If you're new to PHP, this article will help you get a foundation.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html

It looks like you may be trying to parse an XML document.  PHP has specialized tools for this purpose and it's much easier than trying to write a regular expression!  If you can please post the test data, I will be glad to show you how it's done.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question