Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

I need help !

Posted on 2013-12-31
8
Medium Priority
?
235 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 500 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 1000 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 1000 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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 500 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
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.
Suggested Courses

926 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