View Single Post

  #5 (permalink)  
Old 20-03-2008, 04:33 AM
ziycon's Avatar
ziycon ziycon is offline
Wannabe Geek
Recent Blog:
[CaRP] XML error: Invalid character at line 55
 
Join Date: Jan 2007
Location: Dublin
Posts: 416
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ziycon will become famous soon enough
Send a message via MSN to ziycon Send a message via Skype™ to ziycon
Default

Quote:
Originally Posted by Frodo View Post
It escapes nasty charters in you sql statements. It's essential to stop mysql injection attacks.

Your insert code should look like this:

PHP Code:
$content $_POST['content'];
$dbcontent mysql_escape_string($content);
$sql="insert into some_table(msContent) values ('".$dbcontent."')";
$result mysql_query($sql,$conn) or die("Fail"); 
No need to worry abouy sql injection attacks on the pages in questions, there secure enough already, so if i have something like so it should work?
PHP Code:
<?php
header
("Location: ../news/1.htm");
include(
'../forum/SSI.php');

dbConnect();

global 
$context;

if(
$context['user']['is_logged'])
{
    
$validate_admin check_admin_userid($context['user']['id']);
    
$validate check_sec_admin_userid($context['user']['id'],2);
    if((
$validate == true) || ($validate_admin == true))
    {
        
$content mysql_escape_string($_REQUEST['body']);        
        
mysql_query("UPDATE news SET title='".$_GET['title']."', body='".$content."'  WHERE id=".$_GET['id']."");
    }
}

closeConnect();
?>
Tired this but the stripslashes function is not working when displaying the text now!?
__________________
Irish Gaming Network
Reply With Quote