当我尝试从localhost(localhost / PrimaAppAndroid / register.php)打开文件register.php
时,页面仍为白色,如果我尝试查看源文件,则为空。如果我从register.php
离开php部分,即使我没有在html中更改扩展名php也能正常工作。
我看到了similar question,我在AddType application/x-httpd-php .php
文件的末尾添加了apache2.conf
,但没有任何变化。怎么解决这个问题?
这里的消息来源: register.php
<?php
/*
Our "config.inc.php" file connects to database every time we include or require
it within a php script. Since we want this script to add a new user to our db,
we will be talking with our database, and therefore,
let's require the connection to happen:
*/
require("config.inc.php");
?>
<h1>Register</h1>
<form action="register.php" method="post">
Username:<br />
<input type="text" name="username" value="" />
<br /><br />
Password:<br />
<input type="password" name="password" value="" />
<br /><br />
<input type="submit" value="Register New User" />
</form>
的config.inc.php:
<?php
// These variables define the connection information for your MySQL database
$username = "root"
$password = "root"
$host = "localhost"
$dbname = "cinemapreverificasql"
// Tis is the way we saw in class
$conn = mysql_connect($host, $username, $password) or die("Errore nella connessione MySQL");
mysql_select_db($dbname, $conn) or ide("Database inesistente");
?>
答案 0 :(得分:2)
config.inc.php
变量中没有分号?
答案 1 :(得分:2)
错误的另一个可能来源:
mysql_select_db($dbname, $conn) or ide("Database inesistente");
应该是
mysql_select_db($dbname, $conn) or die("Database inesistente");
答案 2 :(得分:2)
Ciao Giacomotb,
如果您正确发布代码,则config.inc.php
文件中会出现拼写错误。
mysql_select_db($dbname, $conn) or ide("Database inesistente");
正如您在最后看到的那样,您使用了die
函数,但是您编写了ide
,只需修复它就可以了
另外你忘记了php变量末尾的分号。
$username = "root"
$password = "root"
$host = "localhost"
$dbname = "cinemapreverificasql"
必须是
$username = "root";
$password = "root";
$host = "localhost";
$dbname = "cinemapreverificasql";
答案 3 :(得分:1)
我注意到你的代码有错误,因为(;)在你宣布的varaiables结束时遗漏了。
<?php
// These variables define the connection information for your MySQL database
$username = "root";
$password = "root";
$host = "localhost";
$dbname = "cinemapreverificasql";
// Tis is the way we saw in class
$conn = mysql_connect($host, $username, $password) or die("Errore nella connessione MySQL");
mysql_select_db($dbname, $conn) or ide("Database inesistente");
?>
另一件事是尝试将您的文件重命名为config.inc.php并将名称重新命名为config_inc.php