Solved

I need help !

Posted on 2013-12-31
8
228 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 30

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 30

Expert Comment

by:Marco Gasi
ID: 39748351
What is line 8 in the snippet above?
0
 

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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 74

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 74

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 108

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now