Jhodges11 Jhodges11 - 1 year ago 115
SQL Question

PHP MSQL server syntax error

I get this error when trying to get this details page for a project to work. Its for school and I dont really understand PHP that well yet.
"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 '' at line 1"

Here is the code for that page.

mysqli_select_db($conn, $dbname);
$recordID = $_GET['recordID'];
$query_Shoe_Details = "SELECT * FROM Products WHERE Shoe_Brand = $recordID";
$Shoe_Details = mysqli_query($conn, $query_Shoe_Details) or die(mysqli_error(($conn)));
$row_Shoe_Details= mysqli_fetch_assoc($Shoe_Details);
$totalRows_Shoe_Details = mysqli_num_rows($Shoe_Details);

<!DOCTYPE html>
<title>details</title><?php include 'connection.php';?>
<p>Product Name: <?php echo $row_Shoe_Details['Product_Name']; ?></p>
<p><img src=
<p>Description: <?php echo $row_Shoe_Details['Product_Description']; ?></p>
<p>Price: $<?php echo $row_Shoe_Details['Product_Price']; ?></p><?php

Answer Source

change your query as, use single quotes

 $query_Shoe_Details = "SELECT * FROM Products WHERE Shoe_Brand = '$recordID'";

Also remove this <?php include 'connection.php';?>, No need to include again