Home Backend Development PHP Tutorial 帮忙看个php程序里用的SQL内联语句解决办法

帮忙看个php程序里用的SQL内联语句解决办法

Jun 13, 2016 pm 01:36 PM
pid price quot

帮忙看个php程序里用的SQL内联语句
以下是php程序代码,但调用不出任何内容,也无报错信息
$pid = $_GET['pid'];
// pid不为空,则调用记录
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()); //SQL语句在这里执行
$row = mysqli_fetch_array($result);
$item = $row[item];
$update = $row[update];
$price = $row[price];
$minOrder = $row[minOrder];
$imglink = $row[imglink];

以下是echo $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=4
mysql_error()也无报错,已确定问题就在红色所示的sql内联语句中,请大家帮忙看看

------解决方案--------------------
将你的sql语句拿到mysql 终端下执行一下看看是什么反应...
------解决方案--------------------
$result = mysqli_query($conn,$sql) or die("$sql
" . mysql_error());
这儿你弄错了。
echo mysqli_error($conn);
------解决方案--------------------
没有错误,也可能使没有符合条件的结果
------解决方案--------------------
首先你那这个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=4 去数据库执行 有无结果?
有结果那就是后面的出错,无结果那就是空
------解决方案--------------------
检查$pid所对应的mysql表字段的字符类型,如果是char,则需加 '
------解决方案--------------------

探讨
以下是php程序代码,但调用不出任何内容,也无报错信息
$pid = $_GET['pid'];
// pid不为空,则调用记录
if (!empty($pid)) {
$sql = "select pd.pid, pd.providerid, pd.item, pd.update, pd.price, pd.minOrder, pd.imglink, pv.ID, pv.company ……
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Fujifilm X-M5 price expectations rise as leaked selfie display adds complexity to the formerly affordable camera line Fujifilm X-M5 price expectations rise as leaked selfie display adds complexity to the formerly affordable camera line Sep 07, 2024 am 09:34 AM

Fujifilm fans were recently very excited at the prospect of the X-T50, since it presented a relaunch of the budget-oriented Fujifilm X-T30 II that had become quite popular in the sub-$1,000 APS-C category. Unfortunately, as the Fujifilm X-T50's launc

FiiO CP13 cassette player launches with transparent retro look FiiO CP13 cassette player launches with transparent retro look Jun 16, 2024 am 09:52 AM

TheFiiOCP13cassetteplayerwasannouncedinJanuary.Now,FiiOisexpandingitsportfoliowithtwonewmodels-onewitharedfrontandonewithatransparentfront.Thelatternotonlyperfectlymatchestheretrocharmoftheangulardesign,butalso

Klipsch unveils Flexus Core 300 flagship soundbar with 8K support, 12 speakers and room correction Klipsch unveils Flexus Core 300 flagship soundbar with 8K support, 12 speakers and room correction Sep 05, 2024 am 10:16 AM

The Klipsch Flexus Core 300 is the top model in the series and is positioned above the already available Flexus Core 200 in the company's soundbar line-up. According to Klipsch, this is the first soundbar in the world whose sound can be adapted to th

Light Phone 3 launches with 50% discount, monochrome OLED and minimalist design Light Phone 3 launches with 50% discount, monochrome OLED and minimalist design Jun 13, 2024 pm 10:18 PM

WhiletheLightPhone2from2018wasstillequippedwithaneconomicale-inkdisplay,theLightPhone3usesanOLEDdisplaythatcanonlydisplaygrayscale.Thereasonfortheswitchtothe3.92-inchOLEDpanelwithitsresolutionof1,240x1,080isth

How to display the pid in Win7 Task Manager? The editor will teach you how to display it. How to display the pid in Win7 Task Manager? The editor will teach you how to display it. Jan 11, 2024 pm 07:00 PM

Many friends may be unfamiliar with the pid identifier, and you can check it in the task manager. However, some users cannot find the PID identifier when they open the Task Manager. In fact, if the user wants to view the process PID identifier, he or she needs to set the relevant settings of the "Task Manager" to see it. The following editor will take the win7 system as an example. How to view the process PID identifier. The PID identifier is a unique sequential number automatically assigned by the Windows operating system to running programs. After the process is terminated, the PID is recycled by the system and may continue to be assigned to newly running programs. When users need to view the process, they will use the task Manager to check, so how to check the process PID identifier? Let me share it with you below

Deal | Tesla Model 3 Long Range AWD regains full $7,500 tax incentive, drops to below $40,000 Deal | Tesla Model 3 Long Range AWD regains full $7,500 tax incentive, drops to below $40,000 Jun 19, 2024 am 09:55 AM

Shortly after Tesla launched the Model 3 Highland refresh towards the end of last year, the US federal EV tax incentive rules changed, cutting the potential discount in half for eligible buyers because of Tesla's use of Chinese LFP cells in the new M

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Realme Pad 2 Lite: Affordable tablet launches with quad speakers, 90 Hz display and 15h battery life Realme Pad 2 Lite: Affordable tablet launches with quad speakers, 90 Hz display and 15h battery life Sep 14, 2024 am 06:28 AM

More than a year after the launch of the Realme Pad 2 the manufacturer presents the more affordable Realme Pad 2 Lite. The new model is slightly smaller, as the display shrinks from 11.5 inches to 10.95 inches, with the IPS panel achieving a resoluti

See all articles