Hello I have this code that won't work. I've been bugging with it for about an hour and can't seem to find any errors, I don't know what it is. Maybe someone could help me here.
Inserting script :
<?php error_reporting(E_ALL); ini_set('display_errors',1);
require('connect.php');
$sql = "INSERT INTO products (name, description, price, url, category, artwork) VALUES ('john', 'john', 'john', 'john', 'john', 'john')";
if ($link->query($sql)) {
echo "<script>
alert('Data was added.');
window.location.href='dashboard.php';
</script>";
}
else {
echo "<script>
alert('Data was not added.');
window.location.href='dashboard.php';
</script>";
}
?>
I am trying to add data to my database, but it just won't add the data that i've given it.
Here is my connect script :
<?php
try {
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$link = new PDO("mysql:host=$dbhost;dbname=dbtesttest;",$dbuser,$dbpass);
} catch (PDOException $e) {
echo "Failed :" . $e->getMessage() . "\n";
}
?>
Anyone got a clue what I am doing wrong? Besides using alerts in php. It doesn't give me any errors, I have a database made with the actual attributes. I need help :(