Solved

INSERT data into MYSQL

Posted on 2011-02-23
6
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

705 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