0

I am having a problem with my php code as it shows half code from loop in the browser after the comparison statement.

    <?
include_once("connection.php");
connect_mysql();
$qry="select * from page_content where pg_id='1'";
$res=mysql_query($qry);
if(mysql_num_rows($res)>0)
{
  $r=mysql_fetch_array($res);
  $txt = $r["pg_text"];
}
?>

it shows like this on browser. Error on Browser

1 Answers1

2

Please add in first line <?php not <? (because maybe you have not configure short tags using, from php.ini) and you can remove ?> at ends line, it's a good practice.

Vahe Galstyan
  • 1,681
  • 1
  • 12
  • 25
  • 1
    "PHP also allows for short open tag (which is discouraged since it is only available if enabled using the short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option). " http://php.net/manual/en/language.basic-syntax.phptags.php –  May 31 '17 at 07:17
  • Yes I know about that.) – Vahe Galstyan May 31 '17 at 07:18