473,326 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

database conversion

Ok. So I am in the middle of a switch from an asp message board, snitz
to be exact, to pbpbb. So far I have not all the members, forums, and
categories converted. But the toll I found made by a nifty person
named Raluca Musaloiu-E. is not working for the topics. I think this
is because there is too many special characters in the body of the
posts to the board.

Here is the error I am getting. And bellow that is the converter that
Raluca Musaloiu-E made. Any suggestions of things I can try to the
converter work? It is only converting about 7 posts out of 4,000.
*****************************Error**************** *********************

Start index:
5 7 8 9 12 13 14 15 16 MySQL error on query BR> INSERT INTO
phpbb_posts_text VALUES ( '16', '', NULL, 'cool. what should i bring?
unfortunately, all my cards are mostly jyhad backed. I have a few
sabbat and some dark sovereigns. that\'s really about it though :-\');
mysql_errno = 1064
mysql_error = You have an error in your SQL syntax near ''cool. what
should i bring? unfortunately, all my cards are mostly jyhad backed.'
at line 5

*****************************Converter************ *********************

<?php
require("config.php");
?>

<html>

<head>
<title>Snitz 2 phpBB2 Convertor - Posts</title>
<p>

<?php
$strQueryError = "MySQL error on query";

// display the mysql error that occurs during execution of query $q
function query_error($q)
{
global $strQueryError;
echo $strQueryError." BR>\n";
echo $q."<BR>\n";
echo "mysql_errno = ".mysql_errno()."<BR>\n";
echo "mysql_error = ".mysql_error()."<BR>\n";
die;
}

function encode_ip($dotquad_ip)
{
$ip_sep = explode('.', $dotquad_ip);
return sprintf('%02x%02x%02x%02x', $ip_sep[0], $ip_sep[1],
$ip_sep[2], $ip_sep[3]);
}

$link1 = mysql_connect($server1, $user1, $password1);
$link2 = mysql_connect($server2, $user2, $password2);

// get a valid start index

$query = mysql_db_query($db2, "SELECT post_id FROM $phpbb_posts ORDER
BY post_id DESC;", $link2);
$row = mysql_fetch_array($query);
$idx = $row[post_id];
echo "Start index: $idx<br>";

$query = mysql_db_query($db1, "SELECT * FROM $forum_reply ORDER BY
REPLY_ID ASC;", $link1);
$i = 0;
$debug1 = 0;
$debug2 = 0;

while($row = mysql_fetch_array($query)) {
$idx++;

$year1 = substr($row[R_DATE], 0, 4);
$month1 = substr($row[R_DATE], 4, 2);
$day1 = substr($row[R_DATE], 6, 2);
$hour1 = substr($row[R_DATE], 8, 2);
$min1 = substr($row[R_DATE], 10, 2);
$sec1 = substr($row[R_DATE], 12, 2);
$date1 = mktime($hour1, $min1, $sec1, $month1, $day1, $year1);

// $message = strip_tags(str_replace("'", "\\'", $row[R_MESSAGE]));
$message = str_replace("'", "\\'", $row[R_MESSAGE]);
$ip = encode_ip($row[R_IP]);
echo "$row[REPLY_ID] ";

// for one post i have to do 2 inserts: into posts and into posts_text

$q1 = "INSERT INTO $phpbb_posts VALUES (
'$row[REPLY_ID]',
'$row[TOPIC_ID]',
'$row[FORUM_ID]',
'$row[R_AUTHOR]',
$date1,
'$ip',
NULL,
'1',
'0',
'1',
'0',
NULL,
'0');";

if (mysql_db_query($db2, $q1, $link2) or query_error($q1))
$debug1++;
else
echo "$debug1 - Error2<br>";

$q2 = "INSERT INTO $phpbb_posts_text VALUES (
'$row[REPLY_ID]',
'',
NULL,
'$message');";

if (mysql_db_query($db2, $q2, $link2) or query_error($q2))
$debug2++;
else
echo "$debug2 - Error3<br>";
}
echo "DONE"
?>

</body>
</html>
Jul 20 '05 #1
1 1359
Nekosama wrote:
MySQL error on query BR> INSERT INTO
phpbb_posts_text VALUES ( '16', '', NULL, 'cool. what should i bring?
unfortunately, all my cards are mostly jyhad backed. I have a few
sabbat and some dark sovereigns. that\'s really about it though :-\');


Escape that backslash in the fellow's emoticon.

In fact, you should escape a number of special characters. There was a
thread on this subject on this mailing list earlier this week.

Since you are using PHP, check this out:
http://ca2.php.net/mysql_escape_string

Regards,
Bill K.
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mudge | last post by:
Hi, My hosting provider only allows me to use 50 connections to my MySQL database that my Web site will use. I don't know what this 50 connections means exactly. Does this mean that only 50...
5
by: Shock | last post by:
Hello all, I am doing some research on database conversions. Currently, I am interested in any information that would help me convert a database from one schema to another. This could be...
11
by: RWC | last post by:
Hello, I'm having trouble converting code in Access XP / 2002. I have some code that declares an variable "as database" in Access 97, which is not recognized in Access XP. I've tried to find a...
7
by: Andante.in.Blue | last post by:
Hello everyone! I've been working with a problematic legacy database for a while. While I am still fairly new to Access, the more I work with the database, the more problems I've uncovered. ...
1
by: Tu Quach | last post by:
I got error message like "run time error 3421: data type conversion error" how can i fix the trouble like that, any references should i include in ? any help would be great thank you
8
by: John Baker | last post by:
Hi: I am URGENTLY in need of some book or web site OR tool that will help me integrate a relatively simple access application into a web page or pages. This is a time recording system (by...
4
by: EMW | last post by:
How can I create a SQL server database in my VB.NET program? I've MSSQLServer installed and running. If a database is created, where is it stored? I used the following code, didn't get any...
1
by: bala | last post by:
Hi Access Gurus The MS Access DB (MS Access 2002 Database) which is currently serving as the backend Database to MS Access (MS Access 2002/XP) frontend needs to be converted to Oracle 8i Backend...
4
by: RSH | last post by:
Hi, I have a situation where I have created a little application that makes an Access database from a SQL Database for reporting purposes. it does the job well, but it seems a bit slow. Is...
6
by: jp2code | last post by:
The provider I host my website on gives me three options when it comes to databases: 1. Microsoft Access 2. MySQL 3. MSSQL I have used Access in the past, and it is adequate for the minor...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.