i'm a beginner in php.Can someone help me with getting the output of the query below ?And is there any problem with my code that i'm not getting the right output.I got this Resource id #3 as output and at the bottom bar it says "error on page"
$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 = '".mysql_escape_string($first_word[0])."'";
I want to get the field_name,category_name and domain_name from different tables where the id'开发者_高级运维s of them match as in the query,thanks in adv!
First off, you should be using PDO and prepared queries to secure your application. At least use mysql_real_escape_string(). As it stands right now, you can be subjected to SQL injection attacks.
Second, you can't just output the query result resource. You need to do something like mysql_fetch_assoc() and output its result.
$qStuff=mysql_query(YOUR_QUERY_GOES_HERE);
while ($results=mysql_fetch_assoc($qStuff)) {
print_r($results);
}
Again though, use PDO instead. There is a great tutorial on the above link.
精彩评论