Jump to content

[SOLVED] How do I troubleshoot this?


daebat

Recommended Posts

I have a form set up to submit to the database.  I am getting this error:

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 ''asdfasdf', '1', '1', '1', '1', '1', 'button.png', 'apma.jpg', 'akaishi_box.jpg'' at line 1

insert into productimages ('asdfasdf', '1', '1', '1', '1', '1', 'button.png', 'apma.jpg', 'akaishi_box.jpg', '3images.jpg')

 

I can provide the form code if you need that as well.

Link to comment
Share on other sites

The correct format for an INSERT statement is..

 

INSERT INTO table_name VALUES ('value1', 'value2', 'value3')

 

Bare in mind that if your not inserting all columns you will need to do this...

 

INSERT INTO table_name (column_one, column_2, column4) VALUES ('value1', 'value2', 'value3')

Link to comment
Share on other sites

this is what I have:

 

<?php
$con = mysql_connect("localhost", "theuser", "thepass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("my_database", $con);
$sql = "insert into productimages ('".mysql_real_escape_string($_POST['title'])."', '".mysql_real_escape_string($_POST['chungshi'])."', '".mysql_real_escape_string($_POST['stretchwalker'])."', '".mysql_real_escape_string($_POST['akaishi'])."', '".mysql_real_escape_string($_POST['bellamargiano'])."', '".mysql_real_escape_string($_POST['mbt'])."', '".mysql_real_escape_string($_POST['upjpg'])."', '".mysql_real_escape_string($_POST['uptiff'])."', '".mysql_real_escape_string($_POST['uppng'])."', '".mysql_real_escape_string($_POST['upthumb'])."')";
mysql_query($sql) or die(mysql_error()." <br /> $sql");


echo "The following information was entered into the database<br><br><br>";
echo "<b>Title:</b> $_POST[title]<br>";

echo "Thanks for taking the time to submit your information.";

mysql_close($con);

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.