Whenever I try to retrieve information from my MySQL database and show it on my web page, the page shows the source instead.
The code source start after the ->fecth()
. I think that my WAMP is not setup correctly or the obvious one: "I did something wrong somewhere".
I am not looking for an upgrade but just for corrections.
<?
$bdd = new PDO('mysql:host=localhost;dbname=test', 'root', '');
$rep = $bdd->query('SELECT * FROM membre');
while($data = $rep->fetch())
{
echo $data['nom'];
}
?>
答案 0 :(得分:1)
Maybe you can't configured your php for accept <?
open tag, try to use <?php
答案 1 :(得分:1)
You might need a complete PHP tag:
<?php
You might need to have a "LoadModule" statement in your Apache config file.
LoadModule php5_module libexec/apache22/libphp5.so
Last, quite often this is the problem --- you need AddHandler:
AddHandler application/x-httpd-php .php
This is often system dependent. Perhaps your hosting company can help?