473,405 Members | 2,185 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,405 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 1591
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.