将专有CMS数据库迁移到Joomla数据库


Migrating a proprietary CMS database to a Joomla database

我目前正在尝试编写一个脚本,将数据库从专有CMS系统迁移到Joomla 1.6数据库。
我的代码在最后一个"骰子"抛出一个错误。(对不起,我一直在自学PHP,我知道我并没有对所有事情都使用正确的术语。)

<?php
$username="root";
$password="";
$database="DATABASE";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM post3";
$result=mysql_query($query);
$num=mysql_num_rows($result);
mysql_close();
$i=0;
while ($i < $num) {
$postid=mysql_result($result,$i,"postid");
echo "$postid <br/>";
$poster=mysql_result($result,$i,"poster");
echo "$poster <br/>";
$department=mysql_result($result,$i,"department");
if($department=="LIFE"){
$department="12";}
elseif ($department=="NEWS"){
    $department="11";}
    elseif ($department=="SPORTS"){
        $department="13";}
        echo "$department <br/>";
$milestone=mysql_result($result,$i,"milestone");
echo "$milestone <br/>";
$date= date('Y-m-d H:i:s', $milestone);
echo "$date <br/>";
$title=mysql_result($result,$i,"title");
echo "$title <br/>";
$preview=mysql_result($result,$i,"preview");
if (empty($preview)) {
   $preview=$title;
}
echo "$preview<br/>";
$alias=str_replace(" ","-", $title);
echo "$alias <br/>";
$bodytext=mysql_result($result,$i,"body_text");
echo "$bodytext <br/>";
$edited=mysql_result($result,$i,"edited");
echo "$edited <br/>";
$pop=mysql_result($result,$i,"pop");
echo "$pop <br/>";
echo "$i Records Copied<br/>";

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("DATABASE", $con);
$sql="INSERT INTO conversion (id, title, alias, introtext, fulltext, state, sectionid, mask, catid, created, created_by, modified, modified_by, checked_out, checked_out_time, publish_up, publish_down, version, parentid, ordering, access, hits, featured, language)
VALUES
('$postid','$title','$alias','$preview','$bodytext','1','0','0','$department','$date','$poster','$date','$poster','0','0000-00-00 00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','$edited','0','$i','1','$pop','0','*')";
if (!mysql_query($sql,$con))
  {
  die ("Query failed: " . mysql_error() . " Actual query: " . $sql);
  }
echo "Success <br/>";
mysql_close($con);
$i++;
}
?>

返回所有内容,但抛出以下错误:查询失败:您的SQL语法有错误;查看与MySQL服务器版本对应的手册,了解在第1行"fulltext, state, sectionid, mask, catid, created, created_by, modified, modified"附近使用的正确语法

任何想法?谢谢你!

fulltext是MySQL的保留关键字。如果要将其用作列名,则需要使用反票,如:

`fulltext`

"fulltext"是MySQL的保留字,所以要么用反号把它括起来(例如`fulltext`),要么用一个不同的名称作为字段