当我运行这段代码时-6ren">
gpt4 book ai didi

php - 通过表单 Cookie 和 GET

转载 作者:行者123 更新时间:2023-12-01 00:49:09 25 4
gpt4 key购买 nike

我正在使用 $_GET 函数在整个表单中传递数据库字段。但是,当我尝试从数据库中提取信息时遇到了一个绊脚石:

<?php
$prodname=$_GET["q"];
?>

<h3>Product Name: <u><?php echo $prodname; ?></u></h3><br />
<?php
$con = mysql_connect("localhost","cl49-vogalcms","vogalcms");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

$prodname=$row['prodname'];
$catagory=$row['catagory'];

@mysql_select_db("cl49-XXX",$con)or die('Unable to select database ln 60:'.mysql_error());
$result=mysql_query("SELECT * FROM products WHERE prodname=$prodname")or die('ln 61 :'.mysql_error());
$cnt=$_COOKIE["count"];


setcookie("user",$myid,time()+10000);
mysql_close($con);
?>

<form name="newad" method="post" enctype="multipart/form-data" action="drtsavepic.php?q=<?php echo"$prodname"; ?>"> <br> <Br>
<input type="file" name="image">
<input name="Submit" type="submit" value="Upload image">

</form>

当我运行这段代码时,出现以下错误

ln 61 :You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

谁能阐明这个问题?

最佳答案

尝试替换此 mysql_query("SELECT * FROM products WHERE prodname=$prodname")

mysql_query("SELECT * FROM products WHERE prodname='".$prodname."'")

关于php - 通过表单 Cookie 和 GET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17969567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com