我得到一個語法錯誤,當我運行我的腳本解析錯誤:語法錯誤,意外'
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\Program Files (x86).................\get.php on line 24
我不能看到什麼是錯,誰能幫我呢?
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "database;
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname) ;
// Check connection
if ($conn->connect_error)
{
die('Connection failed: ' . $conn->connect_error) ;
}
else
{
$product1 = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT) ;
$query = 'SELECT price FROM forms WHERE name=' . $product1 . ' ' ;
$res = mysql_query($query) ;
if (mysql_num_rows($res) > 0)
{
$result = mysql_fecth_assoc($res) ;
echo json_encode($result['price']);
}
else
{
echo json_encode('no results') ;
}
}
?>