chesemonkyloma
09-05-2006, 06:25 PM
It keeps giving me an error, saying that my SQL syntax is incorrect. Here is the complete code of the section, in case it's needed, but just pay attention to the SQL. I didn't post this on another forum because it could also be a PHP problem.
$modelname=ucwords(strtolower($_POST[ModelName]));
$creatorname=ucwords(strtolower($_POST[CreatorName]));
$id=substr(md5(uniqid(rand(), true)), 0, 6);
$imageType=substr(strrchr($_FILES['Picture']['name'], "."), 1);
$imagePath="images/models/".$modelname.".".$imageType;
$link=mysql_connect("localhost", "username", "password")
or die('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("sockigam_", $link);
$sql="INSERT INTO Models (Name, Creator, Email, Description, Category, Socks, NoOfSteps, Difficulty, ImageType, ID)
VALUES ('$modelname', '$creatorname', '$_POST[Email]', '$_POST[Description]', '$_POST[Category]', $_POST[Socks], $_POST[StepsNumber], '$_POST[Difficulty]', '$imageType', '$id')";
mysql_query($sql, $link) or die(mysql_error());
move_uploaded_file($_FILES["Picture"]["tmp_name"], "..".$imagePath);
echo "<FORM ACTION=\"$_SERVER[PHP_SELF]\" METHOD=\"POST\">
<TABLE>";
for ($i=1; $i<=$_POST[StepsNumber]; $i++)
{
echo "<TR>
<TD>Step $i:</TD>
<TD><TEXTAREA ROWS=2 COLS=30 NAME=\"Step{$i}\"></TEXTAREA></TD>
</TR>";
}
echo "<INPUT TYPE=\"hidden\" NAME=\"Model\" VALUE=\"{$modelname}\"><TR><TD><INPUT TYPE=\"Submit\" NAME=\"Submit2\" VALUE=\"Submit\"></TD></TR>
</TABLE></FORM>";
$modelname=ucwords(strtolower($_POST[ModelName]));
$creatorname=ucwords(strtolower($_POST[CreatorName]));
$id=substr(md5(uniqid(rand(), true)), 0, 6);
$imageType=substr(strrchr($_FILES['Picture']['name'], "."), 1);
$imagePath="images/models/".$modelname.".".$imageType;
$link=mysql_connect("localhost", "username", "password")
or die('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("sockigam_", $link);
$sql="INSERT INTO Models (Name, Creator, Email, Description, Category, Socks, NoOfSteps, Difficulty, ImageType, ID)
VALUES ('$modelname', '$creatorname', '$_POST[Email]', '$_POST[Description]', '$_POST[Category]', $_POST[Socks], $_POST[StepsNumber], '$_POST[Difficulty]', '$imageType', '$id')";
mysql_query($sql, $link) or die(mysql_error());
move_uploaded_file($_FILES["Picture"]["tmp_name"], "..".$imagePath);
echo "<FORM ACTION=\"$_SERVER[PHP_SELF]\" METHOD=\"POST\">
<TABLE>";
for ($i=1; $i<=$_POST[StepsNumber]; $i++)
{
echo "<TR>
<TD>Step $i:</TD>
<TD><TEXTAREA ROWS=2 COLS=30 NAME=\"Step{$i}\"></TEXTAREA></TD>
</TR>";
}
echo "<INPUT TYPE=\"hidden\" NAME=\"Model\" VALUE=\"{$modelname}\"><TR><TD><INPUT TYPE=\"Submit\" NAME=\"Submit2\" VALUE=\"Submit\"></TD></TR>
</TABLE></FORM>";