MortimerJazz Posted January 28, 2007 Share Posted January 28, 2007 Hiya - I wasn't quite sure where to post this ...I've designed a type of PM system. The idea is that a dynamically generated PM is sent to a user.However, I'd like this PM to include clickable links and also format it with new lines etc. So my question is, is it possible to store HTML in a MySQL database? When I've tried storing regular href's, I keep getting error messages on my page. Am I doing something wrong?Thanks, Quote Link to comment Share on other sites More sharing options...
corbin Posted January 28, 2007 Share Posted January 28, 2007 make sure you mysql_real_escape any data put into the database(make sure to stripslashes() it if magic quotes are on)... That might not be the problem, but it probably is... Quote Link to comment Share on other sites More sharing options...
lilman Posted January 28, 2007 Share Posted January 28, 2007 Yes you can store HTML tags into a MySQL database. Paste your code and I'll see if I can help you out. Quote Link to comment Share on other sites More sharing options...
MortimerJazz Posted January 28, 2007 Author Share Posted January 28, 2007 Thanks lilman.The code's quite simple so far:[code]$message="The following person has expressed an interest in your toy:<p>Reference Number: <a href="http://www.mysite.com/viewtoy.php?toy=$ref<p>User: $username";$sql = mysql_query("INSERT INTO prv_msg (sender, recipient, subject, message, sell_msg, date_sent, ip_sender) VALUES('$username', '$recipient', '$subject', '$message', '1', now(), '$ip')") or die (mysql_error());[/code] Quote Link to comment Share on other sites More sharing options...
lilman Posted January 28, 2007 Share Posted January 28, 2007 Try this[code]$message="The following person has expressed an interest in your toy:<p>Reference Number: <a href=\"http://www.mysite.com/viewtoy.php?toy=$ref\"<p>User: $username";[/code]I added \ in front of your quotation marks, if you don't PHP will assume that is the end of your statement when in act it is not. Give that a run and let me know if it works or not. Quote Link to comment Share on other sites More sharing options...
Orio Posted January 28, 2007 Share Posted January 28, 2007 If you are still having trouble, you could always encode the PM using base64 and then decode it. It will take a bit more memory (about 33% more) but it's comfortable.Orio. Quote Link to comment Share on other sites More sharing options...
rantsh Posted January 28, 2007 Share Posted January 28, 2007 [quote author=lilman link=topic=124442.msg515593#msg515593 date=1170013916]Try this[code]$message="The following person has expressed an interest in your toy:<p>Reference Number: <a href=\"http://www.mysite.com/viewtoy.php?toy=$ref\"<p>User: $username";[/code]I added \ in front of your quotation marks, if you don't PHP will assume that is the end of your statement when in act it is not. Give that a run and let me know if it works or not.[/quote]Could you achieve this easily with the addslashes function??? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 28, 2007 Share Posted January 28, 2007 "Could you achieve this easily with the addslashes function???"Yes, or you could use htmlentities Quote Link to comment Share on other sites More sharing options...
corbin Posted January 28, 2007 Share Posted January 28, 2007 When assigning variables you cannot use quotes inside of the variable with out escaping them if you use quotes around the variable content (dunno if that made sense)...So you could not assign the variable to htmlentities it... but if it was input by a user then you could... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.