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?

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.

You can try

$sql = "INSERT INTO dbo.Products (Name,Id,Price) VALUES('%s','%d','%f')";
$result = sqlsrv_query($conn3, sprintf($sql,mysql_real_escape_string($NewName),$NewId,$Price));