473,324 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Problem displaying a mysql database field

Hi,

I have a varchar field in a MySQL database that contains a line of text
like so:

"This is a line if text"

The double quotes are included in the database field.

I cannot seem to display it on my HTML page, it always shows as blank.
I have tried using both the stripslashes() and the html_entity_decode()
but it still shows as blank.

An code example I am trying is as follows:
<?php
echo
stripslashes(html_entity_decode($my_variable_from_ a_mysql_database));
?>

How can I display this please???

Tks,
Don

Jun 20 '06 #1
2 1642
donpro wrote:
Hi,

I have a varchar field in a MySQL database that contains a line of text
like so:

"This is a line if text"

The double quotes are included in the database field.

I cannot seem to display it on my HTML page, it always shows as blank.
I have tried using both the stripslashes() and the html_entity_decode()
but it still shows as blank.

An code example I am trying is as follows:
<?php
echo
stripslashes(html_entity_decode($my_variable_from_ a_mysql_database));
?>

How can I display this please???

Tks,
Don

Hmm.. my first intuition is to ask: are you sure the quotes are in the
database ? (i.e. they haven't been removed when inserting)
Have you looked at the database through phpMyAdmin or any such tool ?

Test what you *really* get back from the database query to make sure you
actually get the string properly from the database by doing a:
print_r($query_result);

If the quotes are there, try this for displaying:
print htmlentities(stripslashes($my_variable_from_a_mysq l_database),
ENT_QUOTES);

Good luck,
Juliette
Jun 21 '06 #2
On or about 6/20/2006 8:54 PM, it came to pass that Juliette wrote:
donpro wrote:
Hi,

I have a varchar field in a MySQL database that contains a line of text
like so:

"This is a line if text"

The double quotes are included in the database field.

I cannot seem to display it on my HTML page, it always shows as blank.
I have tried using both the stripslashes() and the html_entity_decode()
but it still shows as blank.

An code example I am trying is as follows:
<?php
echo
stripslashes(html_entity_decode($my_variable_from_ a_mysql_database));
?>

How can I display this please???

Tks,
Don

Hmm.. my first intuition is to ask: are you sure the quotes are in the
database ? (i.e. they haven't been removed when inserting)
Have you looked at the database through phpMyAdmin or any such tool ?

Test what you *really* get back from the database query to make sure you
actually get the string properly from the database by doing a:
print_r($query_result);

If the quotes are there, try this for displaying:
print htmlentities(stripslashes($my_variable_from_a_mysq l_database),
ENT_QUOTES);

Good luck,
Juliette

Suggest checking if magic quotes is on before doing a stripslashes
Here's how I handle comments on my site. It allows for the preservation
of both quote characters(single and double) and honors newlines
converting them to <br />

When storing the data:
if (get_magic_quotes_gpc())
{
$a = stripslashes ($_POST[Pre_Comments]);
$a = htmlspecialchars($a, ENT_QUOTES);
}
else
$a = htmlspecialchars($a, ENT_QUOTES);

On the HTML text generation after getting info from the database
nl2br($i[Pre_Comments])
Jun 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Mosher | last post by:
Hi all, I have an issue with php and/or mysql. I have a php form that writes "items" to a mysql database, including a description of the item. On the mysql server, "magic_quotes_gpc" is ON. I...
2
by: Dariusz | last post by:
Below is part of a code I have for a database. While the database table is created correctly (if it doesn't exist), and data is input correctly into the database when executed, I have a problem...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
6
by: yoshitha | last post by:
hi db : sql server 2000 lan : C#.net(ASp.Net) in my database table there are 2 fileds of data type datatime. in field 1 i'm storing date in field 2 i'm storing time.
2
by: Brave | last post by:
I'm hoping someone can help me with a small issue. I have an asp page that displays informaton from an Access database. I want to create a form that allows users to display only data that...
13
by: David W. Fenton | last post by:
I've been struggling the last two days with something I thought was very easy, which is to open a web page with a form on it and populate the form with data passed in a query string (either POST or...
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
2
by: xtremebass | last post by:
Hi , i have created table with only one field for the type of varchar(8000) . I am stroed bulk amount of data in that field. The size i have specified is enough for the field to occupy my data....
13
by: xtremebass | last post by:
Hi , i have created table with only one field for the type of varchar(8000) . I am stroed bulk amount of data in that field. The size i have specified is enough for the field to occupy my data....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.