Jump to content

Kurrel

Members
  • Posts

    70
  • Joined

  • Last visited

    Never

Posts posted by Kurrel

  1. Hi there,

     

    I've checked the apache error logs and it contains details of recent restarts.  I can see errors I'd expect from other things if I look a week or two back, but nothing related to this.

     

    How would I check for a memory leak?  I've watched task manager for a while but it doesn't give very particular date.

     

    I have error reporting set to the following :

    error_reporting  =  E_ALL & ~E_NOTICE & ~E_STRICT

    Is there a way to check these details despite the 500 error (seeing as it dominates the screen)

  2. 1, I didn't include the loop, just the CURL call that is inside the loop.

    2, I'm almost certain it's returned via my server.  It's a full on white screen without me printing out the response... is there any further way to make sure of this?

    3, Unfortunately, the script is pretty specific to APIs I know on all three systems.  However, you have got me thinking.  I'm going to load a large set of dummy data and remove one, then the other and finally both exterior calls from the script.  If one is breaking, that'll be a big step in the right direction.

  3. Hi there,

     

    I'm writing an application that pulls from two separate web based APIs, collates the data into a single array of data.  Once done, it then enters a loop that cycles through the array and executes a cURL call for each cycle.  This worked perfectly for a controlled set of 10 artificial records and so I've started testing with live data.

     

    On running the code, I eventually the following :

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

     

    I'm not sure how to debug this and so I'm hoping I can find some help here.

    I'm running WAMP, and the php.ini contains the following:

    max_execution_time = 0 ; Maximum execution time of each script, in seconds

    max_input_time = 0 ; Maximum amount of time each script may spend parsing request data

     

    Through testing, I have discovered the following :

    The script can do exactly 35 iterations through the loop in under 2 minutes.

    Any number greater than this causes the error.

    If I skip the first 20 curl submits, I can then do 21 to 55 iterations before failure, so I do not believe it is the 36th value.

    If I put a sleep(5) command into the loop, I can still do 35 and no more iterations than that.

    If I put a sleep(10) command into the loop, it fails on 35 and needs less.

     

    $action		= "post";
    				$url			= "http://url.url.url/api/v1.0/udo_Position/create"; // I've replaced the actual URL out of necessity
    
    				// set user agent {
    					print("Setting CURL options, using URL ".$url."<br>");
    					$cd = curl_init();
    					curl_setopt($cd, CURLOPT_HEADER, 1);
    					curl_setopt($cd, CURLOPT_URL, $url);
    					curl_setopt($cd, CURLOPT_USERPWD, 'username:password');
    					curl_setopt($cd, CURLOPT_RETURNTRANSFER, 1);	// Don't send return value to screen
    					curl_setopt($cd, CURLOPT_USERAGENT, "Firefox/2.0.0.1"); // spoofing FireFox 2.0
    					curl_setopt($cd, CURLOPT_VERBOSE, true);
    				// }
    
    				if ($action == 'get') {
    					;
    				} elseif ($action == 'post') {
    					print("POST set;<br>");
    					print("<pre style='font-family:verdana;font-size:13'>");
    					print_r($pointval);
    					print("</pre>");
    					$pointval["save"]	= "Save"; // The AddNew step form requires this.
    
    					curl_setopt($cd, CURLOPT_POSTFIELDS, $pointval);
    				} else {
    					print("Invalid usage. Please see example<br>");
    					return;
    				}
    
    				$reply = curl_exec($cd);
    
    				$http_status = curl_getinfo($cd, CURLINFO_HTTP_CODE);
    				print("<pre style='font-family:verdana;font-size:13'>");
    				print_r($http_status);
    				print("</pre>");
    
    				print("Here is the reply from the AddNew function: <br>");
    				print("<pre style='font-family:verdana;font-size:13'>");
    				print_r($reply);
    				print("</pre>");
    
    				if (curl_error($cd)) {
    					print("Error: ".(curl_error($cd))."<br>");
    				}
    
    				curl_close($cd);
    				print("Insert Successful.<br>");
    

     

    I am uncertain whether it is a PHP, Apache or cURL issue at this point.  I have another script that pushes a great deal more cURL calls to the same system but pulls from only one external resource, instead of two.  Any help or suggestions would be appreciated.

  4. Also, try this to get a listing of the files in the directory base.  You may find that the program is referencing a different directory base to the one you're expecting.

    if ($handle = opendir("../")) {
    while (false !== ($file = readdir($handle))) {
    	print($file."<br>");
    }
    closedir($handle);
    }
    

  5. Hi PHPers,

     

    I've written code that allows a user to input the location of a csv file.  My code then takes the CSV file, reads the contents and adds some additional fields calculated from several contained fields.

     

    $source							= $_FILES["filesource"];
    
    		$sourcehandle			= fopen($source["tmp_name"], "rb+");
    		$destination			= FIRSTBASE."/calculator/masscalcs/";
    		$destname					= "updated ".$source["name"];
    		$desthandle				= fopen($destination.$destname, "w");
    
    		$count						= 0;
    
    		while (!feof($sourcehandle)) {
                                  // Math stuff and lots of fwriting
    		}
    
    		fclose($sourcehandle);
    		fclose($desthandle);
    

     

    This file is created on the server side fine.

     

    The problem comes in trying to download the darn thing back to the user's machine.  So far I can get a file named correctly but filled with php code, from the previous page so far as I am aware.

     

    This has been accomplished with :

    
    		header("Content-type: text/x-csv");
    		header("Content-Disposition: attachment; filename=\"".$destname."\"");
    		header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    		header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    
    

     

    I've tried a couple of variations on this, including form downloads but the results have varied between the php-spam in the file to an empty file simply named 'updated', no extension and no contents.

     

    Help?  ???

     

    Kurrel,

    - All smiles.

  6. Hi PHPers,

     

    I've been creating a large form for submission, with several dozen fields.  The data is posted to a separate function through form submission, and I've found it easier to sort all the data by making the names of each input into arrays,

    <input id='inputname".$count."' name='conf[tasks][name]' value='".$taskval["name"]."' style='width:100%;'>
    

    for example.

     

    However, in creating a calendar date picker, I've had to use 'getElementsByName'.  This works fine if the name of the referenced input is not an array, but will not work in the above cited example.

     

    Is there a way to make this work, or am I doing something really bad in what I'm doing above?

     

    Kurrel,

    - All smiles.

  7. Hi everyone,

     

    I've a table that has all the status updates of several dozen units and I need to create a list of each unit's 3 most recent updates.

     

    MySQL server versio : 5.0.27-community-nt

     

    $sql = "select dtTime , liGPSID , fLatitude,fLongitude from GPSData where liGPSID > " . $lastpoint . " and dtTime > '$start' ORDER by dtTime";
    

    This currently pulls all the records from the database, ordered by most recent.  This can be over 50k records, though, sometimes a 100 for each unit.

     

    The table structure : (I can't do a direct pull right now, I'll try update this asap.)

     

    Id, dtTime, liGPSID, fLatitude, fLongitude, truckid, userid, deleted

     

    I've tried limiting by time, but some of the units are updated several times a minute and some are updated only once every few hours.

     

    I tried a group and order combination, but they don't return all the other details included in those records.

     

    Is there any SQL command to return the most recent update, and from that the 3 most recent?  They're all stamped with unix dates.

     

    Please, help?

     

    Kurrel.

  8. Okay, that works so far as not throwing errors, but the pdf is then empty, containing no data.

     

    Double-checking, the original remains working and has all details in it but not the copied version.

     

    I wonder if the constant FIRSTBASE and file path are not coming through correctly?

     

    <?php
    $filepath=FIRSTBASE."/images/graphs/driverpdf.pdf"; // change your dir path
    $filename="driverpdf.pdf"; // change your file name 
    
    downloadFile($filename,$filepath);
    function downloadFile($filename,$filepath)
    {
    
    header("Content-type: application/pdf"); 
    header("Content-disposition: attachment; filename=".$filename); 
    header("Content-Length: " . filesize($filepath));
    header("Pragma: no-cache"); 
    header("Expires: 0"); 
    readfile($filepath); 
    return;
    }
    ?>
    

     

    Also, the new file is named to driverpdf-1.pdf rather than remaining the same as the original.  Is this significant?

  9. I am trying to download a generated pdf file from the server to the local machine.

     

    However, when running the script :

     

    header("Content-type: application/pdf"); 
    		header("Content-disposition: attachment; filename=driverpdf.pdf"); 
    		header("Content-Length: " . filesize(FIRSTBASE."/images/graphs/driverpdf.pdf"));
    		header("Pragma: no-cache"); 
    		header("Expires: 0"); 
    		readfile(FIRSTBASE."/images/graphs/driverpdf.pdf"); 
    
    		return;
    

     

    It downloads 'index.php'.  Has anyone seen this and do they possibly know what could be going on?  I don't understand why it's doing this, and can't find an explanation.

  10. Hi people,

     

    I don't know if this belongs here, but I hope so!

     

    I'm trying to start using SOAP in my applications, but at the moment I'm running up against installation problems.  Apparently PHP 5 and up comes with a natural SOAP API and I am running 5.2.0.

     

    php.net says that ' This extension is only available if PHP was configured with --enable-soap.' and I must admit I'm just drawing a blank.  Just got too many things going and believe I should know how to do this any given day.

     

    How do I configure PHP with --enable-soap?  The php.ini?  The command line?  I'm baffled, please help!

  11. No way at all to work with the com ports on the client machine?

     

    For more specific explanation, we are working with several computers that will have a scanner attached.  The hope was that by simply opening a browser we could collate several reading together directly rather than waiting for the computers to compile at day- or week-end.

     

    The idea being that each computer would need only the scanner and a network connection rather than deployed software.

  12. Hi everyone,

     

    I don't know if this belongs here or in the installation forums, but here goes :

     

    How do I allow my PHP code to access a COM port?

     

    When my web page loads from the server it tries to access the device on the local machine attached to the USB port COM3.  It sees it as being there, but gets permission denied from the device.  I am not certain whether this is something that needs to be set on the local machine, the serving machine or in the code of the web page.

     

    The server is Linux and the host machines are Windows.

  13. Okay, I've got that all installed, but I get the following :

     

    Warning: Specified serial port is not valid in /var/www/basefunctions/php_serial.class.php on line 117

     

    whenever I try to run it... I suspect there's an error on the port reference, because I can change it to com1 and run it on the localhost, with it discovering the device...

     

    Any idea what it might be if not '/dev/ttyS0'?

  14. Oddly enough, I was just looking at that example you describe!!  ;D

     

    It's not quite working for me, but that's the way of things.  I'll figure it out!

     

    What I'm getting at the moment is

     

    "Warning: Specified serial port is not valid in /var/www/basefunctions/php_serial.class.php on line 111"

     

    Is this trying to check the server machine, or will it be my local?  From Linux, what is the reference to the third Com port?  ttsy2?

×
×
  • 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.