MySQL Forums
Forum List  »  InnoDB

php import export script error help needed
Posted by: dan13 13dan
Date: September 12, 2008 04:41AM

When i run the script below i get this error, please help??:

insert into bcc_phpbb_forum.phpbb_topics_posted values ("12191","1","1",)
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 ')' at line 1
insert into bcc_phpbb_forum.phpbb_topics_posted values ("937","2","1",)
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 ')' at line 1
insert into bcc_phpbb_forum.phpbb_topics_posted values ("937","3","1",)


/////// SCRIPT /////////////////////////////////////////////////////
include_once("config.inc.php");
error_reporting(E_ALL);

// # first get a mysql connection as per the FAQ

$fcontents = file ('spreadsheet.xls');
//$fcontents = file ('spreadsheet.csv');
// # expects the csv file to be in the same dir as this script

for($i=0; $i<sizeof($fcontents); $i++) {
$line = trim($fcontents[$i]);
$arr = explode(',', $line);
// #if your data is comma separated
// # instead of tab separated,
//# change the '\t' above to ','

$sql = "insert into bcc_phpbb_forum.phpbb_topics_posted values (".
implode(',', $arr) .")";
mysql_query($sql);
echo $sql ."<br>\n";
if(mysql_error()) {
echo mysql_error() ."<br>\n";
}
}

Options: ReplyQuote


Subject
Views
Written By
Posted
php import export script error help needed
3527
September 12, 2008 04:41AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.