Jump to content

sql query


ldoozer

Recommended Posts

$query = "SELECT * FROM sports s, categories c, sport_catog sc WHERE s.SportId = sc.SportId AND c.CategId = sc.CategId AND c.CategId = ".$_GET['catog'] . " ORDER By s.SportTitle ASC";

 

Also be wary of SQL Injection with including the $_GET directly into the sql like that.

Link to comment
https://forums.phpfreaks.com/topic/59151-sql-query/#findComment-293746
Share on other sites

$query = "SELECT * FROM sports s, categories c, sport_catog sc WHERE s.SportId = sc.SportId AND c.CategId = sc.CategId AND c.CategId = ".$_GET['catog'] . " ORDER By s.SportTitle ASC";

 

If Someone entered 1 OR 2 = 2 into the catog parameter, what would that make your SQL statement?

This:

WHERE s.SportId = sc.SportId AND c.CategId = sc.CategId AND c.CategId = 1 OR 2 = 2 ORDER By s.SportTitle ASC";

 

Which would nicely return every row in your database, because 2 will always equal 2....?

 

 

Just check that your $_GET['catog'] is what you want it to be before you start pumping it into SQL statements

Link to comment
https://forums.phpfreaks.com/topic/59151-sql-query/#findComment-293782
Share on other sites

sql injection is a bad thing.

 

basically you don't want to pass direct variables through your URL.

 

imagine soemone passing username and password in the URl.

 

someone just has to enter 'or1='1  as the password string in the URl and they are in.

 

this can cause problems with many aspects, but the most obvious one for people to see is a username password example.

 

 

here is a better description.

http://www.unixwiz.net/techtips/sql-injection.html

Link to comment
https://forums.phpfreaks.com/topic/59151-sql-query/#findComment-293784
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.