我不知道它是否是一个愚蠢的错误,但是post/get变量没有被设置,而应该是。下面是HTML和PHP代码片段:在NetBeans IDE中未设置GET/POST变量
<html>
<head>
<title>
Chain Story
</title>
</head>
<body>
<form method="GET" action="check-valid.php">
<textarea name="a" rows="5" cols="50"></textarea>
<input type="submit" value="Add" />
</form>
</body>
</html>
检查valid.php:
<?php
require 'includes/connect.inc.php';
$conn_ref = connect_db('chainstory') or die(mysqli_error());
if(isset($_GET)){
echo 'Get variable set';
if(isset ($_GET['a'])){
$as = $_GET['a'];
$query = "insert into story1 values (1, " . $as . ")";
mysql_query($query, $conn_ref);
}
else{
echo $_GET;
}}
?>
我得到以下输出:
Get variable set
Notice: Array to string conversion in /home/kevin/Code/php/myWebsite/check-valid.php on line 15
Array
我在NetBeans编码此。任何人都可以指出我犯了什么错误吗? :(
首先,请将'echo $ _GET;'替换为'var_dump($ _ GET)'并查看输出结果 – Kovge 2013-03-26 14:56:06
这是现在的输出!'Get variable setarray(0){}' – Kevin 2013-03-26 15:21:37
@Kovge将它移动到一个新文件夹并使用gedit进行编辑后生效。我不知道亵渎netbeans错了。 – Kevin 2013-03-26 16:25:00