Irish SEO,  Marketing & Webmaster Discussion

 

Htmlentities

This is a discussion on Htmlentities within the Coding Help forums, part of the Webmaster Help category; Hi everyone. Little Problem..... I have a php form that submits data to a db. But if some one put ...


Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Coding Help

Register Forum Rules FAQDonate Members List Calendar Search Today's Posts Mark Forums Read


Notices

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 14-01-2008, 10:26 AM
Joseph Grogan's Avatar
Wannabe Geek
 
Join Date: Jul 2007
Location: Bogland, beside birr...Cloghan
Posts: 147
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Joseph Grogan will become famous soon enough
Send a message via Skype™ to Joseph Grogan
Default Htmlentities

Hi everyone. Little Problem.....

I have a php form that submits data to a db. But if some one put in a ' sign it fecks up the code. I think Htmlentities can get me out of this but not sure how to use it.

I put this is the code into the part that displays the results of the db

PHP Code:
htmlentities($result_row[4]) 
But I dont know what to put in the part that a user submits data.

Hope that makes sense..

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 14-01-2008, 10:40 AM
Frodo's Avatar
Ciaran Rooney - Weeno Ltd
 
Join Date: Jan 2007
Location: London
Posts: 339
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Frodo has much to be proud ofFrodo has much to be proud ofFrodo has much to be proud ofFrodo has much to be proud ofFrodo has much to be proud ofFrodo has much to be proud ofFrodo has much to be proud ofFrodo has much to be proud ofFrodo has much to be proud of
Send a message via MSN to Frodo Send a message via Skype™ to Frodo
Default

PHP Code:
$somevalue $_POST['somevalue'];
$somevalueclean mysql_real_escape_string($somevalue);

$query "INSERT INTO `aTable` (`somevalue`) VALUES ('$somevalueclean')";

$result mysql_query($query$connectionvariable
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 14-01-2008, 10:55 AM
Joseph Grogan's Avatar
Wannabe Geek
 
Join Date: Jul 2007
Location: Bogland, beside birr...Cloghan
Posts: 147
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Joseph Grogan will become famous soon enough
Send a message via Skype™ to Joseph Grogan
Default

Thanks for that frodo....

Much appriciated
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 14-01-2008, 11:45 AM
TheMenace's Avatar
Hardcore Geek
 
Join Date: Nov 2006
Posts: 741
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
TheMenace will become famous soon enough
Send a message via MSN to TheMenace
Default

Alternatively you can use escape quotes - replace all occurrences of ' with ''. I'd have a look at the security issues behind database inserts as well - preventing SQL injections, etc. These are the basics of safe Web app development.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 14-01-2008, 12:03 PM
Joseph Grogan's Avatar
Wannabe Geek
 
Join Date: Jul 2007
Location: Bogland, beside birr...Cloghan
Posts: 147
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Joseph Grogan will become famous soon enough
Send a message via Skype™ to Joseph Grogan
Default

While we are on the issue of internet security. How do you go about changing urls so they dont display id=2 or something to that effect.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 14-01-2008, 12:19 PM
Frodo's Avatar
Ciaran Rooney - Weeno Ltd
 
Join Date: Jan 2007
Location: London
Posts: 339
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Frodo has much to be proud ofFrodo has much to be proud ofFrodo has much to be proud ofFrodo has much to be proud ofFrodo has much to be proud ofFrodo has much to be proud ofFrodo has much to be proud ofFrodo has much to be proud ofFrodo has much to be proud of
Send a message via MSN to Frodo Send a message via Skype™ to Frodo
Default

Look into mod rewrite, for example if you use apache create a file called .htaccess and put the following into it.

It will redirect all calls to yourdomain.com/2 to youdomain.com/index.php?id=2
sliently in the background leaving yourdomain.com/2 as the address in the browser

Code:
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ index.php?id=$1 [L]
__________________

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 14-01-2008, 12:27 PM
Joseph Grogan's Avatar
Wannabe Geek
 
Join Date: Jul 2007
Location: Bogland, beside birr...Cloghan
Posts: 147
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Joseph Grogan will become famous soon enough
Send a message via Skype™ to Joseph Grogan
Default

cool. That a great help...... I will get it going soon hopefully


Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
htmlentities

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT +1. The time now is 05:00 PM.


Powered by: vBulletin Version 3.7.3, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Hosted in Ireland by Blacknight - Test your ISP |Irish Hosting Directory| Armchair.ie|Logo by Eden Web Design|Avatars by Afterglow |Latest Blog Entries | VPS HostingAd Management by RedTyger

Search Engine Friendly URLs by vBSEO 3.2.0