I've looked everywhere and I can't find anything helpful. I'm trying to create an online sheep game, and to begin playing the game, the user needs to select the color and name of their first sheep. When submitted, it inserts the data into my MySQL database successfully, but displays this error:
Error: 1 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1' at line 1
Here's my syntax to connect to the database:
<?php
$conn = mysqli_connect("localhost","root","","flyingfeetranch");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
Here's my form and what I use to insert:
<form name="properties" method="POST">
<input type="radio" name="color" value="white" selected="selected">White<br>
Name: <input type="text" name="name" value=" "/>
<input type="submit" name="submitname" value="Submit"/>
</form>
</div>
<?php
if(isset($_POST['submitname']))
{
$Color = $_POST['color'];
$Name = $_POST['name'];
$Age = "12";
$sql = mysqli_query($conn, "INSERT INTO babydolls (name, color, age)VALUES ('$Name', '$Color', '$Age')");
if($conn->query($sql) === TRUE)
{
echo "New record created successfully";
}
else
{
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
?>