我正在使用php 7.3.x进行编码,并且库是正确的。 我正在尝试连接数据库。看起来不错,但是当我进行查询时,查询中的句子WHERE引发错误:
<?php
$server_name = 'SERVEREXAMPLE\\SQLEXPRESS';
$database_name = array('Database' => 'EXAMPLE_database');
$con = sqlsrv_connect($server_name, $database_name);
$query1 = sqlsrv_query($con, 'SELECT * FROM TABLE_EXAMPLE', array(), array('Scrollable' => SQLSRV_CURSOR_FORWARD)); // -> this works return results
$query2 = sqlsrv_query($con, 'SELECT * FROM TABLE_EXAMPLE WHERE name_product = "'. $name product .'"', array(), array('Scrollable' => SQLSRV_CURSOR_FORWARD)); // -> This isn't work return false
// -> The name product is correctly wroted and exist, tables, database and server too
?>
在查询选项中,我尝试使用SQLSRV_CURSOR_FORWARD
和SQLSRV_CURSOR_KEYSET
。
此代码中看不到任何错误。
我在做什么错?
答案 0 :(得分:0)
答案是:
WHERE (column = '.$product.')
在()
句子后添加WHERE