mysql 插入的问题


Issue with mysql insert

我正在建立一个学习编码的网站,并正在尝试构建一个声明您的业务类型的应用程序。因此,在声明.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
}
?>

基本上,这是要做的是从索赔.php中获取传递给它的业务 ID,(然后所有 cookie 都是为了确保没有人未经授权进入该页面,但我认为它与问题无关,但我把它留在那里以防万一),然后将 id 添加到表中的商业字段中, 用户。然后在最后它重定向到 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;

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