Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 调用变量无效_Php - Fatal编程技术网

Php 调用变量无效

Php 调用变量无效,php,Php,我甚至不确定这些是否叫做变量。但我试图用一种与平时不同的方式从数据库中调用信息 这是不起作用的: id = mysql_real_escape_string($_GET['id'], $con); /* once the file is imported, the variables set above will become available to it */ $select = ("SELECT * FROM shirts WHERE id = '$id' "); $result =

我甚至不确定这些是否叫做变量。但我试图用一种与平时不同的方式从数据库中调用信息

这是不起作用的:

id = mysql_real_escape_string($_GET['id'], $con);
/* once the file is imported, the variables set above will become available to it */

 $select = ("SELECT * FROM shirts WHERE id = '$id' ");
 $result = mysql_query($select) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$id = $id;
$thumb = $row['thumb'];
$title = $row['title'];
$paypal = $row['paypal'];
$tags = $row['tags'];
$price = $row['price'];
}
?>
<div class="storeWrap">
<div class="thumbBox">
<a href="<?php $thumb ?>"rel="lightbox[<?php $id ?>]" title="<?php $title ?>"><img   src="<?php $thumb ?>" width="340px"></a>
 </div>
 <div class="descMain">
 <h2 align="left"><?php $title ?></h2><br />
 <div align="right"><?php $paypal ?> </div>
</div>

</div>

关于为什么我的第一段代码不起作用,有什么建议吗?页面已加载,但我没有收到任何错误,也没有看到我试图加载的衬衫。

将“$”放在id之前,使id成为变量。PHP中的变量以“$”符号开头:

$id = mysql_real_escape_string($_GET['id'], $con);
这里有一个关于PHP中变量的链接:

http://php.net/manual/en/language.variables.php

将“$”放在id之前,使id成为变量。PHP中的变量以“$”符号开头:

$id = mysql_real_escape_string($_GET['id'], $con);
这里有一个关于PHP中变量的链接:

http://php.net/manual/en/language.variables.php
别忘了在此处添加$:

希望这有帮助

别忘了在此处添加$

希望这有帮助

id=mysql\u real\u escape\u string$\u GET['id',$con; 这是打字错误?你错过了美元

此外,您需要回显结果,应该像

id=mysql\u real\u escape\u string$\u GET['id'],$con; 这是打字错误?你错过了美元


除此之外,你需要回显结果,就像是打字错误一样。写代码时要注意。在id前面加上“$”

这是打字错误。写代码时要注意。将“$”放在id之前