Keep failing on insert
Posted: Wed Jun 30, 2010 9:26 pm
Im kinda new to php and mysql, but have been trying to get a submission form working to add data to a mysql db.
Its hosted on a Hostgator server, and I've been on to them already to make sure there are no limitations on the account with regards the functionality I need.
With the code below it always returns MySQL Insertion Failure, so Im assuming the connect.php script and the form script are working as planned. Any idea's?
Thanks,
Balveda
Its hosted on a Hostgator server, and I've been on to them already to make sure there are no limitations on the account with regards the functionality I need.
With the code below it always returns MySQL Insertion Failure, so Im assuming the connect.php script and the form script are working as planned. Any idea's?
Thanks,
Balveda
Code: Select all
<?php
if (isset($_POST['submit'])) {
}
$char1 = $_POST['char1'];
$rank = $_POST['rank'];
$class = $_POST['class'];
$spec1 = $_POST['spec1'];
$spec2 = $_POST['spec2'];
$comments = $_POST['comments'];
$error = FALSE;
if ($rank == "none") {
$error = TRUE;
}
if ($class == "none") {
$error = TRUE;
}
if (isset($comments)) {
$comments = trim($comments);
$comments = strip_tags($comments);
}
if (isset($char1) &&
isset($rank) &&
isset($class) &&
isset($spec1) &&
isset($spec2) &&
isset($comments) &&
$error == FALSE) {
$process = TRUE;
} else {
$process = FALSE;
}
include ("connect.php");
$query = "INSERT INTO character VALUES ('','$char1','$rank','$class','$spec1','$spec2','$comments','now()')";
$q = mysql_query($query);
if (!$q) {
exit("<p>MySQL Insertion failure.</p>");
} else {
mysql_close();
//for testing only
echo "<p>MySQL Insertion Successful</p>";
}
?>