Jump to content

[SOLVED] Can someone check my code?


djfox

Recommended Posts

I get the following error message:

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 'desc, shortname, store, files, layers, gender, posespec, type, cost, spec, date ' at line 1

 

Here`s admin_clothing_add.php:

<?php
//Date: December 31 2007
//For: www.secrettrance.net
//Description: Admin Panel: Add Clothing

include("dbcon.php");
require_once "design.php";
require_once "auth.php";

$Title = "Secret Trance: Admin Panel: Add Clothing";

require_once "header.php";
require_once "hidestatus.php";

if (!isLoggedIn()) {
Redirect("index.php");
}
?>
<p>
<table border=0 width=100% bgcolor="000000"><? //2
?>
<tr>
<td background="<? echo "$boxbanner"; ?>"><b>Admin Panel: Add Clothing</b>
<tr>
<td background="<? echo "$boxback"; ?>">
<?php
if ($lev > 7) {
?>
<form action="admin_clothing_add2.php">
<b>Name:</b>
<br><input type="text" name="title" size="60" maxlength="255">
<p>
<b>Description:</b>
<br><input type="text" name="des" size="60" maxlength="255">
<p>
<b>Short Name:</b>
<br><input type="text" name="short" size="60" maxlength="255">
<p>
<b>Region:</b>
<br><select name="region" style="border: 0px; background-color:#000000; color: #B6ABCE;">
<?php
  $res = mysql_query("SELECT id, name FROM shops ORDER BY name ASC");
  while ( $cats = mysql_fetch_row($res) ){
     echo "<option value='$cats[0]'>$cats[1]</option>";
  }
?>
</select>
<p>
<b>Files:</b> <font size=2>(Exclude .png extensions. Seperate by ,)</font>
<br><input type="text" name="filenames" size="60">
<p>
<b>Layers:</b> <font size=2>(Coordinate layer numbers with file names listed above.)</font>
<br><input type="text" name="lay" size="60">
<p>
<b>Gender:</b>
<br><select name="gender" style="border: 0px; background-color:#000000; color: #B6ABCE;">
<option value="b">Both
<option value="f">Female
<option value="m">Male
</select>
<p>
<b>Is Item Pose Specific?</b>
<br><input type="radio" name="pose" value="0"> No
<br><input type="radio" name="pose" value="1"> Yes
<p>
<b>Item Type</b>
<br><select name="type" style="border: 0px; background-color:#000000; color: #B6ABCE;">
<?php
  $res = mysql_query("SELECT id, name FROM categories ORDER BY name ASC");
  while ( $cats2 = mysql_fetch_row($res) ){
     echo "<option value='$cats2[1]'>$cats2[1]</option>";
  }
?>
</select>
<p>
<b>Cost:</b> 
<br><input type="text" name="price" size="60" maxlength="100">
<p>
<b>Is Item Special Item?</b>
<br><input type="radio" name="spe" value="0"> No
<br><input type="radio" name="spe" value="1"> Yes
<p>
<input type="image" src="<? echo $butadd ?>" name="submit">
</form>
<?php
}
else{
if ($lev <  {
header("Location: today.php");	
}
}
?>
</table><? //2
?>
<p>
<?
require_once "footer.php";
?>

 

admin_clothing_add2.php:

<?php
session_start();
//Date: December 31 2007
//For: www.secrettrance.net
//Description: Admin Panel: Add Clothing

include("dbcon.php");
require_once "design.php";
require_once "auth.php";

$Title = "Secret Trance: Admin Panel: Add Clothing";

require_once "header.php";
require_once "hidestatus.php";

if (!isLoggedIn()) {
Redirect("index.php");
}
if ($lev >  {  
$entry_date = strftime("%B\ %e\,\ %Y %H:%M:%S", time()); 
$add="INSERT INTO clothing ( name, desc, shortname, store, files, layers, gender, posespec, type, cost, spec, date ) VALUES ( '$title', '$des', '$short', '$region', '$filenames', '$lay', '$gender', '$pose', '$type', '$price','$spe', '$entry_date' )";
$res = mysql_query($add) or die(mysql_error());
mysql_close($con);

//Redirect
header("Location: admin_clothing_add.php");
}
else{
if ($lev < 9) {
header("Location: today.php");	
}
}
?>

 

Here`s a screenshot of 'clothing' table:

clothing_table.jpg

Link to comment
Share on other sites

It is because you have a field named 'desc'.  This is a MySQL reserved word.  Either rename that field, or encapsulate your field with the back tick character...e.g.:

$add="INSERT INTO clothing ( `name`, `desc`, `shortname`, `store`, `files`, `layers`, `gender`, `posespec`, `type`, `cost`, `spec`, `date` ) VALUES ( '$title', '$des', '$short', '$region', '$filenames', '$lay', '$gender', '$pose', '$type', '$price','$spe', '$entry_date' )";

Enjoy and happy new year!

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.