开发者

Uploading HTML into database - PERL

im trying to upload HTML into a database which does work for some files but not all.

my $fileContents;
if( $md5Con =~ m/\.php$/g ) {
    my $ftp = Net::FTP->new($DB_ftpserver, Debug => 0) or die "Cannot connect to some.host.name: $@";
    $ftp->login($DB_ftpuser, $DB_ftppass) or die "Cannot login ", $ftp->message;
    ftp->get("/" . $root . $webpage, "c:/perlscripts/" . md5_hex($md5Con) . "-code.php") or die $ftp->message;
    my $file = "c:/perlscripts/" . md5_hex($md5Con) . "-code.php";
    {
       local( $/ ); # undefine the record seperator
       open FILE, "<", $file or die "Cannot open:$!\n";
       my $fileContents = <FILE>;
       #print $fileContents;
       my $bodyContents;
       my $headContents;

       my @contentsArray = split( /<\/head>/is, $fileContents, 2);

       if( scalar @contentsArray == 2 ){
           $bodyContents = $dbh->quote(trim($contentsArray[1]));
           $headContents = $dbh->quote(trim($contentsArray[0]) . "</head>");

           $dbh->do($createBodyTable) or die " error: Couldn't create body table: " . DBI->errstr;
           $dbh->do($createHeadTable) or die " error: Couldn't create header table: " . DBI->errstr;
           $dbh->do("INSERT INTO $headerTable ( headData, headDataOutput ) VALUES ( $headContents, $headContents )") or die " error: Couldn't connect to database: " . DBI->errstr;
           $dbh->do("INSERT INTO $bodyTable ( bodyData, bodyDataOutput ) VALUES ( $bodyContents, $bodyContents )") or die " error: Couldn't connect to database: " . DBI->errstr;
           $dbh->do("INSERT INTO page_names (linkFromRoot, linkTrue, page_name, table_name, navigation, location) VALUES ( $linkFromRoot, $linkTrue, $page_name, $table_name, $navigation, $location )") or die " error: Couldn't connect to database: " . DBI->errstr;

           unlink("c:/perlscripts/" . md5_hex($md5Con) . "-code.php");
       }else{
           print "<span class=\"red\">" . $md5Con . " cannot be used by our CMS, invalid data.</span><br />\n";
       }
   }
   $ftp->quit;
}

can anyone see why this maybe happening?

EDIT

To see at a different angle, this is the output of the data going into the database... The first 3 blocks of code go in fine then errors on the fourth.

<span class="green">http://www.themobilemakeover.co.uk/index.php</span><br />

