i have a sql problem :\

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mekha
Forum Contributor
Posts: 112
Joined: Sat Mar 31, 2012 6:50 am

i have a sql problem :\

Post by mekha »

[text]
mysql_query("SET NAMES 'utf8'");
$sql431=mysql_query("SELECT * FROM categories,pages WHERE categories.Id AND pages.thecategory =".$arts_id);
$resulttitle=mysql_fetch_assoc($sql431);
[/text]

i have a page with a
.php?cat=here the $arts_id
and i have :
[text]if(isset($_GET['cat']))
$arts_id = $_GET['cat'];[/text]
but i cant get the title of the category
--
all the names of tables and fields are right!
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: i have a sql problem :\

Post by Celauran »

Code: Select all

WHERE categories.Id
is not a valid WHERE clause.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: i have a sql problem :\

Post by mikosiko »

Celauran wrote:is not a valid WHERE clause.
I will say ... "In your code context probably is incomplete and with not meaning at all" .... valid?... syntactically it is
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: i have a sql problem :\

Post by Celauran »

Yes, you've explained it better.
mekha
Forum Contributor
Posts: 112
Joined: Sat Mar 31, 2012 6:50 am

Re: i have a sql problem :\

Post by mekha »

ok i changed it to
[text]"SELECT * FROM categories LEFT JOIN pages ON categories.Id = pages.thecategory"[/text]
i get the first category name...but the anothers...i get the same title of the first category
Post Reply