How to solve SQL inline statements used in a php program-php Tutorial

Source: Internet
Author: User
The following SQL inline statements used in a php program are the php program code, but no content is called and no error message is reported. $ pid $ _ GET [pid]; if the pid is not empty, the call record if (! Empty ($ pid) {$ SQL & quot; selectpd. pid, pd. providerid, pd. item, pd. update, pd. price, pd. mi helps you see SQL inline statements used in a php program
The following is the php program code, but no content is called and no error message is reported.
$ Pid = $ _ GET ['pid'];
// If the pid is not empty, the call record
If (! Empty ($ pid )){
$ SQL = "select pd. pid, pd. providerid, pd. item, pd. update, pd. price, pd. minOrder, pd. imglink, pv. ID, pv. company from price_db as pd ".
"Inner join providers as pv ".
"On (pd. providerid = pv. ID) where pd. pid = $ pid ";
Require_once ('../conn. php ');
Echo $ SQL;
$ Result = mysqli_query ($ conn, $ SQL) or die ("$ SQL
". Mysql_error (); // the SQL statement is executed here
$ Row = mysqli_fetch_array ($ result );
$ Item = $ row [item];
$ Update = $ row [update];
$ Price = $ row [price];
$ MinOrder = $ row [minOrder];
$ Imglink = $ row [imglink];

The following are echo $ SQL statements.
Select pd. pid, pd. providerid, pd. item, pd. update, pd. price, pd. minOrder, pd. imglink, pv. ID, pv. company from price_db as pd inner join providers as pv on (pd. providerid = pv. ID) where pd. pid = 4
No error is reported for mysql_error (). If the problem is fixed, the SQL inline statement shown in red is displayed. please take a look.

------ Solution --------------------
Take your SQL statement to the mysql terminal and execute it to see what the response is...
------ Solution --------------------
$ Result = mysqli_query ($ conn, $ SQL) or die ("$ SQL
". Mysql_error ());
You have made a mistake here.
Echo mysqli_error ($ conn );
------ Solution --------------------
No errors may cause no matching results.
------ Solution --------------------
First, you can select the SQL pd. pid, pd. providerid, pd. item, pd. update, pd. price, pd. minOrder, pd. imglink, pv. ID, pv. company from price_db as pd inner join providers as pv on (pd. providerid = pv. ID) where pd. pid = 4 do I have any results when I go to the database?
If there is a result, it is the following error. if there is no result, it is null.
------ Solution --------------------
Check the character type of the mysql table field corresponding to $ pid. if it is char, add'
------ Solution --------------------
Discussion
The following is the php program code, but no content is called and no error message is reported.
$ Pid = $ _ GET ['pid'];
// If the pid is not empty, the call record
If (! Empty ($ pid )){
$ SQL = "select pd. pid, pd. providerid, pd. item, pd. update, pd. price, pd. minOrder, pd. imglink, pv. ID, pv. company ......

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.