Each article that I create has its own unique URL. In each page is the corresponding code, which pulls the template (which is a mix of PHP/HTML/CSS) for the page from a MYSQL table. For some reason, it adds a line break at the top of the page, pushing everything down. Attached is a diagram of what I mean - for the real life example, please PM me. The code that is stored in MySQL is not the problem - it is the method in which I process it, eval(). How can I get rid of this line break? Thanks <?php $article_id = '390'; ?><?php require_once($_SERVER["DOCUMENT_ROOT"] . "/includes/db.php"); $sql = "SELECT Above_Content, Below_Content FROM templates WHERE ID = '1'"; $query = mysql_query($sql); if ($row = mysql_fetch_assoc($query)) { echo eval("?>".$row['Above_Content']); $sql = "SELECT article_title, article_intro, article_content, author_id, creation_date, last_modified_date FROM articles WHERE article_id = '390'"; $query = mysql_query($sql); if ($row = mysql_fetch_assoc($query)) { ?> <p><?php echo $row['article_content']; ?></p> <?php } $sql = "SELECT Above_Content, Below_Content FROM templates WHERE ID = '1'"; $query = mysql_query($sql); if ($row = mysql_fetch_assoc($query)) { echo eval("?>".$row['Below_Content']); } } ?> Code (markup):
Nothing stands out in your code that would be the obvious cause of this. Have you tried putting stops in at each output to get a better idea of what is going on? You dont need anything magical, just some form of indicator every time you output something (E.G ->output1<-, ->output2<-) That aside, Why on earth are you using eval like that? :|
I discovered that it was simply an extra line in the HTML, not a problem with the PHP eval. What do you suggest I use instead? This was the only way I could think of for templating my articles. I couldn't find any other ideas , and this seems to be working fine. Could you explain further why I shouldn't be using eval() here? I'm not questioning you, just looking for more answers =)