Page 1 of 1

please correct this code what's wrong with it

Posted: Tue Mar 09, 2004 3:19 pm
by anmol
hello all. I am trying to connect to Mysql with php(which i have done succesfully) but when i try to use same code in html embedded page it does not displays output correctly.

here is code

Code: Select all

<html>

<head>

 <title>Sentinel An Intrusion Detection Sysem<br><br></title>

</head>

<body>

 <img src = "sentinel.jpg" alt = "Image 1">

 <?php

$host = "localhost";

$login_name = "root";

$password = "brassman";

MySQL_connect("$host","$login_name","$password");

MySQL_select_db(narayan) or die("Failed");

$query = "SELECT * FROM pet";

$result = MYSQL_query($query);

While($rows = MySQL_fetch_array($result)){

$name=$rows['name'];

$sex=$rows['sex'];

echo"<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>";

echo("Name is $name and sex is $sex");

echo("<br>");

}

MySQL_close();

?>

 

 

 

</body>

</html>
can you tell me what is wrong with this code. i get output as :

echo("Name is $name and sex is $sex");

echo("<br>");

}

MySQL_close();

"

Sincerely,

Anmol

Posted: Tue Mar 09, 2004 3:22 pm
by infolock
are you saving the file as a .php
?

unless you have changed your server configuration file, you can't just name a file with an extension of .htm or .html and expect it to process the php.


echo 'Name is '.$name.' and sex is '.$sex.'<br>';

Posted: Wed Mar 10, 2004 3:05 am
by malcolmboston
like infolock said

if that is the output you are getting you probably havent renamed your file properly because if it was your webserver it would do a save / open dialogue box