PHP code not recognized on the page

Asked

Viewed 76 times

0

I made a menu with Ajax and it changes the content dynamically, so far so good, but the problem is that when I insert a PHP code in the page it does not recognize the code and displays the writings, it appears instead of executing the code. Does anyone know what’s going on??

Note: before Ajax worked normally.

prepare("SELECT * FROM empresa"); 
$executa = $empresa->execute(); 
if($executa){
  while($reg = $empresa->fetch(PDO::FETCH_OBJ)){ 
  /* Para recuperar um ARRAY utilize PDO::FETCH_ASSOC */ 
?> 
txt_empresa
?> 
getMessage(); 
} 
?>
  • 2

    is too vague. We have no crystal ball

  • 1

    Only with this section is not possible to know the problem. Post the whole code (the relevant part).

  • When you access the php file directly happened the same thing? you call it at the address file:///c:\amp\htdocs\arquivo.php?

1 answer

3

Always use <?php at the beginning of a code PHP and end with ?>.

For example, in the code you posted above the function that is called getMessage() is not between PHP tags. You have to always check. Avoid using only <? to start PHP code. Some apaches are not configured to use short_tags.

Also, check the file extension if it really is .php . Last point to check is whether the apache you are running is an apache or is the IIS (windows). Always try to use apaches like Xampp, Wamp, Vertrigo, etc.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.