Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
208 views
in Technique[技术] by (71.8m points)

php - PHP:mysqli INSERT INTO语句不起作用(PHP: mysqli INSERT INTO statement is not working)

My php code for registration does not insert values to the database.

(我的php代码未将值插入数据库。)

I tried different ways but it is still not working.

(我尝试了不同的方法,但仍然无法正常工作。)

Here is the code:

(这是代码:)

Database connection:

(数据库连接:)

<?php $link=mysqli_connect("localhost", "root", "");
  mysqli_select_db($link, "dataadventurers");
 ?>

My registration form PHP code:

(我的注册表格PHP代码:)

<?php
include "connection.php"; ?>
            <?php
              if(isset($_POST['submit1'])){
                  $firstname = $_POST['first_name'];
                  $lastname = $_POST['last_name'];
                  $middle = $_POST['middle_initial'];
                  $idnum = $_POST['id_number'];
                  $email = $_POST['email_add'];
                  $pass = $_POST['password'];
                  $bday = $_POST['birthdate'];
                  $course = $_POST['course'];
                  $year = $_POST['year'];


                  mysqli_query($link, "insert into member_registration values('', '$firstname', '$lastname'
                  , '$middle', '$idnum', '$email', '$pass', '$bday', '$course', '$year')");


           ?>
  ask by nergal darski translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

您必须告诉MySQL您想在其中插入数据的列。

mysqli_query($link, "INSERT INTO table(col1, col2, col3...) VALUES(val1, val2, val3...));


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...