使用php函数插入数据mysql数据库

时间:2016-11-25 11:31:55

标签: php

function inseartinto() 
{
    $DEL_LOG_REP = $connection->prepare("DELETE FROM test WHERE itemname='111'")$DEL_LOG_REP->execute()$DEL_LOG_REP->close()return $DEL_LOG_REP
}

2 个答案:

答案 0 :(得分:0)

This is short tutorails on connection in insert query into php...
<?php
    $servername = "localhost";
    $username = "username";
    $password = "password";
    $dbname = "myDB";

    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    } 

    $sql = "INSERT INTO MyGuests (firstname, lastname, email)
    VALUES ('John', 'Doe', 'john@example.com')";

    if ($conn->query($sql) === TRUE) {
        echo "New record created successfully";
    } else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }

    $conn->close();
    ?>

为了更好地理解......来到http://www.w3schools.com/php/default.asp

答案 1 :(得分:0)

你想写什么代码男人.. 这不是一个有效的代码,只是不插入,但也适用于连接.. 你可以通过@ Sasa.D提到W3School.com ...它为您提供从基础知识到专业知识的知识。