philstockham
Technical User
i have a form to input data into a mysql database table. when i was inputting only a couple of fields it worked fine, however, now i have added more fields and it is failing. i have checked the code countless time and can't see what is causing this - HELP IS DESPERATELY NEEDED
below is the mysql table the data is going into:
CREATE TABLE report(
id INT NOT NULL AUTO_INCREMENT,
title VARCHAR(50) NOT NULL,
description VARCHAR(200) NOT NULL,
covershot VARCHAR(50) NOT NULL,
mainbody TEXT NOT NULL,
contents TEXT NOT NULL,
keywords TEXT NOT NULL,
PRIMARY KEY(id)
);
Here is the html/php code i am using for the form:
<form method="post">
<table width="448" border="0" cellpadding="2" cellspacing="1" align="left">
<tr>
<td width="100"><font color="#0000FF" face="Geneva, Arial, Helvetica, sans-serif">Title:</font></td>
<td width="337"><input name="title" type="text"></td>
</tr>
<tr>
<td width="100" valign="top"><font color="#0000FF" face="Geneva, Arial, Helvetica, sans-serif">Descritption:</font></td>
<td><textarea name="description" cols="50" rows="3" id="description"></textarea></td>
</tr>
<tr>
<td height="77"><font color="#0000FF" face="Geneva, Arial, Helvetica, sans-serif">Pricing:</font></td>
<td><textarea name="pricing" cols="50" rows="3" id="pricing"></textarea></td>
</tr>
<tr>
<td valign="top"><font color="#0000FF" face="Geneva, Arial, Helvetica, sans-serif">Cover
shot:</font></td>
<td><input name="covershot" type="text" id="covershot"></td>
</tr>
<tr>
<td valign="top"><font color="#0000FF" face="Geneva, Arial, Helvetica, sans-serif">Main
body: </font></td>
<td><textarea name="mainbody" cols="50" rows="10" id="mainbody"></textarea></td>
</tr>
<tr>
<td valign="top"><font color="#0000FF" size="4" face="Geneva, Arial, Helvetica, sans-serif">Contents:</font></td>
<td><textarea name="contents" cols="50" rows="10" id="textarea2"></textarea></td>
</tr>
<tr>
<td valign="top"><font color="#0000FF" size="4" face="Geneva, Arial, Helvetica, sans-serif">Keywords:</font></td>
<td><textarea name="keywords " cols="50" rows="10" id="keywords "></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="save" type="submit" value="Save Report"></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['save']))
{
$title = $_POST['title'];
$description = $_POST['description'];
$pricing = $_POST['pricing'];
$covershot = $_POST['covershot'];
$mainbody = $_POST['mainbody'];
$contents = $_POST['contents'];
$keywords = $_POST['keywords'];
if(!get_magic_quotes_gpc())
{
$title = addslashes($title);
$description = addslashes($description);
$pricing = addslashes($pricing);
$covershot = addslashes($covershot);
$mainbody = addslashes($mainbody);
$contents = addslashes($contents);
$keywords = addslashes($keywords);
}
include 'config.php';
include 'opendb.php';
$query = "INSERT INTO report (title, description, pricing, covershot, mainbody, contents, keywords) ".
"VALUES ('$title', '$description', '$pricing', ''$covershot', '$mainbody', '$contents', '$keywords')";
mysql_query($query) or die('Error ,query failed');
include 'closedb.php';
echo "Report '$title' added";
}
?>
Any help is much appreciated.
Regards
below is the mysql table the data is going into:
CREATE TABLE report(
id INT NOT NULL AUTO_INCREMENT,
title VARCHAR(50) NOT NULL,
description VARCHAR(200) NOT NULL,
covershot VARCHAR(50) NOT NULL,
mainbody TEXT NOT NULL,
contents TEXT NOT NULL,
keywords TEXT NOT NULL,
PRIMARY KEY(id)
);
Here is the html/php code i am using for the form:
<form method="post">
<table width="448" border="0" cellpadding="2" cellspacing="1" align="left">
<tr>
<td width="100"><font color="#0000FF" face="Geneva, Arial, Helvetica, sans-serif">Title:</font></td>
<td width="337"><input name="title" type="text"></td>
</tr>
<tr>
<td width="100" valign="top"><font color="#0000FF" face="Geneva, Arial, Helvetica, sans-serif">Descritption:</font></td>
<td><textarea name="description" cols="50" rows="3" id="description"></textarea></td>
</tr>
<tr>
<td height="77"><font color="#0000FF" face="Geneva, Arial, Helvetica, sans-serif">Pricing:</font></td>
<td><textarea name="pricing" cols="50" rows="3" id="pricing"></textarea></td>
</tr>
<tr>
<td valign="top"><font color="#0000FF" face="Geneva, Arial, Helvetica, sans-serif">Cover
shot:</font></td>
<td><input name="covershot" type="text" id="covershot"></td>
</tr>
<tr>
<td valign="top"><font color="#0000FF" face="Geneva, Arial, Helvetica, sans-serif">Main
body: </font></td>
<td><textarea name="mainbody" cols="50" rows="10" id="mainbody"></textarea></td>
</tr>
<tr>
<td valign="top"><font color="#0000FF" size="4" face="Geneva, Arial, Helvetica, sans-serif">Contents:</font></td>
<td><textarea name="contents" cols="50" rows="10" id="textarea2"></textarea></td>
</tr>
<tr>
<td valign="top"><font color="#0000FF" size="4" face="Geneva, Arial, Helvetica, sans-serif">Keywords:</font></td>
<td><textarea name="keywords " cols="50" rows="10" id="keywords "></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="save" type="submit" value="Save Report"></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['save']))
{
$title = $_POST['title'];
$description = $_POST['description'];
$pricing = $_POST['pricing'];
$covershot = $_POST['covershot'];
$mainbody = $_POST['mainbody'];
$contents = $_POST['contents'];
$keywords = $_POST['keywords'];
if(!get_magic_quotes_gpc())
{
$title = addslashes($title);
$description = addslashes($description);
$pricing = addslashes($pricing);
$covershot = addslashes($covershot);
$mainbody = addslashes($mainbody);
$contents = addslashes($contents);
$keywords = addslashes($keywords);
}
include 'config.php';
include 'opendb.php';
$query = "INSERT INTO report (title, description, pricing, covershot, mainbody, contents, keywords) ".
"VALUES ('$title', '$description', '$pricing', ''$covershot', '$mainbody', '$contents', '$keywords')";
mysql_query($query) or die('Error ,query failed');
include 'closedb.php';
echo "Report '$title' added";
}
?>
Any help is much appreciated.
Regards