为什么?解析错误语法错误,在C:\ wamp…在行250上发生意外的T_STRING

问题描述 投票:-2回答:2

以下代码可以正常工作,直到我向DB添加了5个新字段。错误在于INSERT行上的mysqli_stmt_execute ( $stmt_2 );部分奇怪的是,使用相同参数的UPDATE部分没有错误。我已经读了相同的行了几个小时,但看不到该解析错误的原因。

$bdd = mysqli_connect('localhost', 'root', '', 'webpage');                                              
if   ( mysqli_connect_errno() ) { printf("Connect failed: %s\n", mysqli_connect_error());  exit(); }    

$num      = NULL ;                  
$oferta   = $_POST['oferta'];
$titulo   = $_POST['titulo'];
$desd     = NULL ;
$hast     = NULL ;
$descuen  = NULL ;
$tipo_hab = NULL ;
$dias_min = NULL ;
mysqli_set_charset ( $bdd , 'utf8' );

$stmt_1 = mysqli_stmt_init($bdd);
$query = "SELECT num FROM promo"; //.......................... counting offers 
if ( mysqli_stmt_prepare($stmt_1, $query)) 
{                       
    mysqli_stmt_execute($stmt_1);                       
    mysqli_stmt_store_result($stmt_1);
    $number_of_offers = mysqli_stmt_num_rows($stmt_1);                      
    mysqli_stmt_close($stmt_1);
}               
    else  { echo ' no select'; exit; } 

if ( $number_of_offers < 1 )       // ...................... if offers < 1 : INSERT (used on the 1st time when there is no record )
{       
    $stmt_2 = mysqli_stmt_init($bdd);
    if ( mysqli_stmt_prepare ( $stmt_2, "INSERT INTO promo 
    ( num  ,  date   , oferta , titulo , desd , hast , descuen , tipo_hab , dias_min ) Values(?,?,?,?,?,?,?,?,?)"))
    {           
    mysqli_stmt_bind_param( $stmt_2 ,"issssssss",$num,$date,$oferta,$titulo,$desd,$hast,$descuen,$tipo_hab,$dias_min)
    mysqli_stmt_execute ( $stmt_2 ); 
    mysqli_stmt_close ( $stmt_2 );
    mysqli_close($bdd);     
    }   
    else  { echo ' no insert'; exit; }      
}
else //................................................... if offers not < 1 : UPDATE
{ 

    $stmt_3 = mysqli_stmt_init($bdd);           
    if ( mysqli_stmt_prepare ( $stmt_3, "UPDATE promo SET  num= ? , date= ? , oferta= ? , titulo= ? , desd= ? , hast= ? , descuen= ? , tipo_hab= ? , dias_min= ?  " ))
        {   
        mysqli_stmt_bind_param( $stmt_3 ,"issssssss", $num , $date, $oferta , $titulo, $desd , $hast , $descuen , $tipo_hab , $dias_min  );
        mysqli_stmt_execute ( $stmt_3 ); 
        mysqli_stmt_close ( $stmt_3 );                              
        }   
        else  { echo ' no update'; exit; } 
}               
php mysqli
2个回答
5
投票

在行尾之前缺少分号!


0
投票

出现错误:mysqli_stmt_bind_param($ stmt,“ sss”,$ username,$ email,$ hashedPwd);

错误代码:解析错误:语法错误,C:\ xampp \ htdocs \ SBSignup \ includes \ signup.inc.php在第60行出现意外的'mysqli_stmt_bind_param'(T_STRING),]

© www.soinside.com 2019 - 2024. All rights reserved.