Hiya, i am having a problem with my script. Its simply ment to upload the data that someone puts in to a form to a database. i have got it to work elsewhere on my site but this one is being wierd.
The error is as follows '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 'what description is', 'what uploader is')' at line 1'
I have recycled the script from another one that i have used, and it is working, which may be my problem but i really cant find where it is in the script. Here is the script, much abliged for any help:
<?php
require_once '../header.php';
require_once '/home/cricher/conn.inc.php';
?>
<html>
</head>
<body>
<div id="navigation"><a href="addvid.php">Add A Video</a> | View A Video</div>
<div class="MainFont">
<?php
if (isset($_POST['submit']) && $_POST['submit'] == "Add Video") {
if ($_POST['url'] != "" &&
$_POST['description'] != "" &&
$_POST['uploader']!="") {
//Check url isnt already taken
$query = "SELECT url FROM videos " .
"WHERE url = '" . $_POST['url'] . "';";
$result = mysql_query($query)
or die(mysql_error());
if (mysql_num_rows($result) != 0) {
?>
<p>
<font color="#FF0000"><b>The url,
<?php echo $_POST['url']; ?>, has already been uploaded, please choose another one!</b></font>
<form action="addvid.php" method="post">
<p>URL:
<input type="text" name="url"><br>
Description:<br>
<textarea name="description" cols="100" rows="4" id="description"><?php echo $_POST['description']; ?></textarea>
<br>
<input type="hidden" name="uploader"
value="<?php echo $_SESSION['name']; ?>">
<input type="submit" name="submit" value="Add Video">
<input name="reset" type="reset" value="Clear">
</p>
</form>
</p>
<?php
} else {
$query = "INSERT INTO videos (url, description, uploader) " .
"VALUES ('" . $_POST['url'] . "', " .
$_POST['description'] . "', '" . $_POST['uploader'] . "');";
$result = mysql_query($query)
or die(mysql_error());
?>
<p>
Thank you, <?php echo $_SESSION['name']; ?> for submitting a video!<br>
<?php
header("Refresh: 5; URL=index.php");
echo "Your registration is complete! " .
"You are being sent to the page you requested!<br>";
echo "(If your browser doesn't support this, " .
"<a href=\"index.php\">click here</a>)";
die();
}
} else {
?>
<p>
<font color="#FF0000"><b>The url and description fields are required!</b></font>
<form action="addvid.php" method="post">
<p>URL:
<input type="text" name="url"
value="<?php echo $_POST['url']; ?>"><br>
Description:<br>
<textarea name="description" cols="100" rows="4" id="description"><?php echo $_POST['description']; ?></textarea>
<br>
<input type="hidden" name="uploader"
value="<?php echo $_SESSION['name']; ?>">
<br>
<input type="submit" name="submit" value="Add Video">
<input type="reset" value="Clear">
</p>
</form>
</p>
<?php
}
} else {
?>
<p>
Welcome to the add a video page!<br>
The URL and description fields are required!
<form action="addvid.php" method="post">
<p>URL:
<input type="text" name="url">
<br>
Description:<br>
<textarea name="description" cols="100" rows="4" id="description"></textarea>
<br>
<input type="hidden" name="uploader"
value="<?php echo $_SESSION['name']; ?>">
<br>
<input type="submit" name="submit" value="Add Video">
<input type="reset" value="Clear">
</p>
</form>
</p>
<?php
}
?>
</div>
</body>
</html>
<?php
require_once '../footer.php';
?>