检查textarea不工作php

vltsax25  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(295)

-我只想找一个post用户
-我有两个表(users,post),我不知道makesystempost//编码html表单和textarea

<form method="POST" autocomplete="off" action="">  
            <textarea name="none" class="textarea" placeholder="Quelle est votre question ?"></textarea>

                <select>
                    <option value="filiére" selected="1">Filiére : Accueil</option>
                    <option value="smp">smpc</option>
                    <option value="smp">smia</option>
                    <option value="smp">svt</option>
                    <option value="smp">smp</option>
                    <option value="smp">smc</option>
                    <option value="smp">sma</option>
                    <option value="smp">smi</option>
                    <option value="smp">svi</option>

                </select>

                <select>
                    <option value="accueil" selected="1">Semestre : Accueil</option>
                    <option value="s1">s1</option>
                    <option value="s2">s2</option>
                    <option value="s3">s3</option>
                    <option value="s4">s4</option>
                    <option value="s5">s5</option>
                    <option value="s6">s6</option>                                              
                </select>   

    <button class="btn-ajouter" type="submit" name="ajouter" value="ajouter">ajouter</button>                           
    </form> 
 //code php 
   $userId = $_SESSION['user_id']; 
   if(isset($_POST['ajouter']))
     {
      $post = $_POST['none'];

     $stmt=$connect->prepare('INSERT INTO 
                publications(id_auteur,date_post,post) VALUES(?,NOW(),?) ');
     $stmt->execute(array(

     ':id_auteur' => $userId,
     ':post'      => $post

            ));
         }

代码。。。致命错误pdo:未捕获的pdoexception:sqlstate[hy093]:无效的参数号:未定义参数

fumotvh3

fumotvh31#

使用命名占位符

$stmt=$connect->prepare('INSERT INTO 
                publications(id_auteur,date_post,post) VALUES( :id_auteur, NOW(),:post ) ');

    $stmt->execute(array(
        ':id_auteur' => $userId,
        ':post'      => $post
    ));

? 作为占位符

$stmt=$connect->prepare('INSERT INTO 
                publications(id_auteur,date_post,post) VALUES( ?, NOW(),? ) ');

    $stmt->execute(array(
        1      => $userId,
        2      => $post
    ));

相关问题