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

WBOY
Release: 2016-06-13 10:17:12
Original
1102 people have browsed it

帮忙看个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 ……
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template