473,395 Members | 1,454 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,395 software developers and data experts.

Syntax Error caused by Inserting Hyperlink in String

am getting syntax error, can someone please explain how to insert a hyperlink into a table.
Feb 27 '07 #1
14 2647
miller
1,089 Expert 1GB
am getting syntax error, can someone please explain how to insert a hyperlink into a table.
Is this an HTML question?

- M
Feb 27 '07 #2
Sorry about the poor topic but it is a perl question
part of my code consists of
<td><<A HREF="http://www.whatever.com">http://www.whatever.com</A></td>

And the error i get is "syntax error at line 99, near "<td><<A HREF="http""
Feb 27 '07 #3
KevinADC
4,059 Expert 2GB
lets see your real perl code. What you posted is an out of context line of text that is impossible to debug in relationship to your perl code.
Feb 27 '07 #4
Haven't posted the whole code because most of it is HTML
but the code concerning the error is below

print "<table border='1'>";
print "<tr><td>Type</td><td>Size</td><td>Price</td></tr>";
foreach $line (@all) {
chop($line);
($size,$price,$type=split(/\|/,$line);
print "
<tr>
<td>$type</td>
<td>$size</td>
<td>$price</td>
<td><A HREF="http://www.whatever.com">http://www.whatever.com</A></td>
</tr>";
}
print"</table>";

If needed i could post the entire code
Also could you help me change some of the table attributes such as font, font colours, bgcolor, row width, column width
Thank you
Feb 27 '07 #5
KevinADC
4,059 Expert 2GB
you can't use unescaped double-quotes in a print command that uses double-quotes as the string terminator, add a backslash to escape embedded double-quotes:

Expand|Select|Wrap|Line Numbers
  1. print "
  2. <tr>
  3. <td>$type</td>
  4. <td>$size</td>
  5. <td>$price</td>
  6. <td><A HREF=\"http://www.whatever.com\">http://www.whatever.com</A></td>
  7. </tr>";
  8. }
perl has quote operators that make life easier:

perldoc Quote and Quote like Operators

Feb 27 '07 #6
miller
1,089 Expert 1GB
To fix your problem, either escape the double quotes inside the string, or use a different encloser. My personal preference is to use qq{my string here}.

http://perldoc.perl.org/functions/qq.html


Expand|Select|Wrap|Line Numbers
  1. print qq{<table border='1'>};
  2. print qq{<tr><td>Type</td><td>Size</td><td>Price</td></tr>};
  3. foreach $line (@all) {
  4.     chop($line);
  5.     ($size, $price, $type) = split(/\|/, $line);
  6.     print qq{
  7. <tr>
  8. <td>$type</td>
  9. <td>$size</td>
  10. <td>$price</td>
  11. <td><A HREF="http://www.whatever.com">http://www.whatever.com</A></td>
  12. </tr>};
  13. }
  14. print qq{</table>};
  15.  
Feb 27 '07 #7
KevinADC
4,059 Expert 2GB
hehehe.... that long hyper link was rather obnoxious, thanks Miller ;)
Feb 27 '07 #8
miller
1,089 Expert 1GB
Your welcome :)

perldoc really does have the silliest anchors. Why on earth they feel it necessary to have an anchor that is 157 characters in length when the header for the section is only 30, I'll never know.
Feb 27 '07 #9
Thanks for the help
It works nicely
But any ideas on improving how the table looks (fonts, colors etc.)
Thank You
Feb 27 '07 #10
Expand|Select|Wrap|Line Numbers
  1. print "<table border='1'>";
  2. print "<tr><td>Type</td><td>Size</td><td>Price</td></tr>";
  3. foreach $line (@all) {
  4. chop($line);
  5. ($size,$price,$type=split(/\|/,$line);
  6. print "
  7. <tr>
  8. <td>$type</td>
  9. <td>$size</td>
  10. <td>$price</td>
  11. <td><A HREF="http://www.whatever.com">http://www.whatever.com</A></td>
  12. </tr>";
  13. }
  14. print"</table>";
  15.  
Another question
The variable $type, how do i transfer that variable to another perl script using the hyperlink?
Most tutorials i have seen comment on forms but not hyperlinks
An suggestions
Thank You
Feb 28 '07 #11
KevinADC
4,059 Expert 2GB
http://www.whatever.com/cgi-bin/yourscript.pl?type=$type
Feb 28 '07 #12
Brilliant
Thanks for the help Kevin, will see if this works
Feb 28 '07 #13
This code works nicely
I have used http://www.whatever.com/cgi-bin/yourscript.pl?$type
But what if i wish to transfer more than one variable using this method, is it possible?
For example tranfer $type, and $size, $code
Thank You
Mar 2 '07 #14
KevinADC
4,059 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. http://www.whatever.com/cgi-bin/yourscript.pl?type=$type&size=$size
or instead of '&' use ';' which to delimit for URI string:

Expand|Select|Wrap|Line Numbers
  1. http://www.whatever.com/cgi-bin/yourscript.pl?type=$type;size=$size
Mar 2 '07 #15

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

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
24
by: deko | last post by:
I'm trying to log error messages and sometimes (no telling when or where) the message contains a string with double quotes. Is there a way get the query to insert the string with the double...
0
by: compuglobalhypermeganetz0r | last post by:
I am having trouble getting an adapter to update my access database, it gives the error Syntax error in INSERT INTO statement. for Line 98: Adapter.Update(WineDS, "tblWines") Below is my...
0
by: DC Gringo | last post by:
I am getting a error upon attempting a postback that causes a redirection of the browser from http://myserver.com/ to http://myserver.com/0. My Try Catch block with exception handler doesn't come...
1
by: amitbadgi | last post by:
HI i am getting the foll error while conv an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Syntax error in UPDATE statement. Source Error: Line...
2
by: serge calderara | last post by:
Dear all, I have the following item on my form : <asp:HyperLink id="lblEvtNb" runat="server" NavigateUrl="Event.aspx?id=">Click here</asp:HyperLink> I need to pass as url parameter an Id...
4
by: Hansen | last post by:
Hi! I have a try/catch statement on my webpage, in which a create som html. Sometimes this routine fails and the catch writes the error in an alert box. My problem is that the only thing the...
5
by: mesut | last post by:
Hi there, how are you colleagues? I try to set a linkaddress in code behind for a <asp:hyperlinkserver control. but I think I have some syntax problem. I don't know how to fix it. What's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.