Search
 
SCRIPT & CODE EXAMPLE
 

PHP

insert 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', 'john@example.com')";

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

$conn->close();
?>
Comment

php insert to 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();

?>
Comment

insert into php myqsl

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

PREVIOUS NEXT
Code Example
Php ::  
Php :: login page in php 
Php :: woocommerce update_status 
Php ::  
:: laravel order by before group by 
:: array to comma separated string php 
Php :: php injection 
Php :: add custom shortcode in contact form 7 
Php :: middleware command in laravel 
Php :: laravel belongs to 
Php ::  
:: php include multiple files at once 
Php :: php globals 
Php :: laravel eloquent get all where in 
Php ::  
:: static class methods php 
Php ::  
Php :: laravel array to string conversion 
Php ::  
:: replace last two characters string php 
Php :: simple pagination in php 
Php :: what is lang in laravel 
::  
Php :: how to install phpmyadmin on windows 10 
:: timezones php 
Php ::  
Php :: php variable inside mysql query 
:: in php how to check md5 password 
:: create resource controller in admin folder laravel 
::  
ADD CONTENT
Topic
Content
Source link
Name
3+5 =