gpt4 book ai didi

php - mysql 插入问题

转载 作者:行者123 更新时间:2023-11-29 14:20:22 25 4
gpt4 key购买 nike

我正在构建一个网站来学习编码,并尝试构建“声明您的业务”类型的应用程序。因此,在 Claim.php 上,我们进行搜索并列出所有企业,每个企业都有一个指向 addclaimedbiz.php?id=$example_business_id 的链接。然后在 addclaimedbiz.php 上我使用以下代码:

<?

$biz_id = mysql_real_escape_string($_GET['id']);
error_reporting(E_ALL);
$auth = $_COOKIE["auth"];
if ($auth != "1"){
header("Location: ./signin.php");
}
$firstname = $_COOKIE['firstname'];
$id = $_COOKIE['id'];
$fname = ucwords($_COOKIE['firstname']);
$lname = ucwords($_COOKIE['lastname']);
$email = $_COOKIE['email'];
$city = ucwords($_COOKIE['city']);
$biz = ucwords($_COOKIE['biz']); // This is Line 14



if (!empty($biz)){
header("Location: ./claim.php?alreadyclaimed=1");
}
else{
include("./config.php");
$result = mysql_query("INSERT INTO users (biz) VALUES ('$biz_id')") or die(mysql_error());
setcookie("biz", "", time()-3600); // This is Line 24
setcookie("biz", $biz_id, time()+60*60*24*30); // This is Line 25
header("Location: ./biz.php"); // This is Line 26
}

?>

基本上,它所做的就是获取从claim.php传递给它的业务ID,(然后所有cookie都是为了确保没有未经授权的人访问该页面,但我认为它与问题,但我将其保留在那里以防万一),然后将 id 添加到表中的 biz 字段,users。然后在最后它重定向到 biz.php。

不幸的是,当我运行此代码时,出现错误:

Notice: Undefined index: biz in addclaimedbiz.php on line 14

Warning: Cannot modify header information - headers already sent by (output started at addclaimedbiz.php:14) in addclaimedbiz.php on line 24

Warning: Cannot modify header information - headers already sent by (output started at addclaimedbiz.php:14) in addclaimedbiz.php on line 25

Warning: Cannot modify header information - headers already sent by (output started at addclaimedbiz.php:14) in addclaimedbiz.php on line 26

上面的代码中包含有错误的行的行号。

我的代码出了什么问题?

感谢您的帮助!

最佳答案

将第 14 行更改为:$biz = $biz_id;

编辑:抱歉,我从来没有注意到你正在学习 PHP。

关于php - mysql 插入问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11837127/

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