Jump to content

jadeg

Members
  • Posts

    34
  • Joined

  • Last visited

jadeg's Achievements

Member

Member (2/5)

0

Reputation

  1. Thank you you very much for all the help. Will implement the suggested chnages
  2. Here is a sample file. I'll look through the code, I have done this severally. https://www.dropbox.com/s/n7pyv96qv1yv8yc/Example%20SG%20Data.xlsx?m=
  3. I am trying to get a csv file from a server, parse it and display the table. However It is exhibiting some strange behaviours. It displays the content of column 1 where it should be column 8 and vice versa. How whenI use print_r() is prints the right value. Any Idea why this is so. Below is my code. ​<?php session_start(); $ftp_server="server"; $ftp_user_name="user"; $ftp_user_pass="password"; $conn_id = ftp_connect($ftp_server) or die ("Couldn't connect to $ftp_server"); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if($login_result) { echo '<h1>Last 10 second reading for Bridgeford T1</h1>'; ftp_pasv($conn_id, true); if(($handle = fopen('ftp://user:%pass@server/1hdata.csv', "r")) !== false) { //pointer to begining of file $table4 = $table5 = $table6 ='<table border="1">'; //table tag $row=0; $x=3591; //rows with data $y=3600; while (($data = fgetcsv($handle, 0, ",")) !== false) { //store data in an array $table4Add = $table5Add = $table6Add= false; if($row >=$x && $row <=$y) { //select range of rows to display values $table4Add=$table5Add=$table6Add=true; } if($row == 0) { //table headings $table4 .= '<thead><tr>'; $table5 .= '<thead><tr>'; $table6 .= '<thead><tr>'; $table4 .= '<th>TimeStamp</th>'; $table4 .= '<th>Voltage A</th>'; $table4 .= '<th>Current A</th>'; $table4 .= '<th>Phase A</th>'; $table4 .= '</tr></thead><tbody>'; } else { if($table4Add) $table4 .= '<tr>'; for($c = 0; $c <= 10; $c++) { //obtain values form each field $value = $data[$c]; if($c==0) { //displaytime if($table4Add) $table4 .= '<td><p>'.$value.'</p></td>'; } if ($c== { // display phase a voltage and implement colour code if($value <=216.2 || $value >=253.0) { if ($table4Add) $table4 .='<td><p style="color:red";>'.round($value,2).'</p></td>'; } else { if ($table4Add) $table4 .='<td><p>'.round($value,2).'</p></td>'; } } if ($c==5) { //display phase a current and implement colour code if(($value*1250) >= 1500.0) { if ($table4Add) $table4 .='<td><p style="color:red";>'.round(($value*1250),2).'</p></td>'; } else { if ($table4Add) $table4 .='<td><p>'.round(($value*1250),2).'</p></td>'; } } if ($c==1) { // display phase a pf and implement colour code if($value <=0.0) { if ($table4Add) $table4 .='<td><p style="color:red";>'.round($value,2).'</p></td>'; } else { if ($table4Add) $table4 .='<td><p>'.round($value,2).'</p></td>'; } } } if($table4Add) $table4 .= '</tr>'; } $row++; } $table4 .= '</tbody></table>'; fclose($handle); echo $table4; // display tables } } ftp_close($conn_id);
  4. jadeg

    FTP server

    Thanks for the responses, the password contained a special character and that was the issue
  5. jadeg

    FTP server

    now I have tried fopen('ftp://user:pass@server/crio1/cRIO01_live.csv', "r") Now I get the error fopen() [function.fopen]: Couldn't resolve host name in
  6. jadeg

    FTP server

    Thank you. I have tried this previously on another sever and it seemed to have worked file
  7. jadeg

    FTP server

    I have tried making a passive connection and still it does not work
  8. jadeg

    FTP server

    Sorry about that. This is the code $ftp_server="server"; $ftp_user_name="user"; $ftp_user_pass="pass"; $conn_id = ftp_connect($ftp_server) or die ("Couldn't connect to $ftp_server"); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if($login_result) { echo '<h1> Last Second Reading for Bridgetford T1 </h1>'; if(($handle = fopen('/crio1/cRIO01_csv', "r")) !== false) { $data = fgetcsv($handle, 0, ","); var_dump($data); } } with this I get the above error
  9. I'm getting an error message anytime I try accessing a file on a remote FTP server. Here is the code I've got $ftp_server="server"; $ftp_user_name="user"; $ftp_user_pass="passs"; $conn_id = ftp_connect($ftp_server) or die ("Couldn't connect to $ftp_server"); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if($login_result){ ftp_pasv($conn_id, true); $handle=fopen('crio/criolive.csv); } I get this error message any pointer to why this is?
  10. I have set up the cron job. To run on the website how do I go about that? Do I just run the script that has the cron job scheduled?
  11. I have a PHP function and I want the function to be called every minute. I know how to do this in javascript, just don't know how to make it work in PHP. How do I go about that
  12. dump of array $data before I perform the array_walk works just file. After the array_walk though, I get an error
  13. Thank you so much! That works
  14. I am trying to multiply every value in the array by 2. Below is my code. However i get the error Unsupported operand types in C <?php session_start(); ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); $ftp_server="server"; $ftp_user_name="user"; $ftp_user_pass="pass"; $conn_id = ftp_connect($ftp_server) or die ("Couldn't connect to $ftp_server"); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if($login_result) { echo '<h1> Last Second Reading for Bridgetford T1 </h1>'; $handle=file('ftp://user:pass@server/public_html/test.csv'); $data =array(); $i=0; foreach ($handle as $row) { if($i==0){ $i++; } else { $data1= explode(",", $row); $count=count($data1); for($c=0; $c<$count; $c++) { if($c>0){ $data[$i][$c]=$data1[$c]; // populate 2 by 2 array } } $i++; } } function myarray (&$val) { $val=$val*2.0; } array_walk($data,'myarray'); var_dump($data); } else { echo "There is a problem\n"; } ftp_close($conn_id); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.