SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Addict
    Join Date
    May 2002
    Location
    Louisville, KY
    Posts
    238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help getting "<a href=" from inside $row[content]

    I guess the easiest way to describe this is to show you my code... here is what i am trying to do...



    PHP Code:

    while($r=mysql_fetch_array($result)) {

    $find "<a href=";
    $replace "<a target=_new href=";

    $new_content eregi_replace($find$replace$r[content]);


    Any ideas?

  2. #2
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    California
    Posts
    267
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Each row is going to reset the variable $new_content. Try this:

    PHP Code:
    $new_content '';
    while(
    $r=mysql_fetch_array($result)) {
     
     
    $find "<a href=";
     
    $replace "<a target=_new href=";
     
     
    $new_content .= eregi_replace($find$replace$r[content]);
     
     } 
    The Banana Stand - an Arrested Development fansite
    LC-3 Help - tutorials on the LC-3 educational assembly language

  3. #3
    SitePoint Addict
    Join Date
    May 2002
    Location
    Louisville, KY
    Posts
    238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help... unfortunately it's not doing it. When I view the page it's totally white... and the source only shows the header information...

    This is (NOT by my choice) running on a windows server with PHP enabled. Everything works fine except this.

    Thanks,
    JP

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    make sure to
    echo $new_content;

  5. #5
    SitePoint Enthusiast cphillips's Avatar
    Join Date
    Feb 2005
    Location
    West Chester, PA USA
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If its totally white, check your code to make sure your code is correct. Sometimes I get the totally white screen when I forget a ";" at the end of a line of code, or a "}" in an If / Then
    Thanks!
    cphillips
    West Chester, PA USA

  6. #6
    SitePoint Addict
    Join Date
    May 2002
    Location
    Louisville, KY
    Posts
    238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is what I have and I'm getting a totally white page.

    PHP Code:
    $find "<a href=";
    $replace "<a target=\"_new\" href=";
    $new_content .= eregi_replace($find$replace$r[content])
                  
    // content
    echo "<div class=\"blog\">$new_content\n"

  7. #7
    SitePoint Addict
    Join Date
    May 2002
    Location
    Louisville, KY
    Posts
    238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any ideas?

  8. #8
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    California
    Posts
    267
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're missing a semicolon on this line:

    PHP Code:
    $new_content .= eregi_replace($find$replace$r[content]) 
    The Banana Stand - an Arrested Development fansite
    LC-3 Help - tutorials on the LC-3 educational assembly language

  9. #9
    SitePoint Addict smittenbite's Avatar
    Join Date
    Jul 2005
    Location
    Friendswood
    Posts
    397
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try echo $new_content; by itself to see if that works.
    nothing.

  10. #10
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try...
    PHP Code:
    // content
    echo "<div class=\"blog\">" $new_content "\n"

  11. #11
    SitePoint Addict
    Join Date
    May 2002
    Location
    Louisville, KY
    Posts
    238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am a complete idiot. Thanks... i forgot the semicolon.


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
  •