Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8954915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:25:18+00:00 2026-06-15T14:25:18+00:00

I had been inserting successfully into database but it is not inserting anything, I

  • 0

I had been inserting successfully into database but it is not inserting anything, I did not change the code since then actually.

What can be the reason?

while ($row = mysql_fetch_array($new_entries)){
    $anzeigen_id = $row[0];
    $firma_id = $row[1];
    $xml_filename = "xml/".$anzeigen_id.".xml";
    $dom = new DOMDocument();
    $dom->load($xml_filename);
    $value = $dom->getElementsByTagName('FormattedPositionDescription');
    foreach($value as $v){
        $text = $v->getElementsByTagName('Value');
        foreach($text as $t){
            $anzeige_txt = $t->nodeValue;
            $anzeige_txt = utf8_decode($anzeige_txt);
            $sql = "INSERT INTO testing (`firmen_id`,`anzeige_id`,`anzeige_txt`) VALUES ('$firma_id','$anzeigen_id','$anzeige_txt')";
            $sql_inserted = mysql_query($sql);
            if($sql_inserted){
                echo "'$anzeigen_id' from $xml_filename inserted<br />";
            }

        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:25:20+00:00Added an answer on June 15, 2026 at 2:25 pm

    Well I will post an answer because it will be more clear to ask you some code example, etc..

    First of all, when you got an unexplicable case like this: you should debug!

    In your case, you display a message when the query success. But what if the query failed? You should handle an error message to see what’s going on. Something like that:

    if($sql_inserted)
    {
      echo "'$anzeigen_id' from $xml_filename inserted<br />";
    }
    else
    {
      throw new Exception(mysql_error() . '. SQL: '.$sql);
    }
    

    There will be an exception when a query failed. You will have the error message (mysql_error()) and the query that failed ($sql).

    What could be a problem, is that you didn’t escape value you put inside your query. So, if there is a ' inside a variable, it will break the query. You should escape them:

    $firma_id    = mysql_real_escape_string($firma_id);
    $anzeigen_id = mysql_real_escape_string($anzeigen_id);
    $anzeige_txt = mysql_real_escape_string($anzeige_txt);
    

    So you will have a final code like this:

    foreach($text as $t)
    {
      $firma_id    = mysql_real_escape_string($firma_id);
      $anzeigen_id = mysql_real_escape_string($anzeigen_id);
      $anzeige_txt = mysql_real_escape_string(utf8_decode($t->nodeValue));
    
      $sql = "INSERT INTO testing (`firmen_id`,`anzeige_id`,`anzeige_txt`) VALUES ('$firma_id','$anzeigen_id','$anzeige_txt')";
      $sql_inserted = mysql_query($sql);
    
      if($sql_inserted)
      {
        echo "'$anzeigen_id' from $xml_filename inserted<br />";
      }
      else
      {
        throw new Exception(mysql_error() . '. SQL: '.$sql);
      }
    }
    

    By the way, as I told you please, don’t use mysql_* functions in new code. They are no longer maintained and the deprecation process has begun on it. See the red box? Learn about prepared statements instead, and use PDO, or MySQLi – this article will help you decide which. If you choose PDO, here is a good tutorial.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've met an unknown error while inserting data into the database. The LogCat had
I had been working on server side(c#) for a couple of years. But now
I know this question had been asked a hundred times, but I have difficulties
All text field values in my database had been converted to upper case. I
Okay so I am running into issues inserting a file into my database as
I'm not that cocky to believe Doctrine 2 is broken, but I couldn't actually
Has anyone had problems inserting a PNG file into a word document, using a
I've been arguing for some time against embedding server-side tags in JavaScript code, but
My normal process for inserting into one table and then getting the ID back
I had been trying to get the tag name and its value in java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.