dougan6982 2014-05-07 18:16
浏览 35

运行php文件什么都不返回

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

  • 写回答

2条回答 默认 最新

  • dongtan6206 2014-05-07 19:17
    关注

    where is your mysql_query()?

    I think you should add the mysql_query() and try again.

    $sql = "SELECT *  FROM User where userId = '$userId' AND password = '$password'";
    
    $query=mysql_query($sql) or die(mysql_error());    **// You didn't add this line**
    
    $res = mysql_fetch_array($query) or die(mysql_error());
    

    your all other code goes here.................. hop your problem is fixed

    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法