Page 1 of 1

help with php/sql

Posted: Thu Jun 12, 2008 5:25 am
by Monopoly
Well I'd like to select values from fields that are in rows with other 2 values

Code:

$sql="SELECT * FROM forum_question WHERE id='$id', forums_id='$forums_id'";
$result=mysql_query($sql);

After WHERE I used two conditions (matching id and forums_id)

But I get an error

How can I solve the problem?

Re: help with php/sql

Posted: Thu Jun 12, 2008 5:28 am
by aceconcepts
You need to replace the comma with AND:

Replace:

Code: Select all

 
$sql="SELECT * FROM forum_question WHERE id='$id', forums_id='$forums_id'";
 
With:

Code: Select all

 
$sql="SELECT * FROM forum_question WHERE id='$id' AND forums_id='$forums_id'";
 

Re: help with php/sql

Posted: Thu Jun 12, 2008 6:18 am
by superdezign
... Duplicate thread?

Re: help with php/sql

Posted: Thu Jun 12, 2008 10:55 am
by aceconcepts
naughty naughty - tut tut tut