解析错误:语法错误,在第7行中意外的“INTO”(T_STRING)。

时间:2021-09-05 22:45:49

I get this error when running this code, im using it to add a specific filter to a database.

在运行这段代码时,我得到了这个错误,我使用它向数据库添加了一个特定的过滤器。

       <?php

//Connect to Databaseeee
    $con=mysqli_connect("127.0.0.1","root","Toom13371!","filter_database_test");
    if (mysqli_connect_errno($con))
        {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
        }

        // sql insertationerino
        $sql = INSERT INTO filterlist ('type_code', 'connector_type', 'construction_type', 'author', 'estimate_lead_time', 'last_update', 'confidence_level', 'passtype', 'start_passband', 'stop_passband', 'low_stopband', 'high_stopband', 'low_passband', 'high_passband', 'start_stopband', 'stop_stopband') VALUES ('".$_POST['type_code']."', '".$_POST['connector_type']."', '".$_POST['construction_type']."', '".$_POST['author']."', '".$_POST['estimate_lead_time']."', '".$_POST['last_update']."', '".$_POST['confidence_level']."', '".$_POST['passtype']."', '".$_POST['start_passband']."', '".$_POST['stop_passband`']."', '".$_POST['low_stopband']."', '".$_POST['high_stopband']."', '".$_POST['low_passband']."', '".$_POST['high_passband']."', '".$_POST['start_stopband']."', '".$_POST['start_stopband']."');
            if (!mysqli_query($con,$sql))
            {
            die('Error: ' . mysqli_error($con));
            }
        echo "1 Filter Added";
        mysqli_close($con);
        ?>

The full error is:

完整的错误是:

Parse error: syntax error, unexpected 'INTO' (T_STRING) in C:\xampp\htdocs\html\addprocess.php on line 7

解析错误:语法错误,在C:\xampp\htdocs\html\addprocess中意外“进入”(T_STRING)。php在第7行

3 个解决方案

#1


0  

First of all you need to learn basic of php.

首先,您需要学习php的基础知识。

  • Any string should be inside quotation.
  • 任何字符串都应该在引号内。
  • You'll need to escape the values before you put them into query by using mysqli_real_escape_string()
  • 在使用mysqli_real_escape_string()将它们放入查询之前,需要先转义这些值

try like this:

试试这样:

$sql = "INSERT INTO filterlist (`type_code`, `connector_type`, `construction_type`, 
`author`, `estimate_lead_time`, `last_update`, `confidence_level`, `passtype`, 
 `start_passband`, `stop_passband`, `low_stopband`, `high_stopband`, `low_passband`, 
 `high_passband`, `start_stopband`, `stop_stopband`) VALUES 
 ('".mysqli_real_escape_string($con,$_POST['type_code'])."', 
 '".mysqli_real_escape_string($con,$_POST['connector_type'])."', 
 '".mysqli_real_escape_string($con,$_POST['construction_type'])."', 
 '".mysqli_real_escape_string($con,$_POST['author'])."',  
 '".mysqli_real_escape_string($con,$_POST['estimate_lead_time'])."', 
 '".mysqli_real_escape_string($con,$_POST['last_update'])."', 
 '".mysqli_real_escape_string($con,$_POST['confidence_level'])."', 
 '".mysqli_real_escape_string($con,$_POST['passtype'])."', 
 '".mysqli_real_escape_string($con,$_POST['start_passband'])."', 
 '".mysqli_real_escape_string($con,$_POST['stop_passband`'])."', 
 '".mysqli_real_escape_string($con,$_POST['low_stopband'])."', 
 '".mysqli_real_escape_string($con,$_POST['high_stopband'])."', 
 '".mysqli_real_escape_string($con,$_POST['low_passband'])."', 
 '".mysqli_real_escape_string($con,$_POST['high_passband'])."', 
 '".mysqli_real_escape_string($con,$_POST['start_stopband'])."', 
 '".mysqli_real_escape_string($con,$_POST['start_stopband'])."')";


if (!mysqli_query($con,$sql)){
            die('Error: ' . mysqli_error($con));
   }
  echo "1 Filter Added";
  mysqli_close($con);

#2


0  

Replace your $sql statement to:

将$sql语句替换为:

$sql = "INSERT INTO filterlist ('type_code', 'connector_type', 'construction_type', 'author', 'estimate_lead_time', 'last_update', 'confidence_level', 'passtype', 'start_passband', 'stop_passband', 'low_stopband', 'high_stopband', 'low_passband', 'high_passband', 'start_stopband', 'stop_stopband') VALUES ('".$_POST['type_code']."', '".$_POST['connector_type']."', '".$_POST['construction_type']."', '".$_POST['author']."', '".$_POST['estimate_lead_time']."', '".$_POST['last_update']."', '".$_POST['confidence_level']."', '".$_POST['passtype']."', '".$_POST['start_passband']."', '".$_POST['stop_passband`']."', '".$_POST['low_stopband']."', '".$_POST['high_stopband']."', '".$_POST['low_passband']."', '".$_POST['high_passband']."', '".$_POST['start_stopband']."', '".$_POST['start_stopband']."')";

#3


0  

In your $sql = INSERT INTO statement if you look at the end, you have "');, this should be "'");. Also your sql query needs to be a string, you cannot have it as a function call. So put the whole query inside a string. So it should be:

在$sql = INSERT INTO语句中,如果您查看末尾,就有“'”;这应该是“'”;您的sql查询也需要是一个字符串,不能将其作为函数调用。因此,将整个查询放在一个字符串中。所以它应该是:

