2021年4月24日星期六

There two values getting stored in my database 0 and the actual total count

So i did this in my python script and the values of cars and cars1 changes every second and the total_space value is constant which is 50 and i have stored the output in a test.txt file.

 #Calculation              new_total1 = total_space - cars              #new_total2 = total_space + cars1              final_total = new_total1              Total=cars+cars1                            #output in text file              count=open('test.txt','w')              print(final_total,file = count)              count.close()   

My php script is something like this

<?php  $conn = new mysqli('localhost','root','','count');  header("Refresh: 60");  $file = fopen("test.txt","r");    while (!feof($file)) {      $content = fgets($file);      $sql = "INSERT INTO `test` (`number_of_cars`) VALUES ('$content')";      $conn->query($sql);      echo $content;  }  fclose($file);  

when I run the php script in my browser through xampp no output is displayed.But when I check my table in database the current output is stored with 0.

Suppose my final_total is 45 at id 1 and 0 at id 2.

Also when i delete the test.txt file and recreate it and if I manually enter random number and save it then output is displayed on the browser.

https://stackoverflow.com/questions/67249379/there-two-values-getting-stored-in-my-database-0-and-the-actual-total-count April 25, 2021 at 11:04AM

没有评论:

发表评论