It checks to see if the submission type is a link or download, then does the according query.
Code: Select all
// db connection
$connection = mysql_connect("localhost", "username", "pass") or die(mysql_error());
$db = mysql_select_db("dbname", $connection) or die(mysql_error());
// is it a link?
if (($_POST['type'] == "link")) {
$sql = "INSERT INTO links ('url', 'description', 'category') VALUES ('$_POST[url]', '$_POST[description]', '$_POST[category]')";
// or is it a download?
} else if (($_POST['type'] == "download")) {
$sql = "INSERT INTO downloads ('title', 'url', 'description', 'category') VALUES ('$_POST[title]', '$_POST[url]', '$_POST[description]', '$_POST[category]')";
}
// send the query.
$result = mysql_query($sql, $connection) or die(mysql_error());What's wrong with my query?
Thanks in advance.