Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
$servername = "address";
$username = "user";
$password = "pass";
$dbname = "eve";
try {
$conn = new PDO("mysql:host=".$servername.";dbname=".$dbname."", $username, $password);
// set the PDO error mode to exception
$sql = "INSERT INTO corp_assetlist (itemID, locationID, typeID, quantity, flag, singleton, rawQuantity)
VALUES (':val1', ':val2', ':val3', ':val4', ':val5', ':val6', ':val7')";
// use exec() because no results are returned
'val1' => 'itemID',
'val2' => 'locationID',
'val3' => 'typeID',
'val4' => 'quantity',
'val5' => 'flag',
'val6' => 'singleton',
'val7' => 'rawQuantity',
echo "New record created successfully";
catch(PDOException $e)
echo $sql . "<br>" . $e->getMessage();
$conn = null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.