Page 1 of 1
echoing trouble
Posted: Sun Jun 06, 2004 7:23 pm
by sk8erh4x0r
I'm having trouble with my user info echo's. This is what i have right now:
echo "<center><h2>$row[username]<h2><center><img width ='70' height='70' src=\"$row[avatar]\"><br \>\n";
I'm trying to have the username and avatar post on the same line, but after the username, its inserting a line break and the avatar is under the username. Any help on how to fix this?
Posted: Sun Jun 06, 2004 10:06 pm
by Illusionist
try $row['username'] and $row['avatar'] instead.
Posted: Sun Jun 06, 2004 10:30 pm
by andre_c
... actually it seems to me that your variables are fine as $row[username] since you have them inside of double quotes.
You might try getting everything inside of the <center> tags instead of just the h2 tags, or if that doesnt work put it in a table with two table cells:
Code: Select all
<?
echo "<table align='center'>\n";
echo " <tr>\n";
echo " <td><h2>$row[username]</h2></td>\n";
echo " <td><img width='70' height='70' src='$row[avatar] /></td>\n";
echo " </tr>\n";
echo "</table>\n";
?>
Posted: Mon Jun 07, 2004 1:06 am
by feyd
andre missed a single quote in there.. although I highly suggest using double quotes for all those attributes..
Posted: Mon Jun 07, 2004 5:57 am
by d3ad1ysp0rk
You didn't end your <h2>, you just started a new one.
Posted: Mon Jun 07, 2004 7:18 am
by Wayne
Code: Select all
echo "<center><h2>$rowїusername]<h2><center><img width ='70' height='70' src="$rowїavatar]"><br \>\n";
<h2> is a block format in HTML, if the second <h2> is actually what you are trying to use as you close for the <h2> then it will not work, anything after an </H2> tag will appear on a new line, so either ...
Code: Select all
echo "<center><h2>$rowї'username']<img width ='70' height='70' src="$rowї'avatar']"></h2></center>\n";
or use a different HTML tag like <FONT> and specify the formatting that you want for the text.
Posted: Mon Jun 07, 2004 3:25 pm
by andre_c
... i'm curious, Feyd, why do you recommend using double quotes around html attributes?
Posted: Mon Jun 07, 2004 3:38 pm
by patrikG
It's XHTML standard and makes HTML XML-compliant. As is, HTML is simply badly formed XML.
Posted: Mon Jun 07, 2004 4:08 pm
by skeetley
Well said patrikG

Posted: Mon Jun 07, 2004 4:15 pm
by feyd
patrik hit it on the nose, exactly.
Posted: Mon Jun 07, 2004 10:59 pm
by andre_c
...hmm... when I validate my code in which i use mostly single quotes for attributes' values, it validates without any problems.
Are you sure that single quotes are not allowed on xhtml for attributes values?
Posted: Tue Jun 08, 2004 6:03 pm
by sk8erh4x0r
Well, that code works where the avatar is put inside the h and center tags but, now the avatar makes the username post at the bottom instead of the top of the avatar. Any help on how to align the username to the top of the avatar?
Posted: Wed Jun 09, 2004 12:18 am
by andre_c
can you post the updated code that you're using?
Posted: Wed Jun 09, 2004 12:39 am
by Illusionist
try this:
Code: Select all
echo "<center><h2>{$row['username']}<h2><center><img width ='70' height='70' src="{$row['avatar']}"><br \>\n";