output php database to html webpage, HELP

i’m trying to get a php database to output/display on a html webpage
and have no results from cutting and pasting code from online tutorials
i’m saving to a file with a htm extension
i believe i have the connection data right:

$db_host = ‘server’;
$db_user = ‘username’;
$db_pwd = ‘password’;

$database = ‘database’;
$table = ‘table’;

if (!mysql_connect($server,$username,$password))
die(“Can’t connect to database”);

if (!mysql_select_db($database))
die(“Can’t select database”);

$result = mysql_query(“SELECT * FROM table”)
or die(mysql_error());

Can someone please help me? send code? tell me what i’m doing wrong? Thanks

i guess, u have written the php script (that fetches data from mysql) in a html page (with .htm extension).

if u did so, .html pages cannot be parsed by the php script engine (even though the page contains php script).

the web server does not use the php compiler to parse .htm pages. instead it just sends the page to browser.

and the browser treats everything (including php script) as plain text and displays as it is.

Sponsor our Newsletter | Privacy Policy | Terms of Service