Solved

I need help !

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

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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 is …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

948 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

23 Experts available now in Live!

Get 1:1 Help Now