doupiai5597 2013-09-12 03:02
浏览 14

mySQL插入

I have the following code where:

Client and Project are varchar, Date is a Date and Quantity is an interger. I am wanting to insert them into a new table called Billings.

When I run the code, the date cames back with 0/0/0000, Client is CLient, Project is Project.

It appears I am not understanding the ' or " or . but I can not find any good examples on the web that will help me determine the correct code. Any help with the correct code is appreciated. Thanks in advance.

The code is:

$strSQLInsert = "insert into Billings (Client, Project, Date, Quantity) values ('Client', 'Project', Date, Quantity)";

Thanks

  • 写回答

3条回答 默认 最新

  • duanmajing9332 2013-09-12 03:08
    关注

    You are not sending the values, instead you are sending the strings 'Client', 'Project' etc.

    You have to use

    INSERT INTO Billings (Client, Project, Date, Quantity)
    values( client_value, project_value, date_value, quantity_value)
    

    So while building the query string use the variables that hold the values -

    $strSQLInsert = "insert into Billings (Client, Project, Date, Quantity) values ('$Client','$Project','$Date',$Quantity);"
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度