Page 1 of 1

i have a sql problem :\

Posted: Thu Apr 26, 2012 12:29 pm
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!

Re: i have a sql problem :\

Posted: Thu Apr 26, 2012 12:43 pm
by Celauran

Code: Select all

WHERE categories.Id
is not a valid WHERE clause.

Re: i have a sql problem :\

Posted: Thu Apr 26, 2012 1:03 pm
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

Re: i have a sql problem :\

Posted: Thu Apr 26, 2012 1:04 pm
by Celauran
Yes, you've explained it better.

Re: i have a sql problem :\

Posted: Thu Apr 26, 2012 1:17 pm
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