开发者

Calling variable is not working [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordina开发者_运维问答rily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

Im not even sure if these are called variables. But I am trying to call information from the database a different way than I usually do.

This is what is not working:

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>

Any suggestions on why my first block of code doesnt work? The page loads but I do not get any errors and I do not see the shirt I am trying to load.


Don't forget to add a $ here:

$id = mysql_real_escape_string($_GET['id'], $con);

Hope this helps!


id = mysql_real_escape_string($_GET['id'], $con); This is typo? You missed the $.

Besides, you need echo the result, should like <?php echo $title ?>


Put '$' before "id" to make "id" a variable. Variables in PHP starts with '$' sign:

$id = mysql_real_escape_string($_GET['id'], $con);

Here's a link about variables in PHP:

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


It's typo. Be attentive while writing code. Put '$' before "id"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