<div class="grid--cell fl1 lh-lg">
<div class="grid--cell fl1 lh-lg">
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, <a href="/help/reopen-questions">visit the help center</a>.
</div>
</div>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2012-08-01 15:43:07Z" class="relativetime">7 years ago</span>.</div>
</div>
</aside>
hello guys i have this problem i can't compare this two strings
<?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);
?>
Someone can explain me how can resolve the problem? The goal of this script is avoid the user to write two times the same things
</div>
if($stringData == $arr[j]){ // is the problem
^^^
is missing a $
Activate error reporting and this should have been pointed out to you automatically:
error_reporting(E_ALL);
ini_set('display_errors', true);