Q:

why the "? >" tag won't close the php part? 

So I was writing some PHP scripts and also some HTML codes but this was what happened:
<? php
/*
some php scripts
*/
$q = "SELECT * FROM users WHERE id='1' AND username='test' AND pass='123'; /* the last line of php */
? >

this was the last code that I used and after that I closed the php and started the html part:
<! doctype html>
<html>
<head>
<meta charset="utf-8">

so at this point when I check localhost and my database I get an error:

Parse error: syntax error, unexpected 'utf' (T_STRING) in F:\wamp64\www\Login2.php on line 47

and it's because of the HTML code I used.  although I closed the PHP with ? > it's still counting HTML codes as PHP! 

A:

Your string is not closed with " that is why you get an error
$q = "SELECT * FROM users WHERE id=1 AND username='test' AND pass='123'";

it should be like above.