Please help solve the problem of code that outputs content from the database-php Tutorial

Source: Internet
Author: User
The project table contains three Pnumber Topic summary fields, I want to click the Topic hyperlink after sorting by Pnumber on a page to enter the second page and output the content in the summary field. However, the message will always be displayed when you click the next page.

Parse error: syntax error, unexpected ''(T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C: \ xampp \ htdocs \ final \ page2.PHP on line 8

How should I change my teaching requirements?

// Page1.php
$ Link = mysql_connect ("localhost", "root ","");
Mysql_select_db ("final ");
Mysql_query ("set names gb2312 ");
$ Row = mysql_query ("SELECT * FROM project order by 'pnumber' ASC ");
Echo"







";Echo" ";While ($ rs = mysql_fetch_array ($ row )){ Echo'';Echo" ";Echo" ";Echo"
No. Question
$ Rs [Pnumber]";
Echo ''. $ rs ['topic '].'';
Echo"
";

}
?>


// Page2.php
$ Link = mysql_connect ("localhost", "root ","");
Mysql_select_db ("final ");
Mysql_query ("set names gb2312 ");
$ Pnumber = $ _ POST ['pnumber'];
$ A = "select * from 'project' where 'pnumber' = '$ pnumber '";
$ Row = mysql_query ($ );
Echo "$ rs ['summary ']";
?>


Reply to discussion (solution)

Echo "$ rs ['summary ']"; -- the error is returned.
However, you have written an error in some areas. The correction is as follows:
$ A = "select * from 'project' where Pnumber = '$ pnumber'"; // either side of the Pnumber field is not enclosed by a quotation mark (') or is not added
$ Row = mysql_query ($ );
$ Rs = mysql_fetch_assoc ($ row); // you can leave it empty.
Echo $ rs ['summary '];

The code itself is correct!
It is estimated that some unprintable characters are at work.

Because there is no replacement for you, I will only
Warning: mysql_fetch_array () expects parameter 1 to be resource, boolean given in D: \ AMP \ web \ ide_tmp.php on line 8

Only indicates that the query failed.

Echo "$ rs ['summary ']"; -- the error is returned.
However, you have written an error in some areas. The correction is as follows:
$ A = "select * from 'project' where Pnumber = '$ pnumber'"; // either side of the Pnumber field is not enclosed by a quotation mark (') or is not added
$ Row = mysql_query ($ );
$ Rs = mysql_fetch_assoc ($ row); // you can leave it empty.
Echo $ rs ['summary '];

Well, I made some changes on this basis and finally succeeded. thank you ~~~

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.