• Welcome to The Cave of Dragonflies forums, where the smallest bugs live alongside the strongest dragons.

    Guests are not able to post messages or even read certain areas of the forums. Now, that's boring, don't you think? Registration, on the other hand, is simple, completely free of charge, and does not require you to give out any personal information at all. As soon as you register, you can take part in some of the happy fun things at the forums such as posting messages, voting in polls, sending private messages to people and being told that this is where we drink tea and eat cod.

    Of course I'm not forcing you to do anything if you don't want to, but seriously, what have you got to lose? Five seconds of your life?

MySQL Question

Peter Shadeslayer

New member
More problems. T_T

PHP:
//Insert an update
function inUpdate($title, $update)
{
$user = "Zack";
$query = "INSERT INTO updates (title, update, date, user)
values('" . $title . "', '" . $update . "', CURDATE(), '" . $user . "')";

mysql_query($query) or die(mysql_error());
}
?>

PHP:
<?php
include("functions.php");
databaseConnect("mysql.owensvilleumc.com", "username", "******", "dbname");

$title = $_POST['title'];
$update = $_POST['update'];

if(isset($title))
{
cleanString($title);
$okay++;
}

else
{
echo "You left the title field blank! ";
}

if(strlen($title) > 50)
{
echo "Your title cannot be longer than fifty characters. ";
}

else
{
$okay++;
}

if(isset($update))
{
cleanString($title, $update, $_COOKIE['user']);
$okay++;
}

else
{
echo "You left the update field blank! ";
}

if(strlen($update) > 500)
{
echo "The length of an update cannot exceed 500 characters. ";
}

else
{
$okay++;
}

if($okay == 4)
{
inUpdate($title, $update);
}

else
{
echo "something's up...";
}
?>

<form action="cms.php" method="post"> 
<table> 
<tr> 
<td> 
Update Title:
</td> 
<td> 
<input type="text" name="title"> 
</td> 
</tr> 
 
<tr> 
<td> 
Update:
</td> 
<td> 
<textarea name="update"> 
 
</textarea> 
</td> 
</tr> 
 
<tr> 
<td> 
<input type="reset" value="Clear"> 
</td> 
<td> 
<input type="submit" value="Submit"> 
</td> 
</tr> 
 
</table> 
</form>

I don't think I really need to explain the purpose of the code... it's pretty direct. ;D
 
My apologies.

MySQL Error said:
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 'update, date, user) values('Title', 'Update ', CURDATE(), 'Zack')' at line 1

This is the page.
 
The word "update" is the problem, since it's a SQL keyword. How did you manage to even create a column named "update"? Shouldn't that return an error? Are you sure you actually named it that?
 
Back
Top Bottom