PHP mySqli not updating table

后端 未结 1 1656
悲&欢浪女
悲&欢浪女 2021-01-29 13:26

I am trying to update the table but nothing is changing. The database name and fields are correct.



        
相关标签:
1条回答
  • 2021-01-29 14:08

    First, I suggest you read the prepared statements quickstart guide which would lead you to something like this...

    $stmt = $con->prepare('UPDATE pupils SET signin = ? WHERE forname = ?');
    $stmt->bind_param('ss', $newval, $forname);
    $stmt->execute();
    

    As an added bonus, you should set mysqli to throw exceptions on error so you don't have to check return values all the time. In your config.php file, before creating the connection, do this...

    mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
    $con = new mysqli(...); // or however you create $con
    

    and as mentioned in the comments, the php.ini file in your development environment should enable full error reporting with the following directives

    error_reporting = E_ALL
    display_errors = On
    

    To directly answer your question, you're missing an equals sign for the <select> elements name attribute. It should be

    <select class="form-control" name="name" id="name">
    
    0 讨论(0)
提交回复
热议问题