$sql = "INSERT INTO filterlist ('type_code', 'connector_type', 'construction_type', 'author', 'estimate_lead_time', 'last_update', 'confidence_level', 'passtype', 'start_passband', 'stop_passband', 'low_stopband', 'high_stopband', 'low_passband', 'high_passband', 'start_stopband', 'stop_stopband') VALUES ('".$_POST['type_code']."', '".$_POST['connector_type']."', '".$_POST['construction_type']."', '".$_POST['author']."', '".$_POST['estimate_lead_time']."', '".$_POST['last_update']."', '".$_POST['confidence_level']."', '".$_POST['passtype']."', '".$_POST['start_passband']."', '".$_POST['stop_passband`']."', '".$_POST['low_stopband']."', '".$_POST['high_stopband']."', '".$_POST['low_passband']."', '".$_POST['high_passband']."', '".$_POST['start_stopband']."', '".$_POST['start_stopband']."');";

#1


0  

First of all you need to learn basic of php.

首先,您需要学习php的基础知识。

  • Any string should be inside quotation.
  • 任何字符串都应该在引号内。
  • You'll need to escape the values before you put them into query by using mysqli_real_escape_string()
  • 在使用mysqli_real_escape_string()将它们放入查询之前,需要先转义这些值

try like this:

试试这样:

$sql = "INSERT INTO filterlist (`type_code`, `connector_type`, `construction_type`, 
`author`, `estimate_lead_time`, `last_update`, `confidence_level`, `passtype`, 
 `start_passband`, `stop_passband`, `low_stopband`, `high_stopband`, `low_passband`, 
 `high_passband`, `start_stopband`, `stop_stopband`) VALUES 
 ('".mysqli_real_escape_string($con,$_POST['type_code'])."', 
 '".mysqli_real_escape_string($con,$_POST['connector_type'])."', 
 '".mysqli_real_escape_string($con,$_POST['construction_type'])."', 
 '".mysqli_real_escape_string($con,$_POST['author'])."',  
 '".mysqli_real_escape_string($con,$_POST['estimate_lead_time'])."', 
 '".mysqli_real_escape_string($con,$_POST['last_update'])."', 
 '".mysqli_real_escape_string($con,$_POST['confidence_level'])."', 
 '".mysqli_real_escape_string($con,$_POST['passtype'])."', 
 '".mysqli_real_escape_string($con,$_POST['start_passband'])."', 
 '".mysqli_real_escape_string($con,$_POST['stop_passband`'])."', 
 '".mysqli_real_escape_string($con,$_POST['low_stopband'])."', 
 '".mysqli_real_escape_string($con,$_POST['high_stopband'])."', 
 '".mysqli_real_escape_string($con,$_POST['low_passband'])."', 
 '".mysqli_real_escape_string($con,$_POST['high_passband'])."', 
 '".mysqli_real_escape_string($con,$_POST['start_stopband'])."', 
 '".mysqli_real_escape_string($con,$_POST['start_stopband'])."')";


if (!mysqli_query($con,$sql)){
            die('Error: ' . mysqli_error($con));
   }
  echo "1 Filter Added";
  mysqli_close($con);

#2


0  

Replace your $sql statement to:

将$sql语句替换为:

$sql = "INSERT INTO filterlist ('type_code', 'connector_type', 'construction_type', 'author', 'estimate_lead_time', 'last_update', 'confidence_level', 'passtype', 'start_passband', 'stop_passband', 'low_stopband', 'high_stopband', 'low_passband', 'high_passband', 'start_stopband', 'stop_stopband') VALUES ('".$_POST['type_code']."', '".$_POST['connector_type']."', '".$_POST['construction_type']."', '".$_POST['author']."', '".$_POST['estimate_lead_time']."', '".$_POST['last_update']."', '".$_POST['confidence_level']."', '".$_POST['passtype']."', '".$_POST['start_passband']."', '".$_POST['stop_passband`']."', '".$_POST['low_stopband']."', '".$_POST['high_stopband']."', '".$_POST['low_passband']."', '".$_POST['high_passband']."', '".$_POST['start_stopband']."', '".$_POST['start_stopband']."')";

#3


0  

In your $sql = INSERT INTO statement if you look at the end, you have "');, this should be "'");. Also your sql query needs to be a string, you cannot have it as a function call. So put the whole query inside a string. So it should be:

在$sql = INSERT INTO语句中,如果您查看末尾,就有“'”;这应该是“'”;您的sql查询也需要是一个字符串,不能将其作为函数调用。因此,将整个查询放在一个字符串中。所以它应该是:

$sql = "INSERT INTO filterlist ('type_code', 'connector_type', 'construction_type', 'author', 'estimate_lead_time', 'last_update', 'confidence_level', 'passtype', 'start_passband', 'stop_passband', 'low_stopband', 'high_stopband', 'low_passband', 'high_passband', 'start_stopband', 'stop_stopband') VALUES ('".$_POST['type_code']."', '".$_POST['connector_type']."', '".$_POST['construction_type']."', '".$_POST['author']."', '".$_POST['estimate_lead_time']."', '".$_POST['last_update']."', '".$_POST['confidence_level']."', '".$_POST['passtype']."', '".$_POST['start_passband']."', '".$_POST['stop_passband`']."', '".$_POST['low_stopband']."', '".$_POST['high_stopband']."', '".$_POST['low_passband']."', '".$_POST['high_passband']."', '".$_POST['start_stopband']."', '".$_POST['start_stopband']."');";