Jump to content

Adsa

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Adsa's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I changed my code slightly but still not able to get it to work. <?php //get end of file pointer $fp = fopen("file.log","r"); //set file pointer to end fseek($fp,0,SEEK_END); // get pointer $end_file = ftell($fp); // set start of file to scan from $start_file = 18456; // set pointer where to start scan fseek($fp,"$start_file",SEEK_SET); //display information while (!feof($fp)) { $userinfo = fscanf($fp, "%s %s %s %s %s %s %s %s %s %s %s %s %s \n"); if ($userinfo) { list ($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8, $field9, $field10, $field11, $field12, $field13) = $userinfo; $output = "$field1 $field2 $field3 $field4 $field5 $field6 $field7 $field8 $field9 $field10 $field11 $field12 $field13"; $output = rtrim($output); } $userinfo=NULL; } fclose($fp); ?>
  2. <?php $access_file_path = "file.log"; $last="18456"; $count =0 $handle = fopen("$access_file_path", "r") or die("can't open file"); while (!feof($handle)) { $userinfo = fscanf($handle, "%s %s %s %s %s %s %s %s %s %s %s %s %s \n"); if ($userinfo) { list ($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8, $field9, $field10, $field11, $field12, $field13) = $userinfo; $output = "$field1 $field2 $field3 $field4 $field5 $field6 $field7 $field8 $field9 $field10 $field11 $field12 $field13"; $output = rtrim($output); $count+=1; if ($count == $last) { $userinfo = fscanf($handle, "%s %s %s %s %s %s %s %s %s %s %s %s %s \n"); if ($userinfo) { list ($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8, $field9, $field10, $field11, $field12, $field13) = $userinfo; $output = "$field1 $field2 $field3 $field4 $field5 $field6 $field7 $field8 $field9 $field10 $field11 $field12 $field13"; $output = rtrim($output); echo "$output"; // do something with output } $userinfo=NULL; } } $userinfo=NULL; } fclose($handle); ?>
  3. Thanks for that i will give it a go. Although since the file is being written to all the time i still need to find the last parse point of the file when i open it again.
  4. Hi.. I need some help with parsing a file. I am parsing a log file to a db but the file is being written to all the time as well. I am wondering is there php command i can use so when i open the file i can go to the last parsed line of the .log file? or am i going to have to record the last line and match it the continue from there? Thanks in adavance
  5. Adsa

    input as image

    If i replace this echo "<p><input type=\"image\" name=\"submit\" value=\"submit\" src=\"img/buttons/register_1.png\" onmouseover=\"this.src = 'img/buttons/register_0.png'\" onmouseout=\"this.src = 'img/buttons/register_1.png'\"></p></form>"; With echo "<p><input type=\"submit\" name=\"submit\" value=\"submit\"></p></form>"; It works fine. Changing it to submit rather than an image it returns the form values.
  6. Adsa

    input as image

    I am trying to create a rollover image for a submit button but when i use the input type as image the values I am sending in the form are not getting sent. Is this how the image process works? I want to keep it as simple as possible Any help would be great. echo "<form method=\"post\" action=\"register1.php\" alt=\"Register\"><p><br>"; echo "<b>Name : </b><br><input name=\"full_name\" type=\"text\" id=\"full_name\"></p>"; echo "<p><b>Email : </b><br><input name=\"email\" type=\"text\" id=\"email\"></p>"; echo "<p><b>Password : </b><br><input name=\"pass1\" type=\"password\" id=\"pass1\"></p>"; echo "<p><b>Retype Password : </b><br><input name=\"pass2\" type=\"password\" id=\"pass2\"></p>"; echo "<p><b>Email Opt out? : </b><br><input name=\"opt_out\" type=\"radio\" id=\"opt_out\" value=\"No\" checked>No"; echo "<input name=\"opt_out\" type=\"radio\" id=\"opt_out\" value=\"Yes\">Yes</p>"; echo "<p><b>Code : </b><br><input name=\"user_code\" type=\"text\" size=\"11\"><br>"; echo "<img src=\"key/pngimg.php\" align=\"middle\"> </p>"; echo "<p><input type=\"image\" name=\"submit\" value=\"submit\" src=\"img/buttons/register_1.png\" onmouseover=\"this.src = 'img/buttons/register_0.png'\" onmouseout=\"this.src = 'img/buttons/register_1.png'\"></p></form>";
  7. Hi, I am a beginner when it comes to php and am wondering if any one can help me with some errors i am getting. I have a download script that access a Mysql DB and gets the relevant information like ip, port, ftp access name and pwd. Currently there are about 20 entries in the DB but not all require ftp access for downloading. Here is the script for downloading the files. <?php // Databse login information include ("include_db_access.php"); // get latest file from database $sql = "SELECT * FROM `ldr_config` "; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($newArray = mysql_fetch_array($result)) { $db_file = $newArray['file_no']; $ftp_server = $newArray['ftp_access']; $ftp_port = $newArray['ftp_port']; $ftp_user_name = $newArray['ftp_user']; $ftp_user_pass = $newArray['ftp_pwd']; $local_server_path = $newArray['local_folder']; $remote_server_path = $newArray['remote_folder']; // check to see if server has no ftp if ($ftp_server == "") { $no_server = "yes"; } if ($no_server != "yes") { // convert into correct file structure. $display_file = str_pad($db_file, 8 , "0", STR_PAD_LEFT); $logfile = str_pad($display_file, 12 , ".log"); // $local_server_name is the folder where we are storing the .log files $local_server_name = $local_server_path; $local_file .= $local_server_name; $local_file .= $logfile; // remote folder path this can be changed if required $remote_file = $logfile; // Get last file on remote server so we know when to stop downloading files. // set up ftp connection $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); ftp_pasv($conn_id, false); $buff = ftp_rawlist($conn_id, $remote_server_path, TRUE); // output the buffer $file_last = var_export($buff, true); $last_file = substr("$file_last", -16, -; // month value $logfile = $display_file; // Start downloading files and save them to $local_file location and also change directory path on remote server if ($remote_server_path != "") { if (ftp_chdir($conn_id, $remote_server_path)) { } else { echo "Couldn't change directory\n"; } } while ( $logfile < $last_file ) { $handle = fopen($local_file, 'w'); // try to download $remote_file and save it to $handle if (ftp_fget($conn_id, $handle, $remote_file, FTP_ASCII, 0)) { echo "$remote_file has sucessfully been saved to $local_file <br>"; } else { echo "file $remote_file does note exists\n"; } // increment file and continue download fclose($handle); $db_file = $display_file + 1; $display_file = str_pad($db_file, 8 , "0", STR_PAD_LEFT); $logfile = str_pad($display_file, 12 , ".log"); // reset some values so they dont duplicate $local_file = ""; $remote_file = $logfile; $local_server_name = $local_server_path; $local_file .= $local_server_name; $local_file .= $logfile; } // close the connection and the file handler ftp_close($conn_id); } // end if for no server $local_file = ""; $remote_file = ""; $file_last = ""; $last_file = ""; $display_file = ""; $no_server = ""; echo "<br>"; } Here is an example of the error I am getting. PHP Warning: ftp_login() expects parameter 1 to be resource, boolean given in down.php on line 73 PHP Warning: ftp_pasv() expects parameter 1 to be resource, boolean given in down.php on line 74 PHP Warning: ftp_rawlist() expects parameter 1 to be resource, boolean given in down.php on line 75 PHP Warning: ftp_chdir() expects parameter 1 to be resource, boolean given in down.php on line 91 PHP Warning: ftp_close() expects parameter 1 to be resource, boolean given in down.php on line 130 Thanks in advance
×
×
  • 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.