php表单插入数据库报错 小白希望大神解答

不知道为啥老是报错,关乎php版本吗还是什么问题呢?请教大神

<form action="gllxsc.php" method="post" enctype="multipart/form-data" align="center">
    <p>数: <input type="text" name="qs" />列:026
    &nbsp;&nbsp;&nbsp;名称: <input type="text" name="lx" />列:哈哈哈
    &nbsp;&nbsp;&nbsp;?00: <input type="text" name="km" />&nbsp;&nbsp;&nbsp;列:开:任何人
    <input type="submit" class="btn" value="提交" />

<?php
$qs = $_POST["qs"];
    $lx = $_POST["lx"];
    $km = $_POST["km"];
$hostName = "127.0.0.1";
    $usrName = "sql";
    $passWord = "sql";
    $port = "3306";
    $dbname = "sql";
    $content = mysqli_connect($hostName, $userName, $passWord, $dbname, $port);
    mysqli_set_charset($content, 'utf-8');
    if ($content) {
        echo "连接成功=。=";
    } else {
        die("连接失败:" . mysqli_connect_error());
    }
    $sqlStr = "insret into sql(qs,lx,km)
                VALUES (' $qs','lx','km')";
    if (mysqli_query($content, $sqlStr)) {
        echo "插入数据成功";
    } else {
        echo "插入失败";
        }
    mysqli_close($content);
?>

目前报错

PHP Warning:  mysqli_connect():  in D:\wwwroot\www.xxxxxx\admin\gllxsc.php on line 10
PHP Warning:  mysqli_set_charset() expects parameter 1 to be mysqli, boolean given in D:\wwwroot\www.xxxxxxxxx\admin\gllxsc.php on line 11

1个回答

降级php版本, 添加utf-8编码

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!