dtu11716 2015-07-12 06:14
浏览 51
已采纳

使用出价项列出用户名 - PHP

I'm fairly new to PHP and I'm trying to make a simple auction website. I think I've run into my first problem.

What I'm trying to do is let a registered user add an item to the auction. I can do this just fine. However, I also need to keep track of the user that put the item up for bidding. I thought I could get the accountid by inserting the accountid from the current session into my table, but I keep getting an error saying accountid is an unknown column in my field list.

Here is the code where I create the table.

 $sql = "CREATE TABLE biditems (
    itemid INT(100) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    accountid INT(100),
    biditem VARCHAR(30) NOT NULL,
    biddesc tinytext
    )";

And to add the items.

 $accountid=$_SESSION['accountid'];
    $item=$_POST['item'];
    $description=$_POST['description'];

    $sql= "INSERT INTO biditems (accountid, biditem, biddesc) VALUES
    ('$accountid', '$item', '$description')";
  • 写回答

2条回答 默认 最新

  • dongyanjing5975 2015-07-12 06:30
    关注

    Your query looks fine. I have also tested it. Did you double check that the structure of your table is correct?

    If you can insert a row via phpMyAdmin or the MySQL Workbench try this and afterwards run a select query like

    $rows = "SELECT * FROM biditems";
    
    while ($row = mysql_fetch_array($rows)) {
        var_dump($row);
    }
    

    Something like this just to make sure.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答