招呼球员的价值,我有这个问题我不能比较这两个字符串
<?php
$dir = '/var/www/devData/test';
// create new directory with 777 permissions if it does not exist yet
// owner will be the user/group the PHP script is run under
if (!file_exists($dir)) {
mkdir ($dir, 0777);
}
$flag = 0;
$stringData = $_POST['data']; // echo = null
$file = "/var/www/devData/test/ciao.txt";
$fh = fopen($file, 'a+') or die("can't open file");
while(!feof($fh)) {
$theData = fgets($fh, filesize($file));
array_push($arr,$theData);
$i++;
}
for($j=0; $j<count($arr); $j++)
if($stringData == $arr[j]){ // is the problem
$flag = 1;
}
if($flag = 0){
fwrite($fh, $stringData); // fwrite works perfectly even if i try to print $string the result is null
}
fclose($fh);
?>
有人可以给我解释一下如何解决这个问题呢?这个脚本的目的是避免用户编写两次同样的事情
所以我们应该去猜测为什么'$ _POST ['data']'未定义?我的猜测:*你的表格有什么问题。 – phant0m 2012-08-01 10:17:13
不是因为我可以将$ _POST的内容写入正常的文件 – Edivad 2012-08-01 10:20:14
我看到这是用'ajax'标记的,您是否将数据作为文章传递?你正在做什么样的Ajax请求?你是否在使用像jQuery这样的库..这么多的问题! – Dale 2012-08-01 10:20:31