$select = mysql_query("SELECT AID, PID, articles.Description, Title, Name FROM articles, title, authors " .
" WHERE TID=title.ID AND AuthorID=authors.ID AND SubID=$id ");
if (!$select) {
echo("<P>Error retrieving category from database!<BR>".
"Error: " . mysql_error());
exit();
}
$select = mysql_query("SELECT AID, PID, articles.Description, Title, Name FROM articles, title, authors WHERE TID=title.ID AND AuthorID=authors.ID AND SubID=$id");
Try typing that query in PHPMyAdmin, and see if any results comes up.
You might have to use:
SELECT AID, PID, articles.Description, Title, Name FROM articles, title, authors WHERE articles.TID=title.ID AND articles.AuthorID=authors.ID AND articles.SubID=$id
Notice in the WHERE bit, I define the table's name in both the column names, you might have to do that when there's 2+ tables.
Also, try putting the WHERE queries in the same order as the FROM queries. eg:
FROM articles, title, authors WHERE articles.tid=title.id AND articles.authorID=authors.ID
Not:
FROM articles, title, authors WHERE articles.authorID=authors.ID AND articles.tid=title.id
mysql_query("SELECT AID, PID, articles.Description, Title, Name FROM articles, title, authors WHERE TID=title.ID AND AuthorID=authors.ID AND SubID=$id");
MySQL said: You have an error in your SQL syntax near 'mysql_query("SELECT AID, PID, articles.Description, Title, Name FROM articles, t' at line 1
OKay, done that. In PHPMyAdmin is get an error saying that:
SQL-query:
SELECT articles.AID, articles.PID, articles.Description, title.Title, authors.Name FROM articles, title, authors WHERE articles.TID=title.ID AND articles.AuthorID=authors.ID AND articles.SubID=$id
MySQL said: Unknown column '$id' in 'where clause'
$text = "SELECT articles.AID, articles.PID, articles.Description, title.Title, authors.Name FROM articles, title, authors WHERE articles.TID=title.ID AND articles.AuthorID=authors.ID AND articles.SubID=$id";
$select = mysql_query($text);
if (!$select) {
echo("<P>Error retrieving category from database!<BR>".
"Error: " . mysql_error());
exit();
}
Bookmarks