-3

The following code worked fine until I added 5 new fields to the DB. The error is in the INSERT part, on line mysqli_stmt_execute ( $stmt_2 ); Oddly, there is no error with the UPDATE part, which uses the same parameters. I've been reading those same lines for hours now and I do not see the reason of that parse error.

$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; } 
}               
Your Common Sense
  • 152,517
  • 33
  • 193
  • 313
SunnyOne
  • 197
  • 3
  • 15

1 Answers1

6

Missed a semicolon at the end of the line before!

Josh Harrison
  • 5,662
  • 1
  • 24
  • 43