$_GET error

There is a file , index.php

If index.php?sex=boyis opened in a browser, the list with the value boy should be loaded
but it gives an error, blank page 🙁
who sees the error?

$db->query("select * from peoples where sex='.$_GET['sex'].'");
while($line=$db->get_row()){
    echo '<ul><li><a href="'.$line['url'].'"> '.$line['name'].'</a></li></ul>';

Answer 1, authority 100%

$sex = mysql_real_escape_string($_GET['sex']); #  
$db->query("select * from peoples where sex='$sex'");

Answer 2

<?
    $sql=mysql_query("select * from peoples where sex='".$_GET['sex']."'");
    while($line=mysql_fetch_array($sql))
    {
        echo '<ul><li><a href="'.$line['url'].'"> '.$line['name'].'</a></li></ul>'; 
    }
?>

Answer 3

Better like this:

$sex = mysql_real_escape_string($_GET['sex']);
$db->query("select * from peoples where sex='".$sex."'");

If it doesn’t work, then like this:

$db->query("select * from peoples where sex=\'".$sex."\'");

Answer 4

Have you tried it like this?

$sex = mysql_real_escape_string($_GET['sex']);  
$db->query("select * from peoples where sex='{$sex}'");

Answer 5

And best of all, because sex can only be boy or girl,

if(isset($_GET['sex'])) $sex=$_GET['sex'];
if($sex=='boy'||$sex=='girl')
...("select * from `peoples` where `sex`='$sex'")

PS don’t forget about mysql syntax.