PHP code with no output returned,please help!

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
ponyyune
Forum Newbie
Posts: 1
Joined: Mon Mar 14, 2011 2:10 am

PHP code with no output returned,please help!

Post by ponyyune »

<?php
mysql_connect ("localhost", "root","") or die ('Error : '.mysql_error());
mysql_select_db("keyword");

$question_text = $_POST['question_text'];

list($first_word) = explode(' ', $question_text);

$query ="SELECT c.field_name,t.category_name, d.domain_name FROM category_fields c, taxonomy_category t, taxonomy_domain d
WHERE c.category_Id = t.category_Id AND t.domain_Id = d.domain_Id
AND c.field_name = '$first_word'";

$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "Keyword :{$row['c.field_name']} <br>" .
"Category : {$row['t.category_name']} <br>" .
"Domain : {$row['d.domain_name']} <br><br>";
}
?>
The output i get did not return the result as stated in query.It displays only the table form by echo above.Is there anything wrong with my code ?

I have a database with 3 tables (category_fields,taxonomy_category,taxonomy_domain)
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: PHP code with no output returned,please help!

Post by cpetercarter »

I think that the problem is that $first_word is an array, not a string, so that the SQL query does not make sense. Try echoing $query to make sure that it says what you want it to say.
Post Reply