Hi there, I am in learning php
I have this code to add records to MySQL database in a table named pc, getting the following error, please help:
Subject creation failed.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘desc,images,alt-images) VALUES (‘gta’,‘blablabla’,‘GTA.jpg’,‘GTA4’)’ at line 1
here are a php code
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php
$title_name = $_POST['title_name'];
$desc = $_POST['desc'];
$images = $_POST['images'];
$alt_images = $_POST['alt_images'];
?>
<?php
$query = "INSERT INTO pc (title,desc,images,alt-images) VALUES ('$title_name','$desc','$images','$alt_images')";
$result = mysql_query($query, $connection);
if ($result) {
// Success!
redirect_to("content.php");
} else {
// Display error message.
echo "<p>Subject creation failed.</p>";
echo "<p>" . mysql_error() . "</p>";
}
?>
<?php mysql_close($connection); ?>
Thanks in advance.