473,405 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Parsing HTML links

jimleon
74
I have a working link that displays two images bup and bdn

Expand|Select|Wrap|Line Numbers
  1. <a href="xxxxxxxxx" onMouseOver="catbtn.src='/images/nos/adn.gif'; return true" onMouseOut="catbtn.src='/images/nos/aup.gif'; return true"><img src="/images/nos/aup.gif" width="20" height="20" alt="A" border="0" Name="catbtn"></a>
the code works fine on an html page but in trying to parse it from a php page
Expand|Select|Wrap|Line Numbers
  1. echo'
  2. <a href="xxxxxxxxx" onMouseOver="catbtn.src='/images/nos/adn.gif'; return true" onMouseOut="catbtn.src='/images/nos/aup.gif'; return true"><img src="/images/nos/aup.gif" width="20" height="20" alt="A" border="0" Name="catbtn"></a>
  3. '
it throws up the error
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';'

I'm sure this has to do with single or double quotes placement.

Any ideas ladies and gentlemen?

Tahnk you
May 22 '08 #1
2 1360
Atli
5,058 Expert 4TB
You need to escape any single-quote-marks in a string that is enclose in single-quote-marks. Otherwise PHP will simple close the string and the rest of the string will be parsed as PHP code.

Like, for example:
Expand|Select|Wrap|Line Numbers
  1. $string = 'Somebody's name'; # This will cause an error
  2. $string = 'Somebody\'s name'; # This won't
  3.  
On a side-note...
You could also do:
Expand|Select|Wrap|Line Numbers
  1. echo <<<END
  2. <a href="xxxxxxxxx" onMouseOver="catbtn.src='/images/nos/adn.gif'; return true" onMouseOut="catbtn.src='/images/nos/aup.gif'; return true"><img src="/images/nos/aup.gif" width="20" height="20" alt="A" border="0" Name="catbtn"></a>
  3. END;
  4.  
May 22 '08 #2
rizwan6feb
108 100+
This is the correct syntax. You must escape the character ' with a \

Expand|Select|Wrap|Line Numbers
  1. echo'
  2. <a href="xxxxxxxxx" onMouseOver="catbtn.src=\'/images/nos/adn.gif\'; return true" onMouseOut="catbtn.src=\'/images/nos/aup.gif\'; return true"><img src="/images/nos/aup.gif" width="20" height="20" alt="A" border="0" Name="catbtn"></a>
  3. '
  4.  
May 22 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
0
by: Pentti | last post by:
Can anyone help to understand why re-parsing occurs on a remote database (using database links), even though we are using a prepared statement on the local database: Scenario: ======== We...
9
by: philipl | last post by:
hi, Does anyone have any sample code for this?? I can't find anything relvant at all. Please share out some code if you have any. thx
0
by: Jarod_24 | last post by:
I've tried the WebBrowser in the System.Windows.Forms namespace, but it dosen't work when you instanciate an object from a class. It needs a Form to live in to work. My application allready has...
3
by: Rodrigo Meza | last post by:
Hello Everyone For a project I am working on, I need to retrieve links from html documents. The easy part is to obtain 'plain' links like <A HREF="http://site/path/document">, but when those...
1
by: Robert Neville | last post by:
Basically, I want to create a table in html, xml, or xslt; with any number of regular expressions; a script (Perl or Python) which reads each table row (regex and replacement); and performs the...
9
by: sebzzz | last post by:
Hi, I work at this company and we are re-building our website: http://caslt.org/. The new website will be built by an external firm (I could do it myself, but since I'm just the summer student...
4
by: =?Utf-8?B?QWxwYW5h?= | last post by:
I am making a thin email client and want to get emails from a pop3 server...Is there any built in support in C# to get emails from a pop3 server and parse the email to show up on the UI ?
1
by: Philip Semanchuk | last post by:
On Oct 12, 2008, at 5:25 AM, S.Selvam Siva wrote: Selvam, You can try to find them yourself using string parsing, but that's difficult. The closer you want to get to "perfect" at finding URLs...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.