Jump to content


Photo

echoing data from a mysql table


  • Please log in to reply
2 replies to this topic

#1 lssjg

lssjg
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 13 May 2006 - 03:51 AM

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...

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';


it's something like that...

then in the actual news page


<?

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']"; }

?>


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.


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


and when i divided the line in 2
$news['topic'] <br />
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


#2 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 13 May 2006 - 04:01 AM

Do this:

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

#3 lssjg

lssjg
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 13 May 2006 - 04:10 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users