PHP - echo html and variables, what am I doing wrong?!

Associate
Joined
3 Nov 2005
Posts
611
I am being baffled by something which should be so simple and seemingly looks correct as I've done something similar a long way up the code which works fine. Be grateful if you can help as I want to get this sorted.

echo "<input type='hidden' name='blog_id[]' value='" . $postid . "'>";
echo "<input type='text' name='blog_title[]' value='" . $editlist2['Title'] . "'>"
echo "<textarea id='editpost' name='blog_post[]'>" . $editlist2['Post'] . "</textarea>";
echo "<h1>This post originally contains " . $length . " characters. You may add up to " . $char_allowed . "more.</h1>";
echo "<h2>This post was first created by " . $editlist2['User'] . " - " . $editlist2['DateTime'] . ".</h2>";

The bottom three lines of the five are all causing issues. When I comment the third line out, the fourth one errors and so on.

The error is - 'Parse error: parse error, expecting `','' or `';'' in...'
 
In the longer term, it's bad practice to code how you have (I think). I'm not a professional coder but personally doing it like that (with whole lines in PHP for no reason) can raise difficulties later and just isn't tidy.

I have been debating which way to do that whether to just open/close a php tag for including variables in HTML but I read around on the subject on a few websites who suggested it was more a matter of readability than any real speed increase.

I do see your point though....I might change it round if others agree with you :)
 
Back
Top Bottom