Page 1 of 1
Mysql STMT Errors. Can you help?
Posted: Fri Jun 04, 2010 2:37 am
by Coburn64
I'm working on a CoburnBoard (custom coded forum software by myself) to Simple Machines Forum software converter. In order to do so, an administrator that co-authors the website has developed a converter for me. It works he says.... but when put into action it dies with random errors.
Here's the code:
http://pastebin.com/mRdXCS8N
Result?
<snip>
CD Database Connection: Success
SMF Database Connection: Success
Converting thread: Spagetti.
Converting post by: Coburn64
Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: invalid object or resource mysqli_stmt in C:\WLMP\HTDOCS\woohoo\conversionator.php on line 121
Warning: mysqli_stmt::execute() [mysqli-stmt.execute]: invalid object or resource mysqli_stmt in C:\WLMP\HTDOCS\woohoo\conversionator.php on line 122
Warning: mysqli_stmt::close() [mysqli-stmt.close]: invalid object or resource mysqli_stmt in C:\WLMP\HTDOCS\woohoo\conversionator.php on line 123
Converting post by: Coburn64
<snip>
I have checked line 120 - 125 and can't spot any errors. These errors loop until the script has completed everything. Could someone please shed some light onto this? At the moment, it's kinda

...
Cheers,
Coburn64
Re: Mysql STMT Errors. Can you help?
Posted: Fri Jun 04, 2010 3:05 am
by requinix
It'd sure help if you posted code...
Re: Mysql STMT Errors. Can you help?
Posted: Fri Jun 04, 2010 5:46 am
by Coburn64
tasairis wrote:It'd sure help if you posted code...
I'm sorry, but the code was posted in that pastebin link. Here's the code for any debuggers out there:
Code: Select all
<?
/*
Coburn's Domain 2 to SMF Conversionator
+-------- Made by Weremuffin. --------+
*/
## Edit these variables for maximum conversion
$db_server = 'localhost'; ## DB Server
$db_user = 'removedusername'; ## DB Username
$db_pass = 'removedpassword'; ## DB Password
$cd_db_name = 'coburndomain2'; ## This where the Coburn's Domain data is located.
$smf_db_name = 'smf'; ## This is where the SMF forum is located.
$smf_forum_prefix = 'smf_'; ## This is the prefix used by your SMF installation.
$smf_desig_forumid = '2'; ## This is where the posts get sent to.
## Infact, If you didn't edit them it probably wouldn't even work..
## Um, Yeah. Don't edit below. Maybe.
## If somethings buggy, DM or Email me.
$mysqli_cd = new mysqli($db_server, $db_user, $db_pass, $cd_db_name);
$cd_error = mysqli_connect_errno();
$mysqli_smf = new mysqli($db_server, $db_user, $db_pass, $smf_db_name);
$smf_error = mysqli_connect_errno();
?>
<html>
<head>
<style>
span{ font-weight:bold; }
span.success{ color:#34BA34; }
span.failure{ color:#FF0000; }
</style>
</head>
<body>
<?
if($cd_error == 0) echo"CD Database Connection: <span class='success'>Success</span><br>";
else{
echo"CD Database Connection: <span class='failure'>Failure</span><br>";
echo"Error #$cd_error. Please check settings and try again.<br>";
}
if($smf_error == 0) echo"SMF Database Connection: <span class='success'>Success</span><br><br>";
else{
echo"SMF Database Connection: <span class='failure'>Failure</span><br>";
echo"Error #$smf_error. Please check settings and try again.<br>";
}
if($cd_error == 0 && $smf_error == 0){
$threads = $mysqli_cd->query("select * from forum_threads");
$iter = 1;
while($t = $threads->fetch_object()){
$firstpost = $mysqli_cd->query("select posttitle from forum_posts where postid='$t->firstpostid'")->fetch_object();
$origforum = $mysqli_cd->query("select name,catid from forumsubcats where id='$t->forumid'")->fetch_object();
$origcat = $mysqli_cd->query("select catname from forumcategories where catid='$origforum->catid'")->fetch_object()->catname;
echo "Converting thread: $firstpost->posttitle<br>";
$topicid = $mysqli_smf->query("select ID_TOPIC from ".$smf_forum_prefix."topics order by ID_TOPIC desc limit 1")->fetch_object()->ID_TOPIC+1;
$rand1 = mt_rand(1,1000).mt_rand(1,1000);
$rand2 = mt_rand(1,1000).mt_rand(1,1000);
$mysqli_smf->query("insert into ".$smf_forum_prefix."topics
(
ID_BOARD,
ID_MEMBER_STARTED,
ID_MEMBER_UPDATED,
ID_FIRST_MSG,
ID_LAST_MSG,
locked,
isSticky,
numViews,
ID_POLL
)
values(
'$smf_desig_forumid',
'0','0',
'$rand1','$rand2',
'1','0',
'$t->views','0'
)
");
if(eregi('duplicate key',$mysqli_smf->error)){
echo"Critical Error. Script has ended.<br>Please restore the tables 'topics' and 'messages' from a backup and try again.";
exit;
}
$posts = $mysqli_cd->query("select * from forum_posts where threadid='$t->threadid'");
while($p = $posts->fetch_object()){
$poster = $mysqli_cd->query("select username from members where userid='$p->userid'")->fetch_object()->username;
echo "Converting post by: $poster<br>";
if($p->postid == $t->firstpostid){
if($t->issticky == 1) $stick = '[sticky] ';
else $stick = '';
$newtitle = $stick.$firstpost->posttitle;
}
else $newtitle = "Re: $firstpost->posttitle";
$origforumnote = "\n\n------------------------------\nOriginal Forum: $origcat - $origforum->name";
$smfpost = $p->post.$origforumnote;
$stmt = $mysqli_smf->stmt_init();
$stmt->prepare("insert into ".$smf_forum_prefix."messages
values(
null,
'$topicid',
'$smf_desig_forumid',
'$p->posttime',
'0',
'',
?,
?,
'',
'$p->posterip',
'1', '0', '',
?,
'xx'
)
");
$stmt->bind_param("sss",$newtitle,$poster,$smfpost);
$stmt->execute();
$stmt->close();
$postid = $mysqli_smf->insert_id;
$mysqli_smf->query("update ".$smf_forum_prefix."messages set ID_MSG_MODIFIED='$postid' where ID_MSG='$postid'");
if($p->postid == $t->firstpostid) $mysqli_smf->query("update ".$smf_forum_prefix."topics set ID_FIRST_MSG='$postid' where ID_TOPIC='$topicid'");
$origforumnote = '';
}
$last_postid = $postid;
$mysqli_smf->query("update ".$smf_forum_prefix."topics set ID_LAST_MSG='$last_postid' where ID_TOPIC='$topicid'");
echo"<br>";
// if($iter == 2) exit;
// else $iter++;
}
}
?>
</body>
</html>
Re: Mysql STMT Errors. Can you help?
Posted: Fri Jun 04, 2010 8:14 pm
by Coburn64
Sorry to bump, but this is kinda urgent.

Re: Mysql STMT Errors. Can you help?
Posted: Fri Jun 04, 2010 8:15 pm
by Benjamin
Forum Rules 1 1.1 4 wrote:
4. All users of any level are restricted from bumping (
as defined here) any given thread within twenty-four (24) hours of its last post. Non-trivial posts are not considered bumping. A bump post found in violation will be deleted, and you may or may not receive a warning. Persons bumping excessively be considered as spammers and dealt with accordingly.