soycharliente Posted June 17, 2007 Share Posted June 17, 2007 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 More sharing options...
The Little Guy Posted June 17, 2007 Share Posted June 17, 2007 You have a spelling error $reslut = mysql_query($query) OR DIE ("Error: getNews()."); if ($result) { Link to comment https://forums.phpfreaks.com/topic/55893-solved-query-broken/#findComment-276105 Share on other sites More sharing options...
soycharliente Posted June 17, 2007 Author Share Posted June 17, 2007 Oh man. Thank you so much. Wow. I feel really retarded. Link to comment https://forums.phpfreaks.com/topic/55893-solved-query-broken/#findComment-276107 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.