Solved

2 problems on displaying database-data

Posted on 2002-06-22
11
220 Views
Last Modified: 2010-07-27
Hello all,

I have 2 problems today :)

I developed a MySql-PHP script that act mostly like php-nuke

put I had 2 problems
first : when I display a sentece of more than one word in a text box ==> only the first word is displayed ! but when I use another form obect like text area ==> the whole sentece is displayed .


Second : I allowed HTML code to be displayed in defualt .. but when I use <table> tag in the topics ==> there is a big white lines before the table ... and when I save the displayed page from my browser (File=>save) and then display it using front page ==> I see more colonms than I created using the <table> code .

I hope that I explain my problems correctly :) ... and I really hope that I can a real soluion to my problems :(

Thanks in advanced,,,
0
Comment
Question by:php_lady
11 Comments
 
LVL 5

Expert Comment

by:Hamlet081299
ID: 7102280
Really hard to answer without seeing some source???
0
 

Accepted Solution

by:
vk1981 earned 100 total points
ID: 7104350
first problem:

I think u display text like this:
<input type=text value=<? echo $sometext; ?>

This is correct:
<input type="text" value="<?echo $sometext;?>">
or
echo "<input type='text' value='".$sometext."'>";

second problem:
I need more details about your problem...
0
 
LVL 40

Assisted Solution

by:Richard Quadling
Richard Quadling earned 100 total points
ID: 7106865
If you are embedding the text into the value inside an <input> tag, you will need to watch out for " within the text as these will be though of as the closing " for the value property.

Try

echo "<input type='text' value='" . addslashes($sometext) . "'>";

Richard.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:php_lady
ID: 7107486
Hello all :)

Thank you very much ... the first problem is solved now with your help :)

regarding the second problem .... here is sample code :
<?php
$mybody = stripslashes($row[lesbody]);
$mybody = nl2br($mybody);
echo $mybody;
?>

the problem is from the nl2br(); function .
I need it so when users enters new lines in the adding form , the text is displayed correctly with there lines .
is there any altirnative soluion ?
what should I do ?

and thanks all again :)
0
 

Expert Comment

by:vk1981
ID: 7107548
Second problem:
Can i see this thml code?
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7107576
What is the wrapping property set to in the <textarea> on the original form.

This will control what is sent to the server initially.

<textarea wrap="physical"> will send you the line breaks which nl2br() can deal with, but if you put this back into a textarea for editing, put it in WITHOUT nl2br().

I think.

0
 

Expert Comment

by:vk1981
ID: 7107985
Try:

ex1:
<TEXTAREA>
<? echo str_replace ("<br>", "", $sometext); ?>
</TEXTAREA>

or

ex2:
<TEXTAREA>
<? echo str_replace ("<br />", "", $sometext); ?>
</TEXTAREA>

or

U must know how nl2br works... ;)
U should know how nl2br works, i.e. u should know what PHP really puts instead of '\n', if it puts '<br>' use ex1, if - '<br />' use ex2...

0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7108074
If you are storing the newlines you are sent from the client, then you only need to convert them to <br> if you intend to display the text OUTSIDE of a TEXTAREA; i.e. in normal HTML.

This textarea (the one I'm typing in right now) is set to wrap="virtual".

The will give all the line feeds and you can use nl2br when you want to put this on the screen (like all the comments here), but if you want to put it back into an edit field, you don't use nl2br. You do nothing except echo the field back to the user within <textarea> tags.
0
 
LVL 11

Expert Comment

by:shmert
ID: 9643582
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Split: vk1981/rquadling
Please leave any comments here within the next seven days.
               
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
               
Sam Barnum
EE Cleanup Volunteer              
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question