“PHP Insertar en MySQL” Código de respuesta

insertar php mysql

<?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 Insertar en 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

insertar en php myqsl

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

Respuestas similares a “PHP Insertar en MySQL”

Preguntas similares a “PHP Insertar en MySQL”

Más respuestas relacionadas con “PHP Insertar en MySQL” en PHP

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código