Page 3 of 4

Posted: Wed May 28, 2003 7:24 pm
by Gappa

Code: Select all

<table border"1"><?php
$db = mysql_connect("localhost", "Gappa", " "); 
mysql_select_db("Gappa",$db); 
$date_formats = array('d/m/y', 'd/m/Y', 'd/m/Y H:i:s', 'D d-M-y', 'D d-M-Y', 'D d-M-Y H:i:s', 'l d F Y', 'l d F Y H:i:s');

$query = 'SELECT topic_title, FROM_UNIXTIME(topic_time,"%W the %D of %M %r") AS Topic_Date, post_text, username FROM phpbb_topics RIGHT JOIN phpbb_posts_text ON topic_first_post_id=post_id RIGHT JOIN phpbb_users ON topic_poster=user_id WHERE forum_id=6 ORDER BY topic_time DESC'; 
$result = mysql_query($query, $db) or die ($query .': '.mysql_error()); 

while($row = mysql_fetch_assoc($result)) 
{ 
   echo $row['topic_title'];
   echo " posted by ";
   echo $row['username'];
   echo " at ";
   echo $row['topic_time'], '<br/>';
   echo $row ['post_text'];
}

?></table>
Ok.. so got rid of some of the pointless code i think... still getting errors.

Parse error: parse error, unexpected T_STRING in /data/hosted/Gappa/test3.php on line 1

Posted: Wed May 28, 2003 8:13 pm
by Gappa
Sorry its not line 1... its line 11

Parse error: parse error, unexpected T_STRING in /data/hosted/Gappa/test3.php on line 11

Posted: Wed May 28, 2003 9:25 pm
by jason
Are you sure that's test3.php?

Also, it would be good to tell us which line is line 11, because with the text wrapping and all, I was at first thinking while($row = mysql_fetch_assoc($result)) was line 11.

P.S. Use the PHP button, it's there for a reason. =)

Posted: Wed May 28, 2003 9:28 pm
by Gappa
I think this is line 11

Code: Select all

   echo $row&#1111;'topic_title'];
and yes im sure the above code is test3.php ...

I know this is gonna be some stupid little coding error... well i hope

Posted: Thu May 29, 2003 6:13 am
by volka
what happens if you use

Code: Select all

echo "$row[topic_title] posted by $row[username] at $row[topic_time] <br/> $row[post_text]";
as loop-body? (ugly but just to test...)

Posted: Thu May 29, 2003 6:45 am
by jason
The only reason I ask is that I ran the script, and I didn't get a parse error anywhere. Are you sure you uploaded the script?

Posted: Thu May 29, 2003 9:53 am
by volka
me neither.
But there was another topic that ran into the same problem. Can't find it anymore and can't remember the outcome :?

Posted: Fri May 30, 2003 12:34 am
by Gappa
Ok this code works... kinda ungly out come but it technically works

Code: Select all

<table border"1"><?php
$db = mysql_connect("localhost", "Gappa", "xocunino"); 
mysql_select_db("Gappa",$db); 
$date_formats = array('d/m/y', 'd/m/Y', 'd/m/Y H:i:s', 'D d-M-y', 'D d-M-Y', 'D d-M-Y H:i:s', 'l d F Y', 'l d F Y H:i:s');

$query = 'SELECT topic_title, FROM_UNIXTIME(topic_time,"%W the %D of %M %r") AS Topic_Date, post_text, username FROM phpbb_topics RIGHT JOIN phpbb_posts_text ON topic_first_post_id=post_id RIGHT JOIN phpbb_users ON topic_poster=user_id WHERE forum_id=6 ORDER BY topic_time DESC'; 
$result = mysql_query($query, $db) or die ($query .': '.mysql_error()); 

while($row = mysql_fetch_assoc($result)) 
{ 
echo "$row[topic_title] posted by $row[username] at $row[topic_time] <br/> $row[post_text]";
}

?></table>
Now i been fulling around with adding html tags like ><b><FONT FACE=Arial SIZE=-1 COLOR=#FF9900
> but I dont know where to add them, everytime I do add them it changes my out put to just give me topic_title and nothing else...

Sooo was wondering how do I add such tags... just to make everything look pretty :)

Posted: Fri May 30, 2003 12:41 am
by Jim
If you're trying to output HTML tags within <?php ?> tags, use the "echo" command to output your code.

i.e.-

echo "<a href=\"haha.html\">HAHA!</a>";

/ i.e ;)

Posted: Fri May 30, 2003 1:52 am
by Gappa

Code: Select all

<HTML>
<table border"1"><?php
$db = mysql_connect("localhost", "Gappa", " "); 
mysql_select_db("Gappa",$db); 
$date_formats = array('d/m/y', 'd/m/Y', 'd/m/Y H:i:s', 'D d-M-y', 'D d-M-Y', 'D d-M-Y H:i:s', 'l d F Y', 'l d F Y H:i:s');

$query = 'SELECT topic_title, FROM_UNIXTIME(topic_time,"%W the %D of %M %r") AS Topic_Date, post_text, username FROM phpbb_topics RIGHT JOIN phpbb_posts_text ON topic_first_post_id=post_id RIGHT JOIN phpbb_users ON topic_poster=user_id WHERE forum_id=6 ORDER BY topic_time DESC'; 
$result = mysql_query($query, $db) or die ($query .': '.mysql_error()); 

