news script?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

Joe wrote:Yes Illusionist i did actually see that code and i tried it. The only problem is that it worked far worse than the original.
... I really don't believe that...
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Try this:

Code: Select all

<?php
	$link = mysql_connect("???", "???", "???"); 
	if ( !@mysql_select_db("???") )
	{
		die("couldnt connect " . mysql_error()); 
	}

	$sql = "SELECT * FROM news ORDER BY ID"; 
	if ( !($result = @mysql_query($sql)) )
	{
		die("<p>Sorry, there was a problem: " . mysql_error() ."</p>");
	}

	while ( $row = mysql_fetch_array($result)  )
	{
		
		echo "<img src='news.gif' border=1>"; 
		echo "<br><u><b>.:" . $row['headline'] . ":.</U></b> posted by " . $row['username'] . "<br>"; 
		echo $row['mainnews']."<br>"; 
		echo "<hr color='white'>"; 
	} 

	mysql_close($link); 

?>
It looked like in your code you sort of changed the value of $row midstream. See if the code above helps.
Post Reply