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

  • Home
  • SEARCH
  • 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 8202841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:20:02+00:00 2026-06-07T07:20:02+00:00

I coded some Form to send Text to MySql. One of my Problem is

  • 0

I coded some Form to send Text to MySql. One of my Problem is to keep the line break. Found some Code over Google but i don’t have any idea how i could use it. Some tries was not really successful.

The Code i found is that below which i don’t know how to set up.

 function my_nl2br($string){
    $string = str_replace("\n", "<br />", $string);
        if(preg_match_all('/\<pre\>(.*?)\<\/pre\>/', $string, $match)){
            foreach($match as $a){
            foreach($a as $b){
            $string = str_replace('<pre>'.$b.'</pre>', "<pre>".str_replace("<br />", "", $b)."</pre>", $string);
            }
        }
    }
return $string;
}

Another code i found is this but if i try to read it from database the line break will not work.

if (isset($_POST['submit'])) 
{ 
    $text = trim($_POST['text']); 
    $text = stripslashes($text); 
    $text = htmlspecialchars($text); 

    echo 'you entered:<br><br>' . nl2br($text); 
} 

This is my Code where i want to implant it.

  if(isset($_POST['title']))
      {
        $title = mysql_real_escape_string(htmlspecialchars($_POST['title']));
        $description = mysql_real_escape_string(htmlspecialchars($_POST['description']));
        $applepart = mysql_real_escape_string(htmlspecialchars($_POST['applepart']));
        $partnumber = mysql_real_escape_string(htmlspecialchars($_POST['partnumber']));
        $productcode = mysql_real_escape_string(htmlspecialchars($_POST['productcode']));
        $compatibility = mysql_real_escape_string(htmlspecialchars($_POST['compatibility']));
        $url_bild = mysql_real_escape_string(htmlspecialchars($_POST['url_bild']));
        $price = mysql_real_escape_string(htmlspecialchars($_POST['price']));
        $insert = mysql_query("INSERT INTO `adressbuch` (`title`,`description`,`applepart`,`partnumber`,`productcode`,`compatibility`,`url_bild`,`price`) VALUES ('$title','$description','$applepart','$partnumber','$productcode','$compatibility','$url_bild','$price')");
        if (!$insert)
        {
          die('Eintrag konnte nicht gespeichert werden: ' . mysql_error());
        }
      }

    ?>

    <form method="POST" action="?page= ">
      <span>Neuer Eintrag:</span> <br />
      <span>Title</span><input type="text" name="title" /> <br />
      <span>Description</span><textarea cols="16" rows="5"  name="description"></textarea> <br />
      <span>Apple Part</span><input type="text" name="applepart" /> <br />
      <span>Part Number</span><input type="text" name="partnumber" /> <br />
      <span>Product Code</span><input type="text" name="productcode" /> <br />
      <span>Compatibility</span><input type="text" name="compatibility" /> <br />
      <span>Image</span><input type="text" name="url_bild" /> <br />
      <span>Price</span><input type="text" name="price" /> <br />
      <input type="submit" value="Speichern"/> <br />
    </form>

cheers guys

  • 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-07T07:20:03+00:00Added an answer on June 7, 2026 at 7:20 am

    To store title in the database, try:

    $title = real_escape_string(nl2br(htmlspecialchars($_POST['title'])));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are testing some code to send email messages using Gmail from a form,
I'm not sure what the problem is here, I've inherited some code form Zend
I am trying to port some code form java do F# that generates a
I'm using below code to check some form fields and render datatable table on
I am trying to get some form data from POST method. Here's the code
Here is some code on the javascript side for form-based uploads: iframe.setAttribute('src', 'javascript:false;'); I'm
I have some code to display a long list of languages inside Rails form
How can I automatically run some code when a WPF form is closed?
I would like to run some code onload of a form in WPF. Is
I am working on some code, basically I have a form. On that form

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.