Jump to content

Insert Into Table


smithmr8

Recommended Posts

This is supposed to Add an update to a mysql Table called 'Updates'. The fields are 'date' and 'update'.

Update is filled with the update text from the $_POST

Date is filled with the time/date at that point.

 

My problem is that its not inserting anything into the table. It appears to work, yet doesn't insert anything.

 

Can you help ?

 

<b>Add Update</b><br>
<center><form method="POST" action="area1.php?step=add">
Update Content<br>
  <textarea rows="3" name="update" cols="40"></textarea><br>
<input type="submit" value="Add" name="B1">
</form></center>
<?php 
if($_GET['step'] == 'add'){
$updatecontent = $_POST['update'];
$date = date("d/m H:i:sA");


$sql = "INSERT INTO `updates` (date, update) VALUES ('$date', '$updatecontent')";
mysql_query($sql);
echo "<center>Update Added Successfully</center>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/91691-insert-into-table/
Share on other sites

<?php 
if($_GET['step'] == 'add'){
$updatecontent = $_POST['update'];
$thedate = date("d/m H:i:sA");


$sql = "INSERT INTO `updates` (`date`, update) VALUES ('$thedate', '$updatecontent')" or die(mysql_error());
mysql_query($sql);
echo "<center>Update Added Successfully</center>";
}
?>

 

I've got this now, but its still not working. Tried the backsticks. Tried changing the field name.

Link to comment
https://forums.phpfreaks.com/topic/91691-insert-into-table/#findComment-469693
Share on other sites

Oh.. I see. I put that in and received this error.

 

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) VALUES ('18/02 18:18:23PM', '55')' at line 1

 

With Query

INSERT INTO `updates` (`thedate`, update) VALUES ('18/02 18:18:23PM', '55')

Link to comment
https://forums.phpfreaks.com/topic/91691-insert-into-table/#findComment-469820
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.