Jump to content

[SOLVED] PHP connects to MySQL, but query won't work...


Neureo

Recommended Posts

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?

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.