-4

I am new to PHP, I got this syntax error but I can't figure it out

$pageid = $_GET['pageid'];
$sql = "SELECT article_id FROM page_content WHERE id='" .$pageid ."'";
$row = $conn->query($sql);
if ($row != false){
    $result = $row->fetch();
    $sql = "SELECT html_code from article WHERE id=" .$result['article_id'];
    $row = $conn->query(&sql);
    if ($row != false){
        $result = $row->fetch();
        echo $result['html_code'];
    }
}

Result: Parse error: syntax error, unexpected ')', expecting '(' in the line 7. Please help me, thank you.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345

1 Answers1

2

You are using a & not a $ for the variable so change this:

$row = $conn->query(&sql);

to this:

$row = $conn->query($sql);
jmattheis
  • 10,494
  • 11
  • 46
  • 58