Jump to content

unable to place • in form fields from mysql


jasonc

Recommended Posts

For some reason when I try to insert in to my editor page the character • in to the longDescription textarea of the field it shows as a square with four boxes and letters and numbers instead?

 

How do I correctly have it show as it does in mysql and when I echo it on the pages.

 

here are some of the lines in my code that gets the database entries and then echos out the form...

 

$getproducts = mysql_query("SELECT * FROM `products` WHERE `Pid` = '".$posts['product_id']."' LIMIT 1");
$numberofrows = mysql_num_rows($getproducts) or die(mysql_error());
$product_id = mysql_result($getproducts, 0, "Pid");
$longDescription = stripslashes(mysql_result($getproducts, 0, "longDescription")); $posts['longDescription'] = $longDescription;

 

and my form...

<textarea name="longDescription" cols="50" rows="8"><?=$posts['longDescription'];?></textarea>

 

and here is my database...

CREATE TABLE IF NOT EXISTS `products` (
  `Pid` text NOT NULL,
  `productTitle` text NOT NULL,
  `longDescription` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `products`
--

INSERT INTO `products` (`Pid`, `productTitle`, `longDescription`) VALUES
('1234', 'The Products Title', '• Something about the product\n• Easy to assemble\n• H:72 x Dia:39cm');

Link to comment
Share on other sites

What is the 'content-type' of your page (<meta http-equiv="Content-Type" content=...) , and the doctype?

 

Secondly, it looks like you are taking a value from the $_POST and inserting it directly into your database, you should be at least running mysql_real_escape_string on any content from the user before using it in any mysql queries. (http://www.phpfreaks.com/tutorial/php-security)

Link to comment
Share on other sites

Ah, I had not even added the <html> or other tags yet.

 

I am actually working on the edit page as I manually add the products to mysql using excel.

 

And yes I shall be using mysql_real_escape_string() on all content !

 

Added the <html> and head tags and all seems to be showing as it should be.

 

thank you for highlighting this, otherwise i may not have got there.

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.