I know this is duplicate with this question. but I received the same error. I searched a lot for similar questions like : PHP not working on HTML file, PHP script not working in HTML file, Cannot run a simple PHP file on the server and many more but could not find any solution.
I created a very simple login html file, then I wrote the php scripts to do the login action in a separate php file. (in the same folder with html file). My problem is that when I type localhost/filename.php in browser, it returned me nothing. (I mean an empty html page without any error messege). Also, when I press the login button in my html login form, it asked me to save file while I expected to run the php file.
I checked the error log, this is the error:
script '/var/www/connectivity.php' not found or unable to stat [Wed May 07 17:51:28 2014] [notice] caught SIGTERM, shutting down [Wed May 07 17:51:29 2014] [notice] Apache/2.2.22 (Ubuntu) PHP/5.3.10-1ubuntu3.11 with Suhosin-Patch configured -- resuming normal operations [Wed May 07 19:25:34 2014] [error] [client 127.0.0.1] PHP Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: NO) in /var/www/connectivity.php on line 7
this is the php script:
<?php
$host="localhost";
$user="root";
$pass="xxxxx";
$db="test";
$con=mysql_connect($host,$user,$pass) or die("Failed to connect to MySQL: " . mysql_error());
$db=mysql_select_db($db,$con) or die("Failed to connect to MySQL: " . mysql_error());
if(isset($_POST['userId'])){
$userId = $_POST['userId'];
$password = $_POST['password'];
$sql = "SELECT * FROM User where userId = '$userId' AND password = '$password'" or die(mysql_error());
$res = mysql_fetch_array($sql) or die(mysql_error());
if(mysql_num_rows($res) > 0) {
echo "SUCCESSFULLY LOGIN TO USER PROFILE PAGE...";
exit();
}
else
{
echo "SORRY... YOU ENTERD WRONG ID AND PASSWORD... PLEASE RETRY...";
exit();
}
}
?>
could someone kindly help me to solve it?
Thanks
mysql_fetch_array($db,$sql)
also use the newer mysqli instead of mysql – Dev Man