Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 05-16-2005, 06:56 PM Formatting
SpottyDog's Avatar
Skilled Talker

Posts: 82
Trades: 0
Hi,

I have made a script to send a message to an sql database and then retrieve it again on my homepage. The trouble i am having is that i am inserting html into the database and when i echo it onto my homepage it echo's out the html instead of using it.

Eg. instead of it saying TEXT HERE
it says <b>TEXT HERE</b>

How do i solve this problem?

Thanks
SpottyDog is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-16-2005, 07:00 PM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
paste your code in here with that i can help out..
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 05-16-2005, 07:04 PM
SpottyDog's Avatar
Skilled Talker

Posts: 82
Trades: 0
.

Last edited by SpottyDog; 05-17-2005 at 01:57 PM..
SpottyDog is offline
Reply With Quote
View Public Profile
 
Old 05-16-2005, 07:22 PM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
See if u really wanna retrive a data E.g say i have two forms Username and Age, wen user fill in those info. and i wanna retrieve that, i will rather say
<? echo_$POST["Username"];
echo_$POST["Username"];
?>

Then in that case use this code <?echo "$home1"; ?> text that
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 05-16-2005, 07:25 PM
SpottyDog's Avatar
Skilled Talker

Posts: 82
Trades: 0
yes but then the posted data wont stay on my home page untill it is updated right?

i want it to come from the database not from POST
SpottyDog is offline
Reply With Quote
View Public Profile
 
Old 05-16-2005, 07:41 PM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
It will wen using a form ok let check your code <?php
$sql = mysql_query("Select home From site"); <------

$sql = mysql_query("SELECT home From site") WHERE blah blah blash = blah blah
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.

Please login or register to view this content. Registration is FREE
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 05-16-2005, 07:44 PM
SpottyDog's Avatar
Skilled Talker

Posts: 82
Trades: 0
ok i really dont understand at what your getting at here. I am still a noob at this lol. Can you construct the script that i should use to retrieve my data while keeping the formatting.
SpottyDog is offline
Reply With Quote
View Public Profile
 
Old 05-16-2005, 09:46 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
ok then dude, i've never really seen this problem before, but i have a feeling it's just the way you're echoing it really.

At the moment you're not telling php to do anything to it, just echoing the data not the information. So let's tell PHP to wake the **** up. Try this:

[/PHP]<?php
echo("$home1");
?> [PHP]

Using those brackets and the quote marks makes all the difference. Also, you should have <?php at the beginning of all PHP encasing!
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 05-17-2005, 07:10 AM
SpottyDog's Avatar
Skilled Talker

Posts: 82
Trades: 0
no, im affraid this still doesn't work

Im sure somebody must of come accross this problem before?
SpottyDog is offline
Reply With Quote
View Public Profile
 
Old 05-17-2005, 07:17 AM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
oh, have you actually made sure you've output HTML headers?? like <HTML><BODY> etc etc ??
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 05-17-2005, 07:23 AM
SpottyDog's Avatar
Skilled Talker

Posts: 82
Trades: 0
yes i those tags. The php that is getting the info is above the head and the echo bit is in the body
SpottyDog is offline
Reply With Quote
View Public Profile
 
Old 05-17-2005, 07:28 AM
SpottyDog's Avatar
Skilled Talker

Posts: 82
Trades: 0
ok

Last edited by SpottyDog; 05-17-2005 at 01:58 PM..
SpottyDog is offline
Reply With Quote
View Public Profile
 
Old 05-17-2005, 12:37 PM
SpottyDog's Avatar
Skilled Talker

Posts: 82
Trades: 0
anyone????
SpottyDog is offline
Reply With Quote
View Public Profile
 
Old 05-17-2005, 12:49 PM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
So tell me now do you wanna retrive your data from your DATABASE.. from all wat u saying here i guess thats wat u wanna do. ??? huh ?
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.

Please login or register to view this content. Registration is FREE
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 05-17-2005, 01:00 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
He said that in his first post I think.

SpottyDog, can you check the HTML source that reaches your browser? I'm guessing that what is actually in your database is along the lines of &lt;b&gt;TEXT HERE&lt;/b&gt; .

Somewhere in your script to insert things into the database did you make use of the function htmlspecialchars() ? That will transform < int &lt;, ' into &quot; etc, and is a security thing so that people can't submit eg <SCRIPT> tags into your forms. What it means is that when you echo part of the database, the html entity (that's what &lt; , &gt; are) get's printed instead of interpreted as HTML.

You either need to store things away into your database differently, or map from the entities back to the characters manually. You can do this by writing:
PHP Code:

echo html_entity_decode($home1); 
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 05-17-2005, 01:09 PM
SpottyDog's Avatar
Skilled Talker

Posts: 82
Trades: 0
0beron my friend, you are a legend!

It worked. I did see that in the source code when i checked it but wasnt sure how to fix it

Thankyou So Much
SpottyDog is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Formatting
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.53203 seconds with 12 queries