'<?php session_start(); ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"h
ttp://www.w3.org/1999/xhtml\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<meta name=\"description\" content=\"The Mo
bile Makeover offers a wide range of services and treatments all from the luxuary of your own home!\" />\n<meta name=\"keywords\" content=\"Mobile Makeover, B
eauty Therapist, Beautician, Therapist, Mobile Therapist, Mansfield, Nottinghamshire\" />\n<meta name=\"language\" content=\"en\" />\n<meta name=\"author\" co
ntent=\"ACT Web Designs\" />\n<meta name=\"copyright\" content=\"The Mobile Makeover\" />\n<meta name=\"publisher\" content=\"ACT Web Designs\" />\n<meta name
=\"country\" content=\"United Kingdom\" />\n<meta name=\"city\" content=\"Mansfield, Nottinghamshire\" />\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=8
\" /> \n<meta name=\"verify-v1\" content=\"4lZIaMmjLMq+UA8nkPYB9RjF5RreNwF3Mzurm9JYvQM=\" />\n<title>The Mobile Makeover - Mobile Beautician</title>\n<link hr
ef=\"stylesheets/main.css\" rel=\"stylesheet\" type=\"text/css\" />\n<link href=\"stylesheets/cssReset.css\" rel=\"stylesheet\" type=\"text/css\" />\n<script
type=\"text/javascript\" src=\"js/jquery-1.3.1.js\"></script>\n<script type=\"text/javascript\" src=\"js/jquery.bgpos.js\"></script>\n<script type=\"text/java
script\" src=\"js/jquery.timers.js\"></script>\n<script type=\"text/javascript\" src=\"js/makeover.scroll.js\"></script>\n<script type=\"text/javascript\">\nv
ar gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");\ndocument.write(unescape(\"%3Cscript src=\'\" + gaJsHost + \"
google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E\"));\n</script>\n<script type=\"text/javascript\">\ntry {\nvar pageTracker = _gat._getTr
acker(\"UA-8193659-6\");\npageTracker._trackPageview();\n} catch(err) {}</script></head>'

<span class="green">http://www.themobilemakeover.co.uk/about-us-the-mobile-makeover.php</span><br />

'<?php session_start(); ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"h
ttp://www.w3.org/1999/xhtml\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<meta name=\"description\" content=\">My na
me is Kelly Knight, I am a highly Qualifed Mobile Beauty Therapist. I have trained in NVQ Level 2 and NVQ level 3 in Beauty Therapy with many additional cours
es and training...\" />\n<meta name=\"keywords\" content=\"Mobile Makeover, About Us, Beauty Therapist, Mobile Therapist, Mansfield, Nottinghamshire\" />\n<me
ta name=\"language\" content=\"en\" />\n<meta name=\"author\" content=\"ACT Web Designs\" />\n<meta name=\"copyright\" content=\"The Mobile Makeover\" />\n<me
ta name=\"publisher\" content=\"ACT Web Designs\" />\n<meta name=\"country\" content=\"United Kingdom\" />\n<meta name=\"city\" content=\"Mansfield, Nottingha
mshire\" />\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=8\" /> \n<title>The Mobile Makeover - About Us</title>\n<link href=\"stylesheets/main.css\" rel
=\"stylesheet\" type=\"text/css\" />\n<link href=\"stylesheets/cssReset.css\" rel=\"stylesheet\" type=\"text/css\" />\n<script type=\"text/javascript\" src=\"
js/jquery-1.3.1.js\"></script>\n<script type=\"text/javascript\" src=\"js/jquery.bgpos.js\"></script>\n<script type=\"text/javascript\" src=\"js/jquery.timers
.js\"></script>\n<script type=\"text/javascript\" src=\"js/makeover.scroll.js\"></script>\n<script type=\"text/javascript\">\nvar gaJsHost = ((\"https:\" == d
ocument.location.protocol) ? \"https://ssl.\" : \"http://www.\");\ndocument.write(unescape(\"%3Cscript src=\'\" + gaJsHost + \"google-analytics.com/ga.js\' ty
pe=\'text/javascript\'%3E%3C/script%3E\"));\n</script>\n<script type=\"text/javascript\">\ntry {\nvar pageTracker = _gat._getTracker(\"UA-8193659-6\");\npageT
racker._trackPageview();\n} catch(err) {}</script></head>'

<span class="green">http://www.themobilemakeover.co.uk/beauty-products-used.php</span><br />

'<?php session_start(); ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"h
ttp://www.w3.org/1999/xhtml\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<meta name=\"description\" content=\"We use
 a wide range of the finest products on the market today. Below is a short brief of just a few of the names which we believe give you the best results - we do
 not compromise when it comes to quality.\" />\n<meta name=\"keywords\" content=\"Mobile Makeover, Beauty Therapist, Beauty Products, Jessica, Calgel, Eve Tay
