Solved

I need help !

Posted on 2013-12-31
8
233 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 110

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

624 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