我观察oblog4xsql-xspace3x.zip中的oblog4xsql-xspace3x.php代码为:
$hash = substr(md5($itemid), 8, 16);
借鉴并使用
PHP脚本导入数据测试后,
$query_insert = mb_convert_encoding("INSERT INTO {$target_db}.supe_spaceitems (`catid`, `uid`, `tid`, `username`, `itemtypeid`, `type`, `subtype`, `subject`, `dateline`, `lastpost`, `viewnum`, `replynum`, `trackbacknum`, `goodrate`, `badrate`, `digest`, `top`, `allowreply`, `folder`, `haveattach`, `grade`) VALUES('$catid', '$uid', '$tid', '$username', '$itemtypeid', '$type', '$subtype', '$subject', UNIX_TIMESTAMP('$dateline'), UNIX_TIMESTAMP('$lastpost'), '$viewnum', '$replynum', '$trackbacknum', '$goodrate', '$badrate', '$digest', '$top', '$allowreply', '$folder', '$haveattach', '$grade');", "utf-8", "gb2312");
print_r ($query_insert);
echo "<br>";
mysql_query("set names utf8;");
mysql_query($query_insert,$target_link);
$itemid = mysql_insert_id($target_link);
//$hash = substr(md5($itemid), 8, 16);
$hash = substr(md5(1), 8, 16);
$query_update = "update {$target_db}.supe_spaceitems set hash='$hash' where itemid>5;";
//$query_update = "update {$target_db}.supe_spaceitems set hash=substr(md5(LAST_INSERT_ID()), 8, 16) where itemid>5;";
echo $query_update ;
mysql_query($query_update,$target_link);
使用sql查询该数据表:
select itemid,hash,substr(md5(1),8,16) as hash1 from supe_spaceitems limit 10;
却得到以下结果:
itemid hash hash1
1 2cc9041325d8ab38 8a0b923820dcc509
2 f8ade0bf4a9d3da0 8a0b923820dcc509
4 a52cf45aca6fb1ca 8a0b923820dcc509
5 84158618c9ca04f6 8a0b923820dcc509
24 a0b923820dcc509a 8a0b923820dcc509
25 a0b923820dcc509a 8a0b923820dcc509
26 a0b923820dcc509a 8a0b923820dcc509
27 a0b923820dcc509a 8a0b923820dcc509
28 a0b923820dcc509a 8a0b923820dcc509
29 a0b923820dcc509a 8a0b923820dcc509
正常的话,a0b923820dcc509a应该为2cc9041325d8ab38。
不知道为什么不对?

至于hash为什么不等于hash1,是不是系统函数定义不一样?
hash值到底是怎么回事?有什么用?
为了这个东西,我都耽误一天时间了。

我的目的是导入以前公司网站自己编的资讯内容到SS5.5资讯频道。
---------------------------------
我的部分代码$query_insert = mb_convert_encoding("INSERT INTO {$target_db}.supe_spaceitems (`catid`, `uid`, `tid`, `username`, `itemtypeid`, `type`, `subtype`, `subject`, `dateline`, `lastpost`, `viewnum`, `replynum`, `trackbacknum`, `goodrate`, `badrate`, `digest`, `top`, `allowreply`, `folder`, `haveattach`, `grade`) VALUES('$catid', '$uid', '$tid', '$username', '$itemtypeid', '$type', '$subtype', '$subject', UNIX_TIMESTAMP('$dateline'), UNIX_TIMESTAMP('$lastpost'), '$viewnum', '$replynum', '$trackbacknum', '$goodrate', '$badrate', '$digest', '$top', '$allowreply', '$folder', '$haveattach', '$grade');", "utf-8", "gb2312");
print_r ($query_insert);
echo "<br>";
mysql_query("set names utf8;");
mysql_query($query_insert,$target_link);
$itemid = mysql_insert_id($target_link);
$hash = substr(md5($itemid), 8, 16); // 表单关联
$query_update = "update {$target_db}.supe_spaceitems set hash='$hash' where itemid=$itemid;";
//$query_update = "update {$target_db}.supe_spaceitems set hash=substr(md5(LAST_INSERT_ID()), 8, 16) where itemid=$itemid;";
echo $query_update ;
mysql_query($query_update,$target_link);