Query works when hardcoded, but not when a number is concatenated

Hello, I am trying to make a CMS where queries are actually held in an html file (for specific reasons)

Anyway, when this html file is called the id that the query needs is stored in a tag like this: <!id>

Well the CMS converts that tag to a number, like 1.

I can concatenate the number to a query and plug it into the mysql_query
function, but in this case it gives me a
“Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/unidenti/www/test/UiCMS/php/sql.inc.php on line 47”

If i dont concatenate it and hardcode the number 1 into the query, the query works!

I have no idea why it behaves this way! Please help!

Link:

You will see the error on This Page when you click View Comments

Code below:

In the HTML file the php is defined like this:


...
<---- HTML ---->
...
<?php 

$id = "<!id>"; // <----the <id> tag is replaced by 1
//---Initialize MySql Connection Class---
$config = new config();
$sql2 = new sql($config->dbhost,$config->dbuser,$config->dbpass, $config->dbname);
$sql2->_select_db($config->dbname);
//---------------------------------------------

$comment_query ='SELECT DISTINCT cms_comments.PK_comments, cms_users.user_name,cms_comments.comment_title,cms_comments.comment,cms_comments.comment_date FROM cms_comments, cms_users WHERE cms_comments.FK_event = ' . $id ;
		
echo $comment_query;	
$result_query =$sql2->_query($comment_query);

while($result = $sql2->_fetch_object($result_query)){
...						
}

?>

Thanks!