Why is it always warning:mysql_fetch_object (): supplied argument is not a valid MySQL Resul

Source: Internet
Author: User
Why is it always

Warning:mysql_fetch_object (): supplied argument is not a valid MySQL result resource in D:\AppServ1\www\forum\index.php O N Line 46


Code:
$id = $row ["id"];
$res =mysql_query ("SELECT count (*) as total from reply where topic id= ' $id '");
$r = Mysql_fetch_object ($res);
Guys, help me.


Reply to discussion (solution)

Topic id= ' $id '//It's wrong here.

How to change it?

You put SQL statements inside MySQL to run, see if there's any results

The last $id with a hyphen, don't write it directly into SQL.

Table structure and requirements are not posted out, how to change only you know.

Topic something.

$res = mysql_query ("SELECT count (*) as total from reply where id=". $id);

Topic is another table.

Topic is another table that has to use a connection query or a multi-table compliant query

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.