Hello,
I'm trying to take the values from an array and put them into a mysql table. I keep gettng an error on the query no matter how I rewrite it. The script does parse without errors. I would appreciate anyone taking a look at the script and making suggestions on what could be the problem.
-----snip----
// Need to convert old date in unixtime to YYYY-MM-DD HH:MM
function convertdate($unixtime) {
return date("Y-m-d", $unixtime);
}
function converttime($unixtime) {
return date("h:m", $unixtime);
}
function convertDateTime($unixtime) {
return convertdate($unixtime)." ".converttime($unixtime);
}
// Open file and put in array
$data = file("babeltopics2.txt");
// Open connection
$newlink = mysql_pconnect("myserver", "myuser", "mypassword")
or die("Could not connect");
mysql_select_db("mydatabase", $newlink)
or die("Could not select database.");
// loop through array
// Elements in this form 952205057|952205057|952205057|7|435
while (list($key, $value) = each($data))
{
$newvalues = explode("|", $value)
or die("Explosion fizzled!");
for($i=0; $i < count($newvalues); $i++) {
$newvalues[2] = convertDateTime($newvalues[2]);
$newresult = mysql_query("INSERT INTO my_posts(post_id, topic_id, post_time, forum_id, poster_id) VALUES ('{$newvalues[0]}' , '{$newvalues[1]}' , '{$newvalues[2]}' , '{$newvalues[3]}' , '{$newvalues[4]}')", $newlink)
or die("Invalid query");
}
}
mysql_free_result($newresult);
mysql_close($newlink);
Thanks in advance for any help!
Susan