Re: [Newbie] Questions...

From: Date: Thu, 08 May 2003 23:46:39 +0000
Subject: Re: [Newbie] Questions...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146939@lists.php.net to get a copy of this message
The Head Sage wrote:
Hey, Hey.
I've read the manual entry on preg_replace() and i've used google for help but i'm still confused as it all looks horribly complicated.. That's because of the complex things you can do with it. If you don't need regex, use str_replace() or similar.
What i want to do is when a user submits a quote for example "<@TheHeadSage> lol" i want to remove the <>'s and replace them with &lt; and &gt; so they display properly on a webpage. How would i go about this using preg_replace() or another function like it? Use htmlspecialchars() or htmlentities().
Also, my second question which ties into the whole quote thing, how do i select random rows from a MySQL database? So i can get a random quote every time the user reloads the page or a new visitor arrives. Use a query like SELECT * FROM table ORDER BY RAND().
Thanks again, You're welcome.
-- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.

« previous php.general (#146939) next »