i used mysql as database,apache as server and php language.When i'm write this code for get data from mysql database table it shows HTTP 500 internal server error and page is not displayed.Actually i'm very very newer for the php.So pls help me. Thank you. ediri <html> <head> <title>show datas</title> </head> <body> <h1>show data</h1> </body> <?php // we must never forget to start the session //session_start(); //$errorMessage = ''; // makes sure they filled it in $dbhost = 'localhost'; $dbuser = 'root'; $dbname = 'detail'; if (!($db = mysql_connect($dbhost, $dbuser))){ die("Can't connect to mysql."); }else{ if (!(mysql_select_db("$dbname",$db))) { die("Can't connect to db."); } } /*$username = addslashes($username); $password = addslashes($password); $name = addslashes($name); $address = addslashes($address);*/ // check if the user id and password combination exist in database $sql = "SELECT username,name,address FROM detail"; $result = mysql_query($sql) or die('Query failed. ' . mysql_error()); //$num_results = mysql_num_rows($result); while($row = mysql_fetch_assoc($result)) { echo "username :{$row['username']} <br>" . "name : {$row['name']} <br>" . "address : {$row['address']} <br><br } /*if (mysql_num_rows($result) == 1) { // the user id and password match, // set the session $_SESSION['db_is_logged_in'] = true; // after login we move to the main page header('Location: NormalUser.php'); exit; } else { $errorMessage = 'Sorry, wrong user id / password';*/ mysql_close($conn); ?> </html> Code (markup):
If you are getting HTTP 500 internal server error than its Apache Problem. There is something wrong with your Apache server installation/Configuration.
you probably did not install php properly, if you're quite new try installing pre packaged installers like xampp etc
This can also be caused by a corrupt or unrecognized .htaccess file. See if there's one and try to remove it temporary.