Solved

2 problems on displaying database-data

Posted on 2002-06-22
11
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

 

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

Technology Partners: 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!

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

636 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