Forum Moderators: coopster
$query = "UPDATE GC SET GCNumber='".$GC."', KEYCODE='".$KEY2."' WHERE KEYCODE='".$_GET['KEY']."'";
mysql_query($query);
BTW - MySQL does not care if you have the ticks arund numbers either.
JAG
$query = "UPDATE GC SET GCNumber='".$GC."', KEYCODE='".$KEY2."' WHERE KEYCODE='".[url=http://us2.php.net/manual/en/function.mysql-real-escape-string.php]mysql_real_escape_string[/url]($_GET['KEY'])."'";
:)
You say that the variable content isn't created by a user, however anyone can type something into the url to get the desired SQL Injection through the GET variable.
Please read about SQL Injections [us2.php.net]. It is definitely worth your time. If you do not use mysql_real_escape_string, then you are leaving your information out in the open!
Anyway, good luck with what you are doing ;)
mysql_real_escape_string [us2.php.net] and mysql_escape_string [us2.php.net] both have slightly different uses than addslashes [us2.php.net].
mysql_real_escape_string and mysql_escape_string both protect from SQL Injection. Read up on the links for more information. If you can, you want to use these functions. If you are using another database other than mysql, there may be other options to escape your query variables.
Addslashes adds slashes to these characters: ' " / NULL
Hope this explains the difference Atomic_Guy ;)
$description = mysql_real_escape_string($_POST['description']);