“PHP -Einsatz in MySQL” Code-Antworten

Fügen Sie PHP MySQL ein

<?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', '[email protected]')";

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

$conn->close();
?>
Jolly Jellyfish

PHP -Einsatz in MySQL

<?php

$vote_yes=$_GET['yes'];
$vote_no=$_GET['no'];
$time=time();

$servername = "localhost";
$username = "bob";
$password = "123456";
$db = "classDB";

$conn = new mysqli($servername, $username, $password, $db);

if ($conn->connect_error){
	die("Connection failed: ". $conn->connect_error);
}

$sql = "insert into votes(yes,no,time)values('$vote_yes','$vote_no','$time')"; 

if ($conn->query($sql) === TRUE) {
	echo "Votes Recorded: Yes = ".$vote_yes." No = ".$vote_no." Time = ".$time;
} else {
	echo "Error: ".$sql."<br>".$conn->error;
}

$conn->close();

?>
Mary Rose J. Jamile

In PHP MYQSL einfügen

$sql = "INSERT INTO database_table('arg1, 'arg2', ...) VALUES ('value1,
value2, ...)'";
Armandres

Ähnliche Antworten wie “PHP -Einsatz in MySQL”

Fragen ähnlich wie “PHP -Einsatz in MySQL”

Weitere verwandte Antworten zu “PHP -Einsatz in MySQL” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen