0
<?php
require "dbconnect.php";
$resultno = mysql_query("SELECT `time` FROM syslog");

while($row = mysql_fetch_array($resultno))
 {
$mysqltime = $row['time'];
$timestamp = strtotime($mysqltime);
$update = date("Y-m-d H:i:s", $timestamp);
echo $update;
 }
$mysqlupdate = mysql_query("INSERT INTO (`datetime`) VALUES ('$update')");

The results stream by but no updates? I must be missing something...

Thanks

4
  • $mysqlupdate = mysql_query("INSERT INTO syslog (datetime) VALUES ('$update')"); Still no luck? Hmm.. Commented Jan 11, 2011 at 19:18
  • Could you tell me what kind of type do you have for datetime column in your mysql table ? Commented Jan 11, 2011 at 19:25
  • I see the problem, I am adding just new rows and not add to the end of each row... Commented Jan 11, 2011 at 19:32
  • Do you have time and datetime both fields in syslog table ? Brief about your table structure? Commented Jan 11, 2011 at 19:38

4 Answers 4

4

You have missed the table name in insert statement.

INSERT INTO tablename (`datetime`) VALUES ('$update')
Sign up to request clarification or add additional context in comments.

Comments

0

You need to specify a table-name after INTO in the SQL query.

Comments

0

Perhaps you should look at the UPDATE command instead of insert. If you are looking to update, you shouldn't be using insert.

Comments

0

Besides what @Paulraj correctly pointed out, you are also passing your php variable as a string.

It should be "INSERT INTO (datetime) VALUES ('" . $update . "')"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.