mrlayance
mrlayance

Reputation: 663

PHP MYSQL INSERT not working?

<?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

Upvotes: 0

Views: 409

Answers (4)

Divya Sankaran
Divya Sankaran

Reputation: 15

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

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

Upvotes: 0

Samuel
Samuel

Reputation: 17171

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

Upvotes: 0

Paulraj
Paulraj

Reputation: 3397

You have missed the table name in insert statement.

INSERT INTO tablename (`datetime`) VALUES ('$update')

Upvotes: 4

johngreen
johngreen

Reputation: 2744

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

Upvotes: 0

Related Questions