Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1660 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

mysql error when inserting data

Thread title: mysql error when inserting data
Closed Thread    
    Thread tools Search this thread Display Modes  
12-31-2007, 04:26 PM
#1
phpintheusa is offline phpintheusa
phpintheusa's Avatar
Status: I'm new around here
Join date: Dec 2007
Location: Tennessee
Expertise:
Software:
 
Posts: 20
iTrader: 0 / 0%
 

phpintheusa is on a distinguished road

Send a message via MSN to phpintheusa

  Old

I just want to recommend that you use a function like this instead of using addslashes(). Addslashes is a security blanket full of holes.

Code:
function validateit($value) {
	$value = str_replace('javascript:', '_', $value);
	$value = str_replace('document.location', '_', $value);
	$value = str_replace('vbscript:', '_', $value);
	$value = str_replace('<marquee', '_', $value);
	$value = str_replace('<script', '_', $value);
	$value = str_replace('?php', '_', $value);
	$value = mysql_real_escape_string(strip_tags(htmlentities(trim($value))));
	return $value;
}
This will help against sql injections, cross site scripting, and all that jazz.

12-31-2007, 04:45 PM
#2
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

Originally Posted by phpintheusa View Post
I just want to recommend that you use a function like this instead of using addslashes(). Addslashes is a security blanket full of holes.

Code:
function validateit($value) {
	$value = str_replace('javascript:', '_', $value);
	$value = str_replace('document.location', '_', $value);
	$value = str_replace('vbscript:', '_', $value);
	$value = str_replace('<marquee', '_', $value);
	$value = str_replace('<script', '_', $value);
	$value = str_replace('?php', '_', $value);
	$value = mysql_real_escape_string(strip_tags(htmlentities(trim($value))));
	return $value;
}
This will help against sql injections, cross site scripting, and all that jazz.
Dont manually escape all the HTML. Use htmlspecialchars and unescape the values that you want in (<b><i>, ect.)

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed