PHP脚本不起作用

时间:2013-01-29 20:58:13

标签: php mysql

您好我有一个问题:我无法弄清楚为什么这个PHP脚本不起作用:

<?php

 echo "VERSION 1.0";

 ini_set('display_errors',1); 
 error_reporting(E_ALL);


$username ="user";
$password = "pw";
$database = "db";
$mysqldb = "dbName";

echo "INIT OF VARIABLES END";

$conn = mysql_connection("host",$username,$password) or die 
("Failed to connect"); 

echo "CONN FINISCHED";

mysql_select_db("dbSave",$conn);

echo "SELECT DONE";

$login = $_POST["login"];
$pw = $_POST["pw"];

echo "GOT DATA:$login, $pw";

$query = "INSERT INTO dbSave (login, pw) VALUES ("$login","$pw");
mysql_query($query);

echo "EINTRAG GEMACHT";

?>

我只是得到一个空白页面,甚至没有错误消息 (更改了变量名称)

1 个答案:

答案 0 :(得分:1)

  1. 确保您已启用错误

  2. 您可以在降价解析器中查看您的问题:

    $query = "INSERT INTO dbSave (login, pw) VALUES ("$login","$pw");
    mysql_query($query);
    
    echo "EINTRAG GEMACHT";
    

    你需要逃避双引号!

    $query = "INSERT INTO dbSave (login, pw) VALUES (\"$login\",\"$pw\");
    mysql_query($query);
    
    echo "EINTRAG GEMACHT";