0

I'm sure this is a dumb question, but I'm somewhat new to hard coding queries into php files and I cannot figure out why I'm getting this error.

What I'm trying to do is add text input in a form into columns on a database table. Here's what I have:

form.php

<form action="submit_processor.php" method="post">
<h2>Add Auto Part</h2>
<h3>Part Name:</h3>
<input type="text" name="available_parts">
<h3>SKU:</h3>
<input type="text" name="partSKU">
<h3>Vehicle Make:</h3>
<input type="text" name="vehicle_make">
<h3>Vehicle Model:</h3>
<input type="text" name="vehicle_model">
<h3>Vehicle Year:</h3>
<input type="text" name="vehicle_year">
<br /><br />
<input type="submit">
</form>

submit_processor.php

<?php
//Connecting to sql db.
$connect = mysqli_connect("my host","my user","my password","my db");
//Sending form data to sql db.
mysqli_query($connect,"INSERT INTO auto_parts (available_parts, partSKU,     vehicle_make, vehicle_model, vehicle_year)
VALUES ('$_POST[available_parts]', '$_POST[partSKU]',     '$_POST[vehicle_make]', '$_POST[vehicle_model]', '$_POST[vehicle_year]')";
?>

Any help would be great!

  • Please provide a link. When I posted the question, I looked at every suggestion and none were about my specific issue. – Jameyson MacDonald Nov 26 '15 at 15:29
  • This one `http://stackoverflow.com/questions/12961248/php-string-parse-error-with-necessary-semicolon-after-variable` is about your error. Unexpected `;` because it is expecting you to close the `mysqli_query` function first. You are open to SQL injections with this. – chris85 Nov 26 '15 at 15:32

1 Answers1

2

Missing ) at last

mysqli_query($connect,"INSERT INTO auto_parts (available_parts, partSKU,     vehicle_make, vehicle_model, vehicle_year)
VALUES ('$_POST[available_parts]', "
    . "'$_POST[partSKU]',"
    . "'$_POST[vehicle_make]', "
    . "'$_POST[vehicle_model]', '$_POST[vehicle_year]')");
                                                        ^//missing )
Niranjan N Raju
  • 12,047
  • 4
  • 22
  • 41