Jump to content

Archived

This topic is now archived and is closed to further replies.

lssjg

echoing data from a mysql table

Recommended Posts

Hey,
i'm currently creating a site... and i have nearly finished the member system... so i am now doing the news syetem. Only problem, i can't get the news out.

In the mysql table...

[code]CREATE TABLE `news` (
`newsid` int( 25 ) NOT NULL AUTO_INCREMENT ,
`author` varchar( 25 ) NOT NULL default '',
`topic` text NOT NULL ,
`news` text NOT NULL ,
`date` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY ( `newsid` )
) ENGINE = MYISAM DEFAULT CHARSET = latin1 COMMENT = 'News System';[/code]


it's something like that...

then in the actual news page


[code]<?

include 'include/config.php';

$query = mysql_query('SELECT * FROM news');

while($news = mysql_fetch_array($query)) {
echo "Title: $news['topic'] <br />
Author: $news['author'] <br />
Date: $news['date'] <br />
$news['news']"; }

?>[/code]


I am getting the following error


Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in E:\Websites\Server\www\site\site\news.php on line 8


Obviously this is not going to be the actual thing... but before i format it... i want to get the coding done.


Can someone please tell me what is wrong...


P.S. the mysql stuff works... i checked in phpmyadmin and i even added a test row through phpmyadmin.

But i still get the above error.


[code] echo "Title: $news['topic'] <br />[/code] is line 8


and when i divided the line in 2 [code]$news['topic'] <br />[/code] this part ended up being the problem part


If anyone could help me.... sometime soon... it would be extremely helpfull........


Until then i'm kinda stuck

Share this post


Link to post
Share on other sites
Do this:

echo "Title: {$news['topic']} <br />
Author: {$news['author']} <br />
Date: {$news['date']} <br />
{$news['news']}";

Share this post


Link to post
Share on other sites
Ok... doing that.....


and it works on both FF and IE.... thanks so much....

it works..... thank-you so very much.... veyr happy [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]


thanks,

cya

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.