Jump to content

Convert Form Text to HTML for database


mjurmann

Recommended Posts

Hello there! I am trying to convert text input by a user including line breaks and ' ' to html markup so that when it is inserted in the database, the ' and line breaks are converted into code so that when the information put in the database is echoed out, it does not stop echoing right before the ' and ignore the line breaks!

Help anyone?
Link to comment
Share on other sites

GetSQLValueString??

What it is this? sorry i didn't understand you.
but i can say you can use it directly in insert query too.
see this example.

$sql="insert into table_name (id,name) values ('$id','".addslashes($_POST['name']."')";

Let us know if you still had  a problem with it please post your piece of code here . :)

Joshi.
Link to comment
Share on other sites

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "addlisting")) {
  $insertSQL = sprintf("INSERT INTO uploaded (type, name, URL, description, address, phone_number, email, imageURL) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
                      GetSQLValueString($_POST['form_menu'], "text"),
                      GetSQLValueString($_POST['form_name'], "text"),
                      GetSQLValueString($_POST['form_url'], "text"),
                      GetSQLValueString($_POST['form_description'], "text"),
  GetSQLValueString($_POST['address'], "text"),
  GetSQLValueString($_POST['phone'], "text"),
  GetSQLValueString($_POST['email'], "text"),
                  GetSQLValueString($_POST['uploaded'], "text"));

I want DESCRIPTION to be the field that has the slashes applied to it. How do I write that?
Link to comment
Share on other sites

I think you are using dreamweaver generated code for form insertion.anyway..


if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "addlisting")) {
  $insertSQL = sprintf("INSERT INTO uploaded (type, name, URL, description, address, phone_number, email, imageURL) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
                      GetSQLValueString($_POST['form_menu'], "text"),
                      GetSQLValueString($_POST['form_name'], "text"),
                      GetSQLValueString($_POST['form_url'], "text"),
                      GetSQLValueString($_POST['form_description'], "text"),
                  GetSQLValueString($_POST['address'], "text"),
                  GetSQLValueString($_POST['phone'], "text"),
                  GetSQLValueString($_POST['email'], "text"),
                      GetSQLValueString($_POST['uploaded'], "text"));

Replace it with this

[code]
<?php
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "addlisting")) {
  $insertSQL = sprintf("INSERT INTO uploaded (type, name, URL, description, address, phone_number, email, imageURL) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
                      "GetSQLValueString($_POST['form_menu'], "text")",
                      GetSQLValueString($_POST['form_name'], "text"),
                      GetSQLValueString($_POST['form_url'], "text"),
                      ".addslashes(GetSQLValueString($_POST['form_description'], "text")).",
                  GetSQLValueString($_POST['address'], "text"),
                  GetSQLValueString($_POST['phone'], "text"),
                  GetSQLValueString($_POST['email'], "text"),
                      GetSQLValueString($_POST['uploaded'], "text"));
?>
[/code]


Try it.
Link to comment
Share on other sites

Oh Sorry!
[code]
<?php
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "addlisting")) {
  $insertSQL = sprintf("INSERT INTO uploaded (type, name, URL, description, address, phone_number, email, imageURL) VALUES ('$_POST[form_menu]','$_POST[form_name]','$_POST[form_url]', '".addslashes($_POST[form_description])."',          '$_POST[address]','$_POST[phone]','$_POST[email]','$_POST[uploaded]'));
?>
[/code]

Try this now!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.