Jump to content

ckuo

Members
  • Posts

    7
  • Joined

  • Last visited

ckuo's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi, I changed to an absolute path and it works perfectly now. Thanks a lot!
  2. Hi, I've tried the new syntax. I think the cron launches but the script doesn't work for some reason. I noticed that if I run the script on the browser http://ckuo.heliohost.org/div_radar/tools/updateStocks.php It works perfectly, but if the cron runs it, it shows these error logs below. In both cases the script is exactly the same "updateStocks.php" [14-Feb-2020 00:00:23 UTC] PHP Warning: fopen(../../cgi-bin/div_radar_cgi/curl_log_updateStocks.txt): failed to open stream: No such file or directory in /home/ckuo/public_html/div_radar/tools/updateStocks.php on line 15 Why isn't fopen able to read the files? Thanks!
  3. Hi tech support, could you help me check if I setup the cron job correctly? I don't receive any emails from the output of the scrip so I am wondering if it runs at all. I set a gmail email in the cron job panel and the cron job frequency set to once per day. The command filled with the following: /usr/local/bin/php /home/ckuo/public_html/div_radar/tools/updateStocks.php Thanks!
  4. I am running on PHP 7.3.6 and I was thinking maybe the DB connection was the problem. I tried testing the Database class in a test.php file and it works fine. I attach the Database.php code below: <?php //This class only deals with connecting and running the queries in DB. class Database { //Variables private $db_host; private $username; private $password; private $db_name; private $mysqli; private $data; //Functions public function __construct(){ $this->db_host = 'localhost'; $this->username = 'ckuo_username'; $this->password = '123456'; $this->db_name = 'ckuo_database'; } //Connect DB public function connect (){ $this->mysqli = new mysqli($this->db_host, $this->username, $this->password, $this->db_name); if ($this->mysqli->connect_errno){ echo "Connection error: ". $mysqli->connect_errno; exit; } // echo 'Connection succesful!'; } //Run the query in DB public function query($sql){ $data = $this->mysqli->query($sql); if(!$data) { return $this->mysqli->errno; } else { return $data; } } } ?> Hi, so I changed the PHP version to 7.3 on cpanel and it works as a charm. Thanks!
  5. I am running on PHP 7.3.6 and I was thinking maybe the DB connection was the problem. I tried testing the Database class in a test.php file and it works fine. I attach the Database.php code below: <?php //This class only deals with connecting and running the queries in DB. class Database { //Variables private $db_host; private $username; private $password; private $db_name; private $mysqli; private $data; //Functions public function __construct(){ $this->db_host = 'localhost'; $this->username = 'ckuo_username'; $this->password = '123456'; $this->db_name = 'ckuo_database'; } //Connect DB public function connect (){ $this->mysqli = new mysqli($this->db_host, $this->username, $this->password, $this->db_name); if ($this->mysqli->connect_errno){ echo "Connection error: ". $mysqli->connect_errno; exit; } // echo 'Connection succesful!'; } //Run the query in DB public function query($sql){ $data = $this->mysqli->query($sql); if(!$data) { return $this->mysqli->errno; } else { return $data; } } } ?>
  6. Hi, I am trying to create dynamic tables that have the same structure and the content changes according to the info in a database. I have a loop that repeat the HTML table code and the PHP DB reading function. I am using the foreach loop syntax to break from the HTML code and tested on my local drive it works but on the server it does not show any table. Can you help me check of the syntax is correct on Heliohost? I also tested the same code in another server and it worked fine. Not sure where the problem is. Below the code: ------------------------------------------------------------------------------------------------------ <?phpinclude_once 'database/Database.php'; //this handles the Database session_start();$_SESSION['DEBUGGING'] = 'OFF'; // Init the DB.$db = new Database;$db->connect(); $sql = "SELECT stock_code FROM (SELECT MAX(stock_id) as stock_id, stock_div.stock_code, MAX(exdiv_date) as exdiv_date FROM stock_div GROUP BY stock_code ORDER BY `exdiv_date` DESC) abc "; $stockcode_array = $db->query($sql)->fetch_all(); foreach ($stockcode_array as $key => $stockcode) : ?> <?php $stock_code = $stockcode[0]; $sql = "SELECT * FROM stock_div WHERE stock_code=$stock_code ORDER BY exdiv_date DESC ,stock_id DESC "; $stock_info = $db->query($sql)->fetch_assoc(); .....some code here.... ?> //End of the PHP dynamic data //HTML table start.... <div class="block"> <div id="<?php echo $stock_code;?>" class="table" onclick="location.href='stock_details.php?stock_code=<?php echo $stock_code;?>';" style="cursor: pointer;"> <div class="row"> <label for="stockCode">Stock Code</label> <input disabled="true" name="stockCode" value="<?php echo $stock_code;?>"></input> </div> <div class="row"> <label for="stockName">Stock Name</label> <input disabled="true" name="stockName" value="<?php echo $stock_info['stock_name'];?>"></input> </div> <div class="row"> <label for="exDiv">Ex-Div Date</label> <input disabled="true" name="exDiv" value="<?php echo $stock_info['exdiv_date'];?>"></input> </div> <div class="row"> <label for="yield">Yield</label> <input disabled="true" name="yield" class="yield" value="<?php echo sprintf("%.1f%%", $stock_info['stock_yield']);?>"></input> </div> <div class="row"> <label for="prob3">P(<3d)</label> <input disabled="true" name="prob3" value="<?php echo sprintf("%.0f%%", ($p3/$dataSize)*100);?>"></input> </div> <div class="row"> <label for="prob5">P(<5d)</label> <input disabled="true" name="prob5" value="<?php echo sprintf("%.0f%%", ($p5/$dataSize)*100);?>"></input> </div> <div class="row"> <label for="prob10">P(<10d)</label> <input disabled="true" name="prob10" value="<?php echo sprintf("%.0f%%", ($p10/$dataSize)*100);?>"></input> </div> <div class="row"> <label for="prob20">P(<20d)</label> <input disabled="true" name="prob20" value="<?php echo sprintf("%.0f%%", ($p20/$dataSize)*100);?>"></input> </div> <div class="row"> <label for="prob30">P(<30d)</label> <input id="prob30" disabled="true" name="prob30" value="<?php echo sprintf("%.0f%%", ($p30/$dataSize)*100);?>"></input> </div> <div class="row"> <label for="size">Data Size</label> <input disabled="true" name="size" value="<?php echo $dataSize;?>"></input> </div> </div></div> //HTML table end.... <?php endforeach; ?> ------------------------------------------------------------------------------------------------------
  7. Hi there, following the post https://www.helionet.org/index/topic/29540-solved-total-beginner-need-help-running-a-python-script/ I realized I have no modules python3.7 for my script. What's the process to add the required modules ? I'll be needing the following: from urllib.request import urlopen as uReqfrom bs4 import BeautifulSoup as soupimport csvimport osimport mysql.connectorimport sysimport re Thanks!
×
×
  • Create New...