Jump to content

[SOLVED] Query broken


soycharliente

Recommended Posts

I've written queries hundreds of times. Can someone please figure out what I can't.

Table has 40 rows. Hostname, username, password, and dbname are all correct.

I keep hitting the else statement and getting nothing.

 

<?php

function dbconnect() {
$hostname = "******";
$username = "******";
$password = "******";
$dbname   = "******";

mysql_connect($hostname, $username, $password) OR DIE ("Unable to connect.");
mysql_select_db($dbname);
}

function dbclose() {
mysql_close();
}

function getNews() {
dbconnect();
$query = "SELECT * FROM news ORDER BY id DESC LIMIT 5";
$reslut = mysql_query($query) OR DIE ("Error: getNews().");
if ($result) {
	while ($r = mysql_fetch_array($result)) {
		$post = $r["post"];
		$date = $r["date"];
		$ymd = explode("-", $date);
		$postDate = date("F j, Y", mktime(0, 0, 0, $ymd[2], $ymd[0], $ymd[1]));
			echo "<div class=\"content\">
				<div class=\"newsdate\">$postDate</div>
				<p>$post</p>
			</div>\n";
	}
} else {
	echo "There are currently no updates about the chapter.";
}
dbclose();
}
?>

Link to comment
https://forums.phpfreaks.com/topic/55893-solved-query-broken/
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.