anybody can solve my php syntax problem?

$sql = "SELECT entries.*, catagories.cat FROM entries, catagories
WHERE entries.cat_id = catagories.id
ORDER BY dateposted DESC
LIMIT 1;";

Is this everything ? What error do you get ?

Close...

Is this everything ? What error do you get ?

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY dateposted' at line 1 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY dateposted' at line 1

You are missing your join functionality (not sure what where clause you want to use or which table dateposted belongs to):

$sql = "SELECT entries.*, catagories.cat FROM entries INNER JOIN catagories
ON entries.cat_id = catagories.id
ORDER BY entries.dateposted DESC
LIMIT 1;";

You need to specify which table `dateposted` belongs to. My guess is that it is used in both.

$sql = "SELECT entries.*, catagories.cat 
        FROM entries, catagories
        WHERE entries.cat_id = catagories.id
        ORDER BY entries.dateposted DESC
        LIMIT 1";

@simplepixie: Both queries do the same thing.

Sorry, it is just the way I code so I automatically put it in and you are correct I could have just amended the ORDER BY

Okay ;) not sure if you knew.

shailu.thakre, i dont know if your using mulitple accounts for this solution, DONT DOUBLE POST. This was in MySQL forum, but under a different name.

$sql = "SELECT entries.*, catagories.cat
FROM entries, catagories
WHERE entries.cat_id = catagories.id
ORDER BY dateposted DESC
LIMIT 1;";

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.