Page 1 of 1

Beginner, My first PHP syntax in index.html is not working

Posted: Fri Aug 15, 2008 11:49 pm
by deep.singh
Hi

I have put following PHP code just below <body> and it is not connecting to database. You can also look at source code from page - http://tumblebus.x10hosting.com/
Could somebody please let me where i am wrong.

<body>
<?php
$dbhost = 'localhost';
$dbuser = 'deepji_admin';
$dbpass = 'homework';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname = 'deepji_db';
mysql_select_db($dbname);
?>

Thanks
Deep

Re: Beginner, My first PHP syntax in index.html is not working

Posted: Sat Aug 16, 2008 12:15 am
by Christopher
The file should be named index.php, not index.html.

Re: Beginner, My first PHP syntax in index.html is not working

Posted: Sat Aug 16, 2008 12:35 am
by desmi
Your page extension is not php, its htm or html, you need to change it to .php so the server knows you want to execute that php code in it, and not just show.

edit: soo late again :D

Re: Beginner, My first PHP syntax in index.html is not working

Posted: Sat Aug 16, 2008 7:55 am
by deep.singh
Thanks Guys, It worked.