lor, Tantrick, Therapist, Mansfield, Nottinghamshire\" />\n<meta name=\"language\" content=\"en\" />\n<meta name=\"author\" content=\"ACT Web Designs\" />\n<m
eta name=\"copyright\" content=\"The Mobile Makeover\" />\n<meta name=\"publisher\" content=\"ACT Web Designs\" />\n<meta name=\"country\" content=\"United Ki
ngdom\" />\n<meta name=\"city\" content=\"Mansfield, Nottinghamshire\" />\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=8\" /> \n<title>The Mobile Makeov
er - Beauty Products Used</title>\n<link href=\"stylesheets/main.css\" rel=\"stylesheet\" type=\"text/css\" />\n<link href=\"stylesheets/cssReset.css\" rel=\"
stylesheet\" type=\"text/css\" />\n<!--[if lte IE 6]><link href=\"stylesheets/mainie6.css\" rel=\"stylesheet\" type=\"text/css\" /><![endif]-->\n<script type=
\"text/javascript\" src=\"js/jquery-1.3.1.js\"></script>\n<script type=\"text/javascript\" src=\"js/jquery.bgpos.js\"></script>\n<script type=\"text/javascrip
t\" src=\"js/jquery.timers.js\"></script>\n<script type=\"text/javascript\" src=\"js/makeover.scroll.js\"></script>\n<script type=\"text/javascript\">\nvar ga
JsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");\ndocument.write(unescape(\"%3Cscript src=\'\" + gaJsHost + \"googl
e-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E\"));\n</script>\n<script type=\"text/javascript\">\ntry {\nvar pageTracker = _gat._getTracker
(\"UA-8193659-6\");\npageTracker._trackPageview();\n} catch(err) {}</script></head>'

<span class="green">http://www.themobilemakeover.co.uk/beauty-treatments.php</span><br />

'<?php session_start(); ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"h
ttp://www.w3.org/1999/xhtml\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<meta name=\"description\" content=\"The Mo
bile Makeover offers a wide range of treatments all from the luxuary of your own home!\" />\n<meta name=\"keywords\" content=\"Mobile Makeover, Beauty Treatme
nts, Beautician, Facials, Pedicures, Hopi Ear Candles, Eye Treatments, Mansfield, Nottinghamshire\" />\n<meta name=\"language\" content=\"en\" />\n<meta name=
\"author\" content=\"ACT Web Designs\" />\n<meta name=\"copyright\" content=\"The Mobile Makeover\" />\n<meta name=\"publisher\" content=\"ACT Web Designs\" /
>\n<meta name=\"country\" content=\"United Kingdom\" />\n<meta name=\"city\" content=\"Mansfield, Nottinghamshire\" />\n<meta http-equiv=\"X-UA-Compatible\" c
ontent=\"IE=8\" /> \n<title>The Mobile Makeover - Beauty Treatments</title>\n<link href=\"stylesheets/main.css\" rel=\"stylesheet\" type=\"text/css\" />\n<lin
k href=\"stylesheets/cssReset.css\" rel=\"stylesheet\" type=\"text/css\" />\n<script type=\"text/javascript\" src=\"js/jquery-1.3.1.js\"></script>\n<script ty
pe=\"text/javascript\" src=\"js/jquery.bgpos.js\"></script>\n<script type=\"text/javascript\" src=\"js/jquery.timers.js\"></script>\n<script type=\"text/javas
cript\" src=\"js/makeover.scroll.js\"></script>\n<script type=\"text/javascript\">\nvar gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl
.\" : \"http://www.\");\ndocument.write(unescape(\"%3Cscript src=\'\" + gaJsHost + \"google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E\"))
;\n</script>\n<script type=\"text/javascript\">\ntry {\nvar pageTracker = _gat._getTracker(\"UA-8193659-6\");\npageTracker._trackPageview();\n} catch(err) {}<
/script></head>'


DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use nea
r '22e64cef7d70fa952ce7444f158e2c4e_header ( headData, headDataOutput ) VALUES ( '<' at line 1 at C:\perlscripts\cgitest.pl line 360, <FILE> chunk 4.

 error: Couldn't connect to database: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right synta
x to use near '22e64cef7d70fa952ce7444f158e2c4e_header ( headData, headDataOutput ) VALUES ( '<' at line 1 at C:\perlscripts\cgitest.pl line 360, <FILE> chunk
 4.

>>>>>> EDIT 2 <<<<<<<<<

After using trace I am non the wiser. Here is my log:

(this is now removing "quote()" and using placeholders)

    DBI 1.607-ithread default trace level set to 0x0/1 (pid 13524) at cgitest.pl line 10
    -> DBI->connect(*****************************************************)
    -> DBI->install_driver(mysql) for MSWin32 perl=5.010001 pid=13524 ruid=0 euid=0
       install_driver: DBD::mysql version 4.011 loaded from C:/Perl/site/lib/DBD/mysql.pm
    <- install_driver= DBI::dr=HASH(0x37be1fc)
    !! warn: 0 CLEARED by call to connect method
    <- connect('database=web110-accounts;host=79.170.44.110;', 'web110-accounts', ...)= DBI::db=HASH(0x37bdc8c) at DBI.pm line 638
    <- STORE('PrintError', 1)= 1 at DBI.pm line 690
    <- STORE('AutoCommit', 1)= 1 at DBI.pm line 690
    <- STORE('Username', 'web110-accounts')= 1 at DBI.pm line 693
    <> FETCH('Username')= 'web110-accounts' ('Username' from cache) at DBI.pm line 693
    <- connected(**********************************)= undef at DBI.pm line 699
    <- connect= DBI::db=HASH(0x37bdc8c)
    <- STORE('dbi_connect_closure', CODE(0x37c3634))= 1 at DBI.pm line 708
    <- prepare('SELECT * FROM accounts WHERE KI = '9096699576bcc810df5bc311650c4ebd' ')= DBI::st=HASH(0x37bda24) at cgitest.pl line 61
    <- execute= 1 at cgitest.pl line 62
    <- rows= '1' at cgitest.pl line 63
    <- fetchrow_hashref= HASH(0x37bd514)24keys row1 at cgitest.pl line 64
    <- finish= 1 at cgitest.pl line 71
    <- disconnect= 1 at cgitest.pl line 72
   ****************************************************************************
   ****************************************************************************
    <- STORE('PrintError', 1)= 1 at DBI.pm line 690
    <- STORE('AutoCommit', 1)= 1 at DBI.pm line 690
    <- STORE('Username', 'web110-db-2')= 1 at DBI.pm line 693
    <> FETCH('Username')= 'web110-db-2' ('Username' from cache) at DBI.pm line 693
    <- connected('DBI:mysql:database=web110-db-2;host=79.170.44.110;', 'web110-db-2', ...)= undef at DBI.pm line 699
    <- connect= DBI::db=HASH(0x3d615ac)
    <- STORE('dbi_connect_closure', CODE(0x3d60f6c))= 1 at DBI.pm line 708
    <- prepare('INSERT INTO ? ( headData, headDataOutput ) VALUES ( ?, ? )')= DBI::st=HASH(0x351659c) at cgitest.pl line 263
    <- prepare('INSERT INTO ? ( bodyData, bodyDataOutput ) VALUES ( ?, ? )')= DBI::st=HASH(0x37bd914) at cgitest.pl line 264
    <- prepare('INSERT INTO page_names (linkFromRoot, linkTrue, page_name, table_name, navigation, location) VALUES ( ?, ?, ?, ?, ?, ? )')= DBI::st=HASH(0x3d575fc) at cgitest.pl line 265
    <- quote("http://www.themobilemakeover.co.uk/index.php")= "'http://www.themobilemakeover.co.uk/index.php'" at cgitest.pl line 271
    <- prepare("SELECT * FROM page_names WHERE linkTrue = 'http://www.themobilemakeover.co.uk/index.php' ")= DBI::st=HASH(0x3d571bc) at cgitest.pl line 272
    <- execute= '0E0' at cgitest.pl line 273
    <- rows= '0' at cgitest.pl line 274
    <- quote("The Mobile Makeover - Mobile Beautician")= "'The Mobile Makeover - Mobile Beautician'" at cgitest.pl line 289
    <- prepare("SELECT * FROM page_names WHERE page_name = 'The Mobile Makeover - Mobile Beautician' ")= DBI::st=HASH(0x3d56fdc) at cgitest.pl line 290
    <- execute= '0E0' at cgitest.pl line 291
    <- rows= '0' at cgitest.pl line 292
    <- DESTROY(DBI::st=HASH(3d54254))= undef at cgitest.pl line 287
    <- do('CREATE TABLE IF NOT EXISTS `6959bbd13fdb4df586a5b9d08aae1153_body` (
                    `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
                    `bodyData` TEXT NOT NULL, 
                    `bodyDataOutput` TEXT NOT NULL 
                    ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;')= '0E0' at cgitest.pl line 362
    <- do('CREATE TABLE IF NOT EXISTS `6959bbd13fdb4df586a5b9d08aae1153_header` (
                    `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
                    `headData` TEXT NOT NULL, 
                    `headDataOutput` TEXT NOT NULL 
                    ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;')= '0E0' at cgitest.pl line 363
    !! ERROR: 1064 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''6959bbd13fdb4df586a5b9d08aae1153_header' ( headData, headDataOutput ) VALUES ( ' at line 1' (err#0)
    <- execute('6959bbd13fdb4df586a5b9d08aae1153_header', '<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description开发者_开发知识库" content="The Mobile Makeover offers a wide range of services and treatments all from the luxuary of your own home!" />
<meta name="keywords" content="Mobile Makeover, Beauty Therapist, Beautician, Therapist, Mobile Therapist, Mansfield, Nottinghamshire" />
<meta name="language" content="en" />
<meta name="author" content="ACT Web Designs" />
<meta name="copyright" content="The Mobile Makeover" />
<meta name="publisher" content="ACT Web Designs" />
<meta name="country" content="United Kingdom" />
<meta name="city" content="Mansfield, Nottinghamshire" />
<meta http-equiv="X-UA-Compatible" content="IE=8" /> 
<meta name="verify-v1" content="4lZIaMmjLMq+UA8nkPYB9RjF5RreNwF3Mzurm9JYvQM=" />
<title>The Mobile M...', ...)= undef at cgitest.pl line 365
    !! ERROR: 1064 CLEARED by call to execute method
    !! ERROR: 1064 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''6959bbd13fdb4df586a5b9d08aae1153_body' ( bodyData, bodyDataOutput ) VALUES ( '<' at line 1' (err#0)
    <- execute('6959bbd13fdb4df586a5b9d08aae1153_body', '<body>
    <div id="wrapper">
        <div id="header">
            <div id="innerHeader">
                <h1><span>The Mobile Makeover - Mobile Beauty Therapist - Mansfield Nottinghamshire</span></h1>
                <div class="clear"></div>
                <?php include("php/navigation.php"); ?>
                <div class="clear"></div>
            </div>
        </div>
        <div id="main">
            <div id="content1" class="content vis">
                <h2>Welcome to The Mobile Makeover</h2>
                <div class="image1">
                </div>
                <p>Home visit appointments are designed to save you time and stress, by providing a service in the comfort of your own home, no need to worry about travel and traffic or facing the cold night air after a relaxing treatment.</p>
                <p>If you have a baby or a toddler The Mobile Makeover can help you put together a package of <a href="beauty-treatments.php" title="link to treatments page">treatments</a> that is ada...', ...)= undef at cgitest.pl line 366
    !! ERROR: 1064 CLEARED by call to execute method
    <- execute("public_html/index.php", "http://www.themobilemakeover.co.uk/index.php", ...)= 1 at cgitest.pl line 367
    <- DESTROY(DBI::st=HASH(3d56f5c))= undef at cgitest.pl line 270
    <- quote("http://www.themobilemakeover.co.uk/about-us-the-mobile-makeover.php")= "'http://www.themobilemakeover.co.uk/about-us-the-mobile-makeover.php'" at cgitest.pl line 271
    <- prepare("SELECT * FROM page_names WHERE linkTrue = 'http://www.themobilemakeover.co.uk/about-us-the-mobile-makeover.php' ")= DBI::st=HASH(0x3d56d9c) at cgitest.pl line 272
    <- execute= '0E0' at cgitest.pl line 273
    <- rows= '0' at cgitest.pl line 274
    <- quote("The Mobile Makeover - About Us")= "'The Mobile Makeover - About Us'" at cgitest.pl line 289
    <- prepare("SELECT * FROM page_names WHERE page_name = 'The Mobile Makeover - About Us' ")= DBI::st=HASH(0x3b07814) at cgitest.pl line 290
    <- execute= '0E0' at cgitest.pl line 291
    <- rows= '0' at cgitest.pl line 292
    <- DESTROY(DBI::st=HASH(3d54254))= undef at cgitest.pl line 287
    <- do('CREATE TABLE IF NOT EXISTS `30df18a64311aa9aaaa9576b030f0f83_body` (
                    `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
                    `bodyData` TEXT NOT NULL, 
                    `bodyDataOutput` TEXT NOT NULL 
                    ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;')= '0E0' at cgitest.pl line 362
    <- do('CREATE TABLE IF NOT EXISTS `30df18a64311aa9aaaa9576b030f0f83_header` (
                    `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
                    `headData` TEXT NOT NULL, 
                    `headDataOutput` TEXT NOT NULL 
                    ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;')= '0E0' at cgitest.pl line 363
    !! ERROR: 1064 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''30df18a64311aa9aaaa9576b030f0f83_header' ( headData, headDataOutput ) VALUES ( ' at line 1' (err#0)
    <- execute('30df18a64311aa9aaaa9576b030f0f83_header', '<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content=">My name is Kelly Knight, I am a highly Qualifed Mobile Beauty Therapist. I have trained in NVQ Level 2 and NVQ level 3 in Beauty Therapy with many additional courses and training..." />
<meta name="keywords" content="Mobile Makeover, About Us, Beauty Therapist, Mobile Therapist, Mansfield, Nottinghamshire" />
<meta name="language" content="en" />
<meta name="author" content="ACT Web Designs" />
<meta name="copyright" content="The Mobile Makeover" />
<meta name="publisher" content="ACT Web Designs" />
<meta name="country" content="United Kingdom" />
<meta name="city" content="Mansfield, Nottinghamshire" />
<meta http-equiv="X-UA-Compatible" content="IE=8" /> 
<title>The Mobile Makeover - About U...', ...)= undef at cgitest.pl line 365
    !! ERROR: 1064 CLEARED by call to execute method
    !! ERROR: 1064 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''30df18a64311aa9aaaa9576b030f0f83_body' ( bodyData, bodyDataOutput ) VALUES ( '<' at line 1' (err#0)
    <- execute('30df18a64311aa9aaaa9576b030f0f83_body', '<body id="aboutUsPage">
    <div id="wrapper">
        <div id="header">
            <div id="innerHeader">
                <h1><span>The Mobile Makeover - About Us</span></h1>
                <div class="clear"></div>
                <?php include("php/navigation.php"); ?>
                <div class="clear"></div>
            </div>
        </div>
        <div id="main">
            <div id="content1" class="content vis">
                <h2>About Us - Kelly Night</h2>
                <div class="image1">
                </div>
                <p>My name is Kelly Knight, I am a highly Qualified Mobile Beauty Therapist. I have trained in NVQ Level 2 and NVQ level 3 in Beauty Therapy with many additional courses and training gained within my time in the beauty industry. I have gained my years of experience from working at one of the UK's biggest Hotels &amp; Spa chains where i worked as a salon supervisor. After being approached by a number of people to go mobile to their homes i recognised that the...', ...)= undef at cgitest.pl line 366
    !! ERROR: 1064 CLEARED by call to execute method
    <- execute("public_html/about-us-the-mobile-makeover.php", "http://www.themobilemakeover.co.uk/about-us-the-mobile-makeover.php", ...)= 1 at cgitest.pl line 367
    <- DESTROY(DBI::st=HASH(3d56f1c))= undef at cgitest.pl line 270
    <- quote("http://www.themobilemakeover.co.uk/beauty-products-used.php")= "'http://www.themobilemakeover.co.uk/beauty-products-used.php'" at cgitest.pl line 271
    <- prepare("SELECT * FROM page_names WHERE linkTrue = 'http://www.themobilemakeover.co.uk/beauty-products-used.php' ")= DBI::st=HASH(0x3d56f3c) at cgitest.pl line 272
    <- execute= '0E0' at cgitest.pl line 273
    <- rows= '0' at cgitest.pl line 274
    <- quote("The Mobile Makeover - Beauty Products Used")= "'The Mobile Makeover - Beauty Products Used'" at cgitest.pl line 289
    <- prepare("SELECT * FROM page_names WHERE page_name = 'The Mobile Makeover - Beauty Products Used' ")= DBI::st=HASH(0x3d545a4) at cgitest.pl line 290
    <- execute= '0E0' at cgitest.pl line 291
    <- rows= '0' at cgitest.pl line 292
    <- DESTROY(DBI::st=HASH(3d54684))= undef at cgitest.pl line 287
    <- do('CREATE TABLE IF NOT EXISTS `02b5f135f611c1d7b0ec090182bc6cf5_body` (
                    `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
                    `bodyData` TEXT NOT NULL, 
                    `bodyDataOutput` TEXT NOT NULL 
                    ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;')= '0E0' at cgitest.pl line 362
    <- do('CREATE TABLE IF NOT EXISTS `02b5f135f611c1d7b0ec090182bc6cf5_header` (
                    `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
                    `headData` TEXT NOT NULL, 
                    `headDataOutput` TEXT NOT NULL 
                    ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;')= '0E0' at cgitest.pl line 363
    !! ERROR: 1064 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''02b5f135f611c1d7b0ec090182bc6cf5_header' ( headData, headDataOutput ) VALUES ( ' at line 1' (err#0)
    <- execute('02b5f135f611c1d7b0ec090182bc6cf5_header', '<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="We use a wide range of the finest products on the market today. Below is a short brief of just a few of the names which we believe give you the best results - we do not compromise when it comes to quality." />
<meta name="keywords" content="Mobile Makeover, Beauty Therapist, Beauty Products, Jessica, Calgel, Eve Taylor, Tantrick, Therapist, Mansfield, Nottinghamshire" />
<meta name="language" content="en" />
<meta name="author" content="ACT Web Designs" />
<meta name="copyright" content="The Mobile Makeover" />
<meta name="publisher" content="ACT Web Designs" />
<meta name="country" content="United Kingdom" />
<meta name="city" content="Mansfield, Nottinghamshire" />
<meta http-equiv="X-UA-Compa...', ...)= undef at cgitest.pl line 365
    !! ERROR: 1064 CLEARED by call to execute method
    !! ERROR: 1064 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''02b5f135f611c1d7b0ec090182bc6cf5_body' ( bodyData, bodyDataOutput ) VALUES ( '<' at line 1' (err#0)
    <- execute('02b5f135f611c1d7b0ec090182bc6cf5_body', '<body id="aboutUsPage">
    <div id="wrapper">
        <div id="header">
            <div id="innerHeader">
                <h1><span>The Mobile Makeover - Beauty Products</span></h1>
                <div class="clear"></div>
                <?php include("php/navigation.php"); ?>
                <div class="clear"></div>
            </div>
        </div>
        <div id="main">
            <div id="content1" class="content vis">
                <h2>Beauty products that we use</h2>
                <div class="image1">
                </div>
                <p>We use a wide range of the finest products on the market today. Below is a short brief of just a few of the names which we believe give you the best results - we do not compromise when it comes to quality.<br /> - <em>Kelly Knight</em></p>
            </div>
            <div class="content vis norm">
                <h2>Jessica</h2>
                <div class="image3">
                </div>
                <p>The Jessica &copy; nail products are de...', ...)= undef at cgitest.pl line 366
    !! ERROR: 1064 CLEARED by call to execute method
    <- execute("public_html/beauty-products-used.php", "http://www.themobilemakeover.co.uk/beauty-products-used.php", ...)= 1 at cgitest.pl line 367
    <- DESTROY(DBI::st=HASH(3d6982c))= undef at cgitest.pl line 270
    <- quote("http://www.themobilemakeover.co.uk/beauty-treatments.php")= "'http://www.themobilemakeover.co.uk/beauty-treatments.php'" at cgitest.pl line 271
    <- prepare("SELECT * FROM page_names WHERE linkTrue = 'http://www.themobilemakeover.co.uk/beauty-treatments.php' ")= DBI::st=HASH(0x3d56edc) at cgitest.pl line 272
    <- execute= '0E0' at cgitest.pl line 273
    <- rows= '0' at cgitest.pl line 274
    <- quote("The Mobile Makeover - Beauty Treatments")= "'The Mobile Makeover - Beauty Treatments'" at cgitest.pl line 289
    <- prepare("SELECT * FROM page_names WHERE page_name = 'The Mobile Makeover - Beauty Treatments' ")= DBI::st=HASH(0x3d6b48c) at cgitest.pl line 290
    <- execute= '0E0' at cgitest.pl line 291
    <- rows= '0' at cgitest.pl line 292
    <- DESTROY(DBI::st=HASH(3d6c674))= undef at cgitest.pl line 287
    <- do('CREATE TABLE IF NOT EXISTS `22e64cef7d70fa952ce7444f158e2c4e_body` (
                    `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
                    `bodyData` TEXT NOT NULL, 


It's hard to see for sure what's going wrong, but I think Andreas Bonini is correct that you've got quoting problems.

However, he has accidentally referred you to a PHP function ;-)

You can use DBI's quote method for the same effect. (Update: oops, you used it already for the data items. But perhaps you need to use it - or placeholders - for the table name variables too?)

However, it's considered better practice by most people to use placeholder values:

while (something) {
    # I've imagined you're looping over the data

    $dbh->do("INSERT INTO $headerTable ( headData, headDataOutput ) 
      VALUES ( $headContents, $headContents )")
        or die " error: Couldn't connect to database: " . DBI->errstr;
}

becomes:

my $sth = $dbh->prepare("INSERT INTO ? ( headData, headDataOutput ) 
                  VALUES ( ?, ? )") 
                    or die " error: Couldn't prepare : " . DBI->errstr;)

# later...
while (something) {
    # loop over the data

    $sth->execute($headerTable, $headContents, $headContents) 
      or die "couldn't execute: " . $sth->errstr;
}

Untested... sorry ;-)

I'm not 100% sure you can use a placeholder for the table name, but I don't really see why not, so I suggest trying it. If not, you should quote() the table name as described above.

Assuming your code runs in a loop, you can prepare the statement handler ($sth) once outside the loop and run execute several times, which should save some time if you have many inserts to do.

HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