[英]php script not running in WAMP server
I have installed WAMP server and using port# 81 since port 80 is being used by IIS server. 由于IIS服务器正在使用端口80,因此我已安装WAMP服务器并使用端口号81。 All works fine!
一切正常!
http://localhost:81/phpmyadmin/
and even http://localhost:81/?phpinfo=1
. http://localhost:81/phpmyadmin/
甚至http://localhost:81/?phpinfo=1
。
I have placed my website under C:\\wamp\\www\\
folder. 我已将网站放置在
C:\\wamp\\www\\
文件夹下。 On submit button I'm calling checklogin.php which chwcks for user details from DB, but all i see is the following script in browser instead of running the php code :( Need help to resolve this problem! Any Issues with having WAMP on Windows 8? 在提交按钮上,我正在调用checklogin.php,该命令会从数据库中获取用户详细信息,但是我所看到的只是浏览器中的以下脚本,而不是运行php代码:(需要帮助来解决此问题!Windows上有WAMP的任何问题8?
<?php
$host="http://localhost:81/";
$username="root";
$password="";
$db_name="guru_dakshina";
$tbl_name="members";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>
Your PHP isn't running. 您的PHP未运行。 Assuming you are using Windows: Open your services (type services in your start menu) and browse to PHP.
假设您使用Windows:打开服务(在“开始”菜单中键入服务)并浏览到PHP。 Start it.
启动它。
replace the host value to localhost. 将主机值替换为localhost。
try : 尝试:
$host = "localhost";
As we know MYSQL_* is depreciated now so better use MYSQLI_* or PDO 我们知道MYSQL_ *现在已贬值,因此最好使用MYSQLI_ *或PDO
Here is you code using MYSQLI_* , Hope it help you and i have made necessary correction needed to make it run correctly. 这是您使用MYSQLI_ *的代码,希望它能对您和我有所帮助,以使其正确运行。 :)
:)
<?php
session_start();
ob_start();
$host="localhost";
$username="root";
$password="";
$db_name="guru_dakshina";
$tbl_name="members";
$conn = mysqli_connect($host, $username, $password, $db_name)or die("cannot connect");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysqli_real_escape_string($conn,$myusername);
$mypassword = mysqli_real_escape_string($conn,$mypassword);
$sql="SELECT * FROM `$tbl_name` WHERE `username`='$myusername' and `password`='$mypassword'";
$result=mysqli_query($conn,$sql);
$count=mysqli_num_rows($conn,$result);
if($count==1){
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>
PHP is not parsed, assuming you are using Apache add the following two lines to your Apache conf and restart Apache. 假设您使用的是Apache,则不会解析PHP,将以下两行添加到Apache conf中并重新启动Apache。
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.