SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation blog form problem [url][/url] [code][/code]

    When I enter a URL in my blog entry form i.e. www.sitepoint.com I want it to be clickable on the index page where my blog entries display.

    On the index page I have this code which works for bold tags:
    PHP Code:
        $find[] = "[b]"//Look for bold tag
        
    $replace[] = "<span style='font-weight: bold;'>";  //Replace with span tag
        
    $find[] = "[/b]"//Look for bold end tag
        
    $replace[] = "</span>"//replace with end span 
    I tried changed this hoping it would work for
    PHP Code:
        $find[] = "[url]"//Look for bold tag
        
    $replace[] = "<span class="class2"><a href="http://www.sitepoint.com" onclick="window.open (this.href, 'child', 
    'height=650,width=525,scrollbars'); return false">";  //Replace with span tag
        
    $find[] = "[/url]"//Look for bold end tag
        
    $replace[] = "</a></span>"//replace with end span 
    I was trying to get a new window load when you click on the link.
    I didnt get that far because the browser gave me this error on that line:
    Parse error: parse error, unexpected T_STRING in /home/webmedia/public_html/jecgardner/index.php on line 46
    I have tried making it simple by using just the <a href="www.sitepoint.com"> but the browser still gives me an error. Another problem with this method is all text that is wrapped with [ur|][/url] will go to the same site

    I put this into the blog entry form <a href="http://www.skaffers.com">www.sitepoint.com</a> which turned into a link on the index page but when I clicked on it the browser said:
    The requested URL /jecgardner/http<img src='../jecgardner/images/facehm.gif' alt='hmm'/>/www.sitepoint.com was not found on this server.


    Ultimately I would like the links to look like this sites:
    http://www.tanfa.co.uk/css/articles/...ers-design.asp


    Another problem I encountered which is not so serious is the code tag that changes the background colour. I have achieved this but if I add a border to the code it repeats the top border on every new line..
    This is a screenshot of what it looks like using a border:


    This is the code for the border:
    PHP Code:
        $find[] = "[code]"//Look for code tag
        
    $replace[] = "<span style='border-style: outset; background-color:#646464; color: white;'>";  //Replace with span tag
        
    $find[] = "[/code]"//Look for code end tag
        
    $replace[] = "</span>"//replace with end span 
    Any ideas how I can get the links to work and fix the border problem?

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,228
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)

    quotes mess

    If you look at your $replace[] line, ie.
    PHP Code:
    $replace[] = "<span class="class2"><a href="http://www.sitepoint.com" onclick="window.open (this.href, 'child',
    'height=650,width=525,scrollbars'); return false">";  //Replace with span tag 
    you will see that the "color highlighting" shows your problem. The string begins with the character after the first double quote, and ends with the last character before the next double quote. The script expects a line end - the semi-colon - ";" so when there is more text instead it complains.
    Try using single quotes, or escape the quotes with back-slashes, or use heredoc syntax, and you might have better luck.

  3. #3
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The text highlighted in orange is because of the "//" if I remove http:// so its just www. then I get this browser error:
    Parse error: parse error, unexpected '[' in /home/webmedia/public_html/jecgardner/index.php on line 45
    I have tried the single quotes.. The heredoc syntax is totally new to me. I found info on this page: http://uk.php.net/types.string <<<

    I wouldnt know how to apply heredoc syntax correctly


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •