Solved

INSERT data into MYSQL

Posted on 2011-02-23
6
277 Views
Last Modified: 2012-05-11
This has to be simple but i am baffled not to find anything on this matter  

I have this string, yes it's a string, not a file. And i want to insert it into my sql without any modification.
mysql_escape_string() does not work;
mysql_real_escape_string() does not work



<root>
                        <supplorder entrydate="23/02/2011">
                          <lineitems>
           <lineitem>
            <art_nr>20673</art_nr>
            <lev_num>20001</lev_num>
            <code_lev>15-00155</code_lev>
            <eenheid>5</eenheid>
            <werkeenheid>5</werkeenheid>
            <nr_eenheden>1</nr_eenheden>
            <omschr>huls iso 0.14mm2  grijs zak 500</omschr>
            <omschrlang></omschrlang>
            <internrem></internrem>
            <aank>8.59</aank>
            <voor>0</voor>
            <besteld>5</besteld>
            <lijntot>42.94</lijntot>
            <kortbijlev>0</kortbijlev>
            <eenhstr>st</eenhstr>
            <vrij_ingav>0</vrij_ingav>
            <assocrekrowid>0</assocrekrowid>
          </lineitem>
         
           <lineitem>
            <art_nr>20675</art_nr>
            <lev_num>20001</lev_num>
            <code_lev>15-00255</code_lev>
            <eenheid>5</eenheid>
            <werkeenheid>5</werkeenheid>
            <nr_eenheden>1</nr_eenheden>
            <omschr>huls iso 0.25mm2  geel zak 500</omschr>
            <omschrlang></omschrlang>
            <internrem></internrem>
            <aank>6.64</aank>
            <voor>2</voor>
            <besteld>3</besteld>
            <lijntot>19.91</lijntot>
            <kortbijlev>0</kortbijlev>
            <eenhstr>st</eenhstr>
            <vrij_ingav>0</vrij_ingav>
            <assocrekrowid>0</assocrekrowid>
          </lineitem>
         </lineitems>
               </supplorder>
           </root>
0
Comment
Question by:ScottNL1
6 Comments
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 34960498
Post your INSERT INTO statement please
0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 34960500
Also the table definition as well so we can see the column's data type and size
0
 
LVL 3

Expert Comment

by:jmsloan
ID: 34960523
Your double quotes need to be backslashed

insert into test values('<root>
<supplorder entrydate=\"23/02/2011\">
<lineitems>
<lineitem>
<art_nr>20673</art_nr>
<lev_num>20001</lev_num>
<code_lev>15-00155</code_lev>
<eenheid>5</eenheid>
<werkeenheid>5</werkeenheid>
<nr_eenheden>1</nr_eenheden>
<omschr>huls iso 0.14mm2 grijs zak 500</omschr>
<omschrlang></omschrlang>
<internrem></internrem>
<aank>8.59</aank>
<voor>0</voor>
<besteld>5</besteld>
<lijntot>42.94</lijntot>
<kortbijlev>0</kortbijlev>
<eenhstr>st</eenhstr>
<vrij_ingav>0</vrij_ingav>
<assocrekrowid>0</assocrekrowid>
</lineitem>

<lineitem>
<art_nr>20675</art_nr>
<lev_num>20001</lev_num>
<code_lev>15-00255</code_lev>
<eenheid>5</eenheid>
<werkeenheid>5</werkeenheid>
<nr_eenheden>1</nr_eenheden>
<omschr>huls iso 0.25mm2 geel zak 500</omschr>
<omschrlang></omschrlang>
<internrem></internrem>
<aank>6.64</aank>
<voor>2</voor>
<besteld>3</besteld>
<lijntot>19.91</lijntot>
<kortbijlev>0</kortbijlev>
<eenhstr>st</eenhstr>
<vrij_ingav>0</vrij_ingav>
<assocrekrowid>0</assocrekrowid>
</lineitem>
</lineitems>
</supplorder>
</root>'):
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 14

Expert Comment

by:Scott Madeira
ID: 34960542
what do you mean "mysql_escape_string() does not work;
mysql_real_escape_string() does not work"

Do you get an error message? Is the data not what you were expecting?  Please provide the SQL statement and table definition that was requested above for us to help you.
0
 
LVL 1

Accepted Solution

by:
ScottNL1 earned 0 total points
ID: 34960721
unbelievable, after all that i forgot to put the $string in quoit's.

INSERT INTO drafts (id,xml) VALUES ($id,'$string')

sorry for that,  
0
 
LVL 1

Author Closing Comment

by:ScottNL1
ID: 34995334
I am a fool
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question