PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old May 8th, 2008, 05:10 AM
wilorichie wilorichie is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Brisbane
Posts: 151 wilorichie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 3 m 8 sec
Reputation Power: 2
SQL Security

Hey guys,

Im really worried about security on this site, and would like to see if I can get any more suggestions / tips from the many heads we have out here.

This is my form check function so far:

Code:
// If they entered data that should be going into an sql database, then make it more secure //
function sql_form($v){

	// if magic quotes are on, turn them off to use GOOD backslashes //
	if(get_magic_quotes_gpc()){ $v = stripslashes($v); }
	
	// if they entered nothing, simply give it null //
	if($v == ""){ $v = "NULL"; }
	
	// if the value has been set and it isn't a number, then escape the quotes //
	if($v != "" && !is_numeric($v)){ 
		$v = mysql_real_escape_string($v);
	}
	
	// remove the fatal query characters //
	$v = str_replace(";", "", $v);
	
	return $v;

}


Anything else I can add/do to improve this yet again?
__________________
- Richie

Last edited by wilorichie : May 8th, 2008 at 06:14 AM.

Reply With Quote
  #2  
Old May 8th, 2008, 06:23 AM
wilorichie wilorichie is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Brisbane
Posts: 151 wilorichie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 3 m 8 sec
Reputation Power: 2
Another question:

When I check my database, it will display:
my'string

rather than:
my\'string


Whats going on there? Shouldn't the database have \' when I am using mysql_real_escape_string() ??? My function not working properly!?

Reply With Quote
  #3  
Old May 8th, 2008, 07:32 AM
cwf's Avatar
cwf cwf is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 354 cwf User rank is Private First Class (20 - 50 Reputation Level)cwf User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 3 Days 7 h 7 m 19 sec
Reputation Power: 2
For your second post, no. The escape characters are only in the query string to allow the special characters to be treated as data. The escape characters are not inserted into the database.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > SQL Security


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway