please correct this code what's wrong with it

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
anmol
Forum Newbie
Posts: 7
Joined: Sat Mar 06, 2004 7:25 pm

please correct this code what's wrong with it

Post 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
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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>';
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post 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
Post Reply