Neureo Posted July 17, 2008 Share Posted July 17, 2008 Hey. I'm using this code: <?php $db = mysql_connect($dbhost, $dbuser, $dbpassword); mysql_select_db($dbdatabase, $db); $sql = "SELECT entries.*, categories.cat FROM entries, catories WHERE entries.cat_id = categories.id ORDER BY dateposted DESC LIMIT 1"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); ?> ...but when I run the code, I get this error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/blog/index.php on line 10 Everything is running smoothly, I tested the connection, etc... Anyone know why this is happening? Link to comment https://forums.phpfreaks.com/topic/115159-solved-php-connects-to-mysql-but-query-wont-work/ Share on other sites More sharing options...
cooldude832 Posted July 17, 2008 Share Posted July 17, 2008 maybe cause your query is failling. If you are debugging a query always write them like <?php $q = "Select * from `table"; $r = mysql_query($q) or die(mysql_error()."<br /><br />".$q); ?> Link to comment https://forums.phpfreaks.com/topic/115159-solved-php-connects-to-mysql-but-query-wont-work/#findComment-592170 Share on other sites More sharing options...
Neureo Posted July 17, 2008 Author Share Posted July 17, 2008 Hey, thanks. Turns out it was a simple misspelling... XP I'll always remember to put "die" after my queries. You're awesome. Link to comment https://forums.phpfreaks.com/topic/115159-solved-php-connects-to-mysql-but-query-wont-work/#findComment-592175 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.