while($row = mysql_fetch_assoc($result)) 
{ 
echo "<b><FONT FACE=Arial SIZE=-1 COLOR=#FF9900>";
echo "$row[topic_title]</b>";
echo "<FONT SIZE=-2 COLOR=#666666 posted by $row[username]";
echo " at $row[topic_time]<br/>";
echo "<FONT SIZE=-1 COLOR=#FFFFFF $row[post_text]";
echo "<br/><br/>";
}

?></table>
</HTML>
OK think this is right... but its not working.. still only displaying the topic_title and nothing else.

see here > http://www.hostultra.com/~Gappa/test3.php

what have i done wrong?

Posted: Fri May 30, 2003 2:50 am
by volka
echo "<FONT SIZE=-2 COLOR=#666666 posted by $row[username]";
you didn't end the font open-tag, so posted, by and the value of $row[username]
try

Code: Select all

<?php
...
echo "<b><FONT FACE=Arial SIZE=-1 COLOR=#FF9900>";
echo "$row[topic_title]</FONT></b>";
echo "<FONT SIZE=-2 COLOR=#666666> posted by $row[username]";
echo " at $row[topic_time]</FONT><br/>";
echo "<FONT SIZE=-1 COLOR=#FFFFFF> $row[post_text]</FONT>";
echo "<br/><br/>";
...
?>
and just a style suggestion

Code: Select all

<html>
	<head>
		<style type="text/css">
			body { background-color: darkblue; }
			fieldset { color: white; font-size: small; }
			legend { color: #FF9900;}
			fieldset span { color: silver; font-size: x-small; display: block}
		</style>
	</head>
	<body>
<?php
	...
	while($row = mysql_fetch_assoc($result))
	{
?>
		<fieldset>
			<legend><?php echo $row["topic_title"]; ?></legend>
			<span>
				posted by <?php echo $row["username"]; ?>
			</span>
			<?php echo $row["post_text"]; ?>
		</fieldset>
<?php
	}
?>
	</body>
</html>
(only a suggestion. Yes, I like fieldsets ;) )

Posted: Fri May 30, 2003 4:11 am
by Gappa

Code: Select all

<html> 
   <head> 
   </head> 
   <body>
<?php
$db = mysql_connect("localhost", "Gappa", "xocunino"); 
mysql_select_db("Gappa",$db); 
$date_formats = array('d/m/y', 'd/m/Y', 'd/m/Y H:i:s', 'D d-M-y', 'D d-M-Y', 'D d-M-Y H:i:s', 'l d F Y', 'l d F Y H:i:s');

$query = 'SELECT topic_title, FROM_UNIXTIME(topic_time,"%W the %D of %M %r") AS Topic_Date, post_text, username FROM phpbb_topics RIGHT JOIN phpbb_posts_text ON topic_first_post_id=post_id RIGHT JOIN phpbb_users ON topic_poster=user_id WHERE forum_id=6 ORDER BY topic_time DESC'; 
$result = mysql_query($query, $db) or die ($query .': '.mysql_error()); 

while($row = mysql_fetch_assoc($result)) 
   { 
echo "<b><FONT FACE=Arial SIZE=-1 COLOR=#FF9900>"; 
echo "$row[topic_title]</FONT></b>"; 
echo "<FONT SIZE=-2 COLOR=#666666> posted by $row[username]"; 
echo " at $row[topic_time]</FONT><br/>"; 
echo "<FONT FACE=Arail SIZE=-1 COLOR=#000000> $row[post_text]</FONT>"; 
echo "<br/><br/>";   } 
?> 
   </body> 
</html>
Hehe styles nice man, but i'll work on that after i get a baisc layout to work... this in general is working apart from the topic_time is no longer working! eeeekkk!!! 8O any suggestions!?

Posted: Sat May 31, 2003 1:30 am
by Gappa
Every one think the above should be working???

Its just refusing to give me the date!!!...

Posted: Sun Jun 01, 2003 4:03 am
by Gappa
Ok got the time thing worked out... had to change from topic_time to topic_date...

now any way with getting the comments kinda thing going (link to the forum topic)... im getting an error on line 18... which is.

Code: Select all

echo "<a href="http://www.hostultra/~Gappa/phpBB2/viewtopic.php?t=$row[topic_id]">Read more</a>";
Hmmm problem?

Parse error: parse error, expecting `','' or `';'' in /data/hosted/Gappa/test3.php on line 18

Posted: Sun Jun 01, 2003 4:08 am
by twigletmac
Have a read of:
http://www.php.net/manual/en/language.types.string.php

You need to escape those double quotes in the HTML otherwise PHP thinks you've ended the string and then put a bunch of random characters it doesn't understand after it - you can see the difference in the syntax colouring of the code you posted and this below:

Code: Select all

echo "<a href="http://www.hostultra/~Gappa/phpBB2/viewtopic.php?t=$row[topic_id]">Read more</a>";
Mac