dongtuan1980 2012-05-08 12:27
浏览 10
已采纳

Php插入添加空白条目

I'm trying to add new entries to an sql database using php, i can add a new entry, but it adds 2 blank lines to the database. The query i use is

$query = "INSERT INTO dbo.Products (Name,Id,Price) VALUES    ('$NewName','$NewId','$Price')";
$result = sqlsrv_query($conn3, $query);

any ideas why it'd do that?

  • 写回答

2条回答 默认 最新

  • doubing3662 2012-05-08 12:37
    关注

    Try using VALUE instead of VALUES to make sure only a single entry is added.

    This should limit the insertion to a single item only. It then depends if you are keen to debug the issue more thoroughly to see what was the problem.

    Lastly, it never hurts to check if the variables are all properly escaped.

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

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思