SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple PHP issue

    This should not be an issue... but it is. I have spent the better part of 2 hours trying to figure out why I am getting an eval code parse error. This snippet is being called from a file (all HTML except this) and eval()ed. The error is on line 9 which is the mysql_query line.
    PHP Code:
    <?php
    $sql 
    = @mysql_query("SELECT *
    FROM articles
    WHERE featured = '1'
    LIMIT 0 , 1"
    );
    //echo mysql_num_rows($getSnippet);
    if(!$sql)
        {
        echo 
    'No articles available';
        }
    else
        {
        while(
    $snippet mysql_fetch_array($sql))
            {
    ?>

    <h3><?php echo $snippet['title']; ?></h3>
      
    <?php echo substr($snippet['article'],150); 
            }
        }
    ?>
    Called from:
    PHP Code:
            $pagecontent stripslashes(makehtml(nl2br($rowContent['content'])));
            echo 
    '<p>';
            eval(
    '?>'.$pagecontent);
            echo
    '</p>'
    Make any sense of it?
    Aaron Brazell
    Technosailor



  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2001
    Location
    Michigan, USA
    Posts
    414
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What happens if you don't eval the code? Just run the code as normal PHP. I imagine it works, right? I am failing to see exactly why anything would be causing a problem. If you're still having a problem tomorrow, I'll take some time and sit down and look at it. Unfortunately, my two tests tomorrow have my attention right now

  3. #3
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So what was the point of the response?

    I can't simply run the code. It's coming in from mysql. It's a string. It needs to be eval()ed.

    Next.
    Aaron Brazell
    Technosailor



  4. #4
    SitePoint Evangelist
    Join Date
    Jul 2001
    Location
    Michigan, USA
    Posts
    414
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was implying you try the code without pulling it from the mySQL database. Simply checking if it worked to begin with, which I've had happen to me personally before.

    However, feel free to ignore my suggestion. I don't appreciate your response (from an advisor?!?!) and will no longer be helping you.

    I do wish you luck with fixing your problem.

  5. #5
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Forgive me. I'm dealing with another issue at the moment as well. Yes it runs fine by itself, but not as an eval()
    Aaron Brazell
    Technosailor



  6. #6
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using single-quotes only and escaping them within the string. eval has.."issues" with quotes much of the time.
    TuitionFree a free library for the self-taught
    Anode Says... Blogging For Your Pleasure

  7. #7
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, I tried that too. I've broken everything down to try to narrow down the error, and it still seems to be happening at the eval:
    PHP Code:
    $getContent = mysql_query("SELECT * FROM pages WHERE id = ".$selectedpage);
    if(!@$getContent)
        {
        echo '<p>Page Data Not Available.</p>';
        }
    else
        {
        while($rowContent = mysql_fetch_array($getContent))
            {
            echo '<h3 class="feature">'.stripslashes($rowContent['title']).'</h3>';
            $pagecontent = nl2br($rowContent['content']);
            $pagecontent = makehtml($pagecontent);
            $pagecontent = stripslashes($pagecontent);
            echo '<p>';
            eval('?>'.addslashes($pagecontent).'<?php ');
            echo'
    </p>';
            }
        }
    Aaron Brazell
    Technosailor



  8. #8
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone...
    Aaron Brazell
    Technosailor



  9. #9
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    What does makehtml() do? Not in the manual

    Why don't you just do this?
    PHP Code:
    while($rowContent mysql_fetch_array($getContent))
        {
            echo 
    '<h3 class="feature">'.stripslashes($rowContent['title']).'</h3>';
            
    $pagecontent nl2br($rowContent['content']);
            
    $pagecontent makehtml($pagecontent);
            
    $pagecontent stripslashes($pagecontent);
            echo 
    '<p>';
            echo 
    addslashes($pagecontent);
            echo
    '</p>';
            }
        } 

  10. #10
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $pagecontent has PHP in it. It won't execute right?
    Aaron Brazell
    Technosailor



  11. #11
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DJ P@CkMaN
    What does makehtml() do? Not in the manual

    Why don't you just do this?
    PHP Code:
    while($rowContent mysql_fetch_array($getContent))
        {
            echo 
    '<h3 class="feature">'.stripslashes($rowContent['title']).'</h3>';
            
    $pagecontent nl2br($rowContent['content']);
            
    $pagecontent makehtml($pagecontent);
            
    $pagecontent stripslashes($pagecontent);
            echo 
    '<p>';
            echo 
    addslashes($pagecontent);
            echo
    '</p>';
            }
        } 
    makehtml() is a bbcode parser I wrote.
    Aaron Brazell
    Technosailor



  12. #12
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Sketch
    $pagecontent has PHP in it. It won't execute right?
    Yeah, that's right

  13. #13
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    got it. Thanks to naramation. it was the nl2br() screwing everything up.

    Thanks guys
    Aaron Brazell
    Technosailor




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
  •