Jump to content

[SOLVED] PHP/MySQL problem


Vineman

Recommended Posts

I'm having a problem getting info from my MySQL database. It's connecting fine and as far as I can tell it's set up just fine, but it keeps returning that there's no info despite the database having two entries.

The value retrieval:
[code=php:0]$newsQuery = mysql_query("SELECT * FROM news ORDER BY ID DESC limit 0,1");
if($newsQuery == NULL){
$title = "No news has been recorded.";
}
else if($newsQuery != NULL){
$n = mysql_fetch_array($newsQuery);
$title = $n["title"];
$subtitle = $n['subtitle'];
$body = $n["body"];
}[/code]


This is what the database looks like:
CREATE TABLE `news` (
  `ID` int(6) NOT NULL auto_increment,
  `IP` varchar(20) NOT NULL default '',
  `title` varchar(60) NOT NULL default '',
  `subtitle` varchar(60) NOT NULL default '',
  `body` text NOT NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;


How it's being used:
[code=php:0]<h2><? echo"$title";?></h2>
<p class="description"><? echo"$subtitle";?></p>
<p><? echo"$body";?></p>[/code]

Help :-\
Link to comment
https://forums.phpfreaks.com/topic/31740-solved-phpmysql-problem/
Share on other sites

Archived

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

×
×
  • Create New...

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.