Solved

INSERT data into MYSQL

Posted on 2011-02-23
6
275 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
Comment Utility
Post your INSERT INTO statement please
0
 
LVL 34

Expert Comment

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

Expert Comment

by:jmsloan
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 14

Expert Comment

by:Scott Madeira
Comment Utility
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
Comment Utility
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
Comment Utility
I am a fool
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The viewer will learn how to count occurrences of each item in an array.
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now