Loosing my formatting in a var

Joined: 11/28/2008

I have an admin page,
I use a page to copy and paist an IRCd MOTD into a dbase
and its formatting (lines and spaces all go in fine and it looks right)

now I go to the actual site, where i made simple code to have it to display the MOTD
But it's lost the formatting

I'll show you a simple version of what ive done for the admin pages

motd.php

<?PHP
include("********");
$result = mysql_query("SELECT * FROM motd");

while($row = mysql_fetch_array($result))

$motd1 = $row["motd"];

?>
MOTD





Whats new
<?PHP echo $motd1; ?>


motdp.php

<?php
@extract($_POST);
include(
"********");
$motd = urldecode($motd);
$newdate = date("M/j Y");

$thenum = '1';

$dotheupdatetq = "UPDATE motd SET motd='$motd', datenew='$newdate' WHERE idmot='$thenum'";
$result = mysql_query($dotheupdatetq)
or die (
"update broke");
?>

The Update Was Completed Click Here
To Return Or Click Here To Go To The Admin
Index

between those 2 pages,
in motd.php in the admin page any ways, the formating is right, the lines are one after the other and it looks right

now here is the regular motd.php

<?PHP
include("**********");
$resultggb = mysql_query("SELECT * FROM motd");

while($row = mysql_fetch_array($resultggb))

$motd = $row["motd"];
$fdatenew1 = $row["datenew"];

?>

<?PHP echo $motd; ?>



<?PHP echo $fdatenew1; ?>

And on this page the MOTD comes out all jumbeled together with no formatting, I can't figure out what i've missed.

G&G Podcast Host
Matt Farina's picture
Joined: 06/01/2006
PDO, escape strings

A few suggestions....

1) Use PDO for your database communications. If you don't switch to PDO I would STRONGLY suggest properly sanitizing and escaping the info you put into the database. Depending on the values sent in you could have some issues.

2) Don't extract $_POST into the script. Doing this is considered a bad idea. Someone could post a variable you aren't expecting and mess up your script.

Now, what does the source of the printed MOTD look like? Not just how it's displayed on the screen.

Matt Farina
Geeks and God Former Co-Host
www.mattfarina.com

Joined: 11/28/2008
$_Post is the way i know how

$_Post is the way i know how to do things,

Please forgive my ignorance but what is PDO, I'm used to doing things a certain way, thats how I've always done them, I might have to find a good book on PDO

if your used to irc, there is a MOTD when you first enter the network on your status bar,

this is an example of one and how it looks formated a small part of it.

essage of the Day, irc.IRC.net
-
- 23/1/2009 18:24
- is the last built date of this server.
-
- IRC.irc.NET - IRC IRC Network
- ======================================
-
- Location: New York, NY
-
- ======================================================
- Owner:
- kind
-
- Admin:
- ReZNiC
- BlueFire
-
- Co-Admin(s):
- DragonFlu
-
- Newnet Core Administrator(s):
- ReZNiC
- Kevin

this is how mine is coming

Welcome To Irc.irc.com - - Thanks For Using My Server To Connect With Your Friends. Please Behave And Have A - Great Time. - let us all pray that tyler returns quick - Suggested Channels: - ************************************ - #Services - Services and General Help Channel. - #Help - IRC's Help Channel - #Idle-Chat - General Idle Chat. - #Beginners - IRC Beginner Help Channel. - #vhost - For Help With HostServ. - #IRC - Server Channel. - ************************************ - ***** Admins ***** - - DavMathew - Trackker122 - krashking - - ***** Opers

its taking out all the spaces on me :/

Joined: 11/28/2008
:/

does anyone have any ideas?

Joined: 10/18/2008
PDO is a php abstraction

PDO is a php abstraction layer for dealing with db's. It's just really nice and help prevent people hacking your db. But you can sanitize all your insert variables to prevent someone from deleting your entire db.

Try using nl2br before inserting into your db. That way you convert the line breaks into html br's.

You could also use explode to split the string on "-" or use str_replace to swap the "-" with "br>-".

/ * Begin Signature */
It's a strange thing about determined seekers-after-wisdom that, no matter where they happen to be, they'll always seek that wisdom which is a long way off. Wisdom is one of the few things that looks bigger the further away it is.

Joined: 11/28/2008
Thank you so much :) I'm

Thank you so much :)

I'm going to read up on PDO I really apreciate your help