I have this code running locally smoothly. The program only looks for a file and write data on it. When I try to run the same program on a server, it just does nothing...
This is the complete code:
<?php
$myFile = "Current_User.txt";
//$produto = "sapato1";
//$produto = $produto.";";
$i = 0;
$produto = $_POST["produtoID"];
$produto = $produto.";";
//$produto = $_POST["produtoID"];
$fh = fopen($myFile, 'r');
$line_of_text = fgets($fh);
$str = $line_of_text;
$str = str_replace("
", "", $str);
$str = $str."_Cesto.txt";
fclose($fh);
$fh2 = fopen($str, "r")or die("can't open file");
while (($line_of_text = fgets($fh2))) {
$i++;
$line_of_text = str_replace("
", "", $line_of_text);
$line_of_text = str_replace("", "", $line_of_text);
if($produto == $line_of_text){
break;
}
}
fclose($fh2);
$dados = file($str);
if($i == 1){
unset($dados[$i - 1]);
}
else{
unset($dados[$i - 2]);
}
file_put_contents($str,$dados);
?>
you forgot to upload Current_User.txt
Did you check the write permission of your Current_User.txt file? What File System are you using on your Server?
If you have access: Check your PHP error_log on the Server to get more valueable answers, or change the error_reportings.
Following code is facing the same problem so permissions could be the reason or elsewise change the method to GET it will be working.
<?php
$url = "http://sea-summit.com/T_webservice/get_appointments_by_id.php";
$data = array('user_id'=> 1);
$options = array(
'http' => array(
'method' => 'POST',
'content' => json_encode( $data ),
'header'=> "Content-Type: application/json
" . "Accept: application/json
" ));
$context = stream_context_create( $options );
$result = file_get_contents( $url, false, $context );
$response = json_decode( $result );
var_dump($response);
?>