Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

MySql Error Message

New Here ,
May 16, 2010 May 16, 2010

My website has several forms. When I process one of the forms, I get the error messages below.

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 'Condition, Length, Color, City, `State`, Email, Photo) VALUES ('29', '4', 'Used'' at line 1.

On another form, I get this message:  Incorrect table name ''

Please help.  I am a novice!!!

Thanks.

TOPICS
Server side applications
647
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 16, 2010 May 16, 2010

There's an error somewhere in your code so you need to post your code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 17, 2010 May 17, 2010

Here is my code.  Thanks for your help.

<form action="<?php echo $editFormAction; ?><?php echo $loginFormAction; ?>" method="POST" enctype="multipart/form-data" name="individual" class="individual" id="individual">
  <table width="594" border="0" class="test">
  <tr></tr>
  <tr>
    <td width="166" class="td">Posting Title</td>
    <td colspan="3"><span id="sprytextfield1">
      <label>
        <input name="Posting Title" type="text" class="test" id="Posting Title" size="35" />
        </label>
      <span class="textfieldRequiredMsg">Required</span></span></td>
  </tr>
  <tr>
    <td class="td">Price</td>
    <td colspan="3"><span id="sprytextfield2">
      <label>
        <input name="price" type="text" class="test" id="price" size="35" />
      </label>
      <span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
  </tr>
  <tr>
    <td class="td">Size(s)</td>
    <td colspan="3"><label>
      <select name="size" size="1" class="test" id="size">
<option>0</option>
        <option>2</option>
        <option>4</option>
        <option>6</option>
        <option>8</option>
        <option>10</option>
        <option>12</option>
        <option>14</option>
        <option>16</option>
        <option>18</option>
        <option>20</option>
        <option>22</option>
        <option>24</option>
        <option>26</option>
      </select>
    </label></td>
  </tr>
  <tr>
    <td class="td">Condition</td>
    <td colspan="3"><label>
      <select name="Condition" class="test" id="Condition">
<option>New</option>
        <option>Used</option>
      </select>
    </label></td>
  </tr>
  <tr>
    <td class="td">Length</td>
    <td colspan="3"><label>
      <select name="Length" class="test" id="Length">
<option>Long</option>
<option>Short</option>
<option>Mid-Length</option>
      </select>
    </label></td>
  </tr>
  <tr>
    <td class="td">Color</td>
    <td colspan="3" class="td"><span id="sprytextfield5">
      <label>
        <input name="Color" type="text" class="test" id="Color" size="35" />
      </label>
      <span class="textfieldRequiredMsg">Required</span></span></td>
  </tr>
  <tr>
    <td class="td">City</td>
    <td class="td"><span id="sprytextfield4">
      <label>
        <input name="City" type="text" class="test" id="City" size="35" />
      </label>
      <span class="textfieldRequiredMsg">Required</span></span></td>
    <td class="td"> </td>
    <td class="td"> </td>
  </tr>
  <tr>
    <td class="td">State</td>
    <td colspan="3"><label>
      <select name="State" class="test" id="State">
        <option>AL</option>
        <option>AK</option>
        <option>AZ</option>
        <option>AR</option>
        <option>CA</option>
        <option>CO</option>
        <option>CT</option>
        <option>DE</option>
        <option>DC</option>
        <option>FL</option>
        <option>GA</option>
        <option>HI</option>
        <option>ID</option>
        <option>IL</option>
        <option>IN</option>
        <option>IA</option>
        <option>KS</option>
        <option>KY</option>
        <option>LA</option>
        <option>ME</option>
        <option>MD</option>
        <option>MA</option>
        <option>MI</option>
        <option>MN</option>
        <option>MS</option>
        <option>MO</option>
        <option>MT</option>
        <option>NE</option>
        <option>NV</option>
        <option>NH</option>
        <option>NJ</option>
        <option>NM</option>
        <option>NY</option>
        <option>NC</option>
        <option>ND</option>
        <option>OH</option>
        <option>OK</option>
        <option>OR</option>
        <option>PA</option>
        <option>RI</option>
        <option>SC</option>
        <option>SD</option>
        <option>TN</option>
        <option>TX</option>
        <option>UT</option>
        <option>VT</option>
        <option>VA</option>
        <option>WA</option>
        <option>WV</option>
        <option>WI</option>
        <option>WY</option>
      </select>
    </label></td>
  </tr>
  <tr>
    <td class="td">Email</td>
    <td colspan="3"><span id="sprytextfield3">
      <label>
        <input name="Email" type="text" class="test" id="Email" size="35" />
      </label>
      <span class="textfieldRequiredMsg">Required</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
  </tr>
  <tr>
    <td height="26" class="td">Confirm Email</td>
    <td colspan="3"><span id="spryconfirm1">
      <label>
        <input name="Confirm Email2" type="text" class="test" id="Confirm Email2" size="35" />
      </label>
      <span class="confirmRequiredMsg">Required</span><span class="confirmInvalidMsg">The values don't match.</span></span></td>
  </tr>
  <tr>
    <td height="26" class="td">Photo(s)</td>
    <td colspan="3"><label>
      <input name="Photo" type="file" class="test" id="Photo" size="35" />
    </label></td>
  </tr>
  <tr>
    <td height="131" class="td">Additional Details</td>
    <td colspan="3"><label>
      <textarea name="Additional Details" cols="40" rows="6" class="test" id="Additional Details"></textarea>
    </label></td>
  </tr>
  </table>
  <p>
    <label>
      <input name="Submit" type="submit" class="test" id="Submit" value="Post" />
    </label>
  </p>
  <input type="hidden" name="MM_insert" value="individual" />
</form>
<p> </p>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 17, 2010 May 17, 2010

There are many things wrong with your form code. Options don't have values for one.

Also, you haven't posted your processing script.

Furthermore, you need to provide your database table schema.

Assuming that you're not working on a local testing server, you may be subjecting yourself to potential vulnerabilities if you're uploading several forms to your website without proper knowledge of what it is that you're putting on your site. I suggest you learn your language first and then upload it to your site once you know exactly what it is that you're uploading, not the other way around where you upload things to your site when you have no idea what you're doing and then learn afterwards what you should of done (the hard way i.e. compromising your database or worse). If you're developing locally on a testing server then disregard my warning and read up on some books to learn php.

BTW, mentioning your scripting language in your original post is a good way to get accurate feedback as well. You never mentioned your scripting language in your other post regarding file upload capability in a form, even after I recommended that you do so.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 18, 2010 May 18, 2010

First let me say that I appreciate all the help you have been providing me.

I don't understand where option came from because those are the values for the list menu.

I am working on a local server and having been using the tutorials to build my website. 

Here is my processing script:

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;   
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "individual")) {
  $insertSQL = sprintf("INSERT INTO shoes (`size`, Condition, Color, City, `State`, Email, Photo) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['size'], "text"),
                       GetSQLValueString($_POST['Condition'], "text"),
                       GetSQLValueString($_POST['Color'], "text"),
                       GetSQLValueString($_POST['City'], "text"),
                       GetSQLValueString($_POST['State'], "text"),
                       GetSQLValueString($_POST['Email'], "text"),
                       GetSQLValueString($_POST['Photo'], "int"));

  mysql_select_db($database_bridesmaidsrack_db, $bridesmaidsrack_db);
  $Result1 = mysql_query($insertSQL, $bridesmaidsrack_db) or die(mysql_error());
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 18, 2010 May 18, 2010
LATEST

Where can I locate the database table schema so that I can provide it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines