dpb42021
2014-08-14 17:23
浏览 62
已采纳

从PHP到MySQL的DateTime [关闭]

I've been trying to solve the issue below by looking at similar posts but nothing worked.

$roster_id = mysqli_real_escape_string($con, $_POST['player-id']);
$current_bid = mysqli_real_escape_string($con, $_POST['player-salary']);
$winning_gm_id = mysqli_real_escape_string($con, $_POST['gm-id']);
$now = mysqli_real_escape_string($con, date('Y-m-d H:i:s'));
$duration = mysqli_real_escape_string($con,2);
$sql_insert_faa = "INSERT INTO free_agent_auction (roster_id, current_bid, winning_gm_id, date_posted, faa_times_id) VALUES ('$roster_id','$current_bid,'$winning_gm_id','$now','$duration')";

Error: 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 '1','2014-08-14 17:16:47','2')' at line 1

图片转代码服务由CSDN问答提供 功能建议

我一直试图通过查看类似的帖子来解决下面的问题,但没有任何效果。 \ n

  $ roster_id = mysqli_real_escape_string($ con,$ _POST ['player-id']); 
 $ current_bid = mysqli_real_escape_string($ con,$ _POST ['player-salary']); \  n $ winner_gm_id = mysqli_real_escape_string($ con,$ _POST ['gm-id']); 
 $ now = mysqli_real_escape_string($ con,date('Ymd H:i:s')); 
 $ duration = mysqli_real_escape_string(  $ con,2); 
 $ sql_insert_faa =“INSERT INTO free_agent_auction(roster_id,current_bid,winning_gm_id,date_posted,faa_times_id)VALUES('$ roster_id','$ current_bid,'$ winning_gm_id','$ now','$ duration  ')“; 
   
 
 

错误:您的SQL语法中有错误; 检查与MySQL服务器版本对应的手册,以便在第1行“1”,“2014-08-14 17:16:47”,“2”)附近使用正确的语法

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • dtz33344 2014-08-14 17:24
    最佳回答

    Missing a ' after $current_bid

    $sql_insert_faa = "INSERT INTO free_agent_auction (roster_id, current_bid, winning_gm_id, date_posted, faa_times_id) VALUES ('$roster_id','$current_bid','$winning_gm_id','$now','$duration')";
    
    评论
    解决 无用
    打赏 举报