I've been working on a project for a video website. It pulls information from the database and inserts the details where needed.
Everything so far is working perfectly, but I've just done a SQL injection test and everything is completely open. I've been looking around for answers to close it up and make things a bit more secure.
I've tried to implement the PDO statements but I can't get my head around it. I've only been working on php/sql for this month so I'm extremely new.
any help or other solutions would be amazing, the code below is my main connection point for the page which I believe is also the most vulnerable part
<?php
$username="********";
$password="*******";
$database="*******";
$id = $_GET['id'];
$badchars = array("\"", "\\", "/", "*", "'", "=", "-", "#", ";", "<", ">", "+", "%");
$myid = str_replace($badchars, "", $id);
mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query("SELECT * FROM Videos WHERE id='$id'");
while($row = mysql_fetch_array($result)) {
$title=mysql_result($result,0,"title");
$url=mysql_result($result,0,"url");
$id=mysql_result($result,0,"id");
$description=mysql_result($result,0,"description");
$source=mysql_result($result,0,"source");
$type=mysql_result($result,0,'type');
}
?>