-3

你好我有一个问题:我不知道为什么这个 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";

?>

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

4

1 回答 1

1
  1. 确保您打开了错误

  2. 您可以在 markdown 解析器中看到您的问题:

    $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";
    
于 2013-01-29T21:00:09.690 回答