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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
deep.singh
Forum Newbie
Posts: 2
Joined: Fri Aug 15, 2008 11:41 pm

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

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

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

Post by Christopher »

The file should be named index.php, not index.html.
(#10850)
desmi
Forum Commoner
Posts: 64
Joined: Sun Jun 15, 2008 4:55 am

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

Post 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
deep.singh
Forum Newbie
Posts: 2
Joined: Fri Aug 15, 2008 11:41 pm

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

Post by deep.singh »

Thanks Guys, It worked.
Post Reply