Jump to content

ober

Staff Alumni
  • Posts

    5,327
  • Joined

  • Last visited

Posts posted by ober

  1. Well the path returned by pathinfo uses backslashes, so I have to use backslashes for the rest unless I replace them all with forward slashes, which I don't think I've tried.  And my editor doesn't like it when I don't escape them, so I assumed I had to (PHP Designer 7).

     

    This is the error:

    Warning: fopen(C:\\Program Files\\FDS\\DTManage\\Web\\DTM\\php\\DTBill\\sources\\snapshot\\snapshot.txt): failed to open stream: Permission denied in C:\Program Files\FDS\DTManage\Web\DTM\php\DTBill\sources\snapshot\createExport.php on line 5 Cannot open file (C:\\Program Files\\FDS\\DTManage\\Web\\DTM\\php\\DTBill\\sources\\snapshot\\snapshot.txt) Warning: fclose(): supplied argument is not a valid stream resource in C:\Program Files\FDS\DTManage\Web\DTM\php\DTBill\sources\snapshot\createExport.php on line 32
  2. You would have to know the contents of the entire page before you knew if it contained a div with a certain class.  Are you generating the rest of the page?  I'm assuming that the div would have already been added by the time you're running the above code?  If so, set a variable when that div is created and then read the variable when you get to this part of the page.

     

    The only other option would be to write the contents of the page to a variable and check the variable for the string containing the div.

  3. I'm not sure that's the best way to check for valid links.  You're probably hitting the script processing limit because file_get_contents can take a while depending on server load and where you are grabbing the file from.  I'm not sure what the answer is, but I don't think looking for an input element on the page is the most efficient way to go about it.

  4. I'm trying to create a simple data dump to a text file.  It was all working fine and now fopen doesn't like my relative paths.  So I'm using an absolute path to the file:

     

    C:\\Program Files\\FDS\\DTManage\\Web\\DTM\\php\\DTBill\\sources\\snapshot\\snapshot.txt

     

    But fopen keeps saying it can't open the file.  It's acting like it isn't there.

     

    $path_parts = pathinfo(__FILE__); 
    $filename = str_replace('\\', '\\\\', $path_parts['dirname'])."\\\\snapshot.txt";
    
    if (!$handle = fopen($filename, 'w')) {
         echo "Cannot open file ($filename)";
    }

     

    Can someone tell me why this isn't working?  :wtf:

  5. WTF...

    for(i=1;i<totalboxes;i++)
        {
            if(document.getElementById('bill'+i).value != null && document.getElementById('bill'+i).value != '')
            {
                total += Number(document.getElementById('bill'+i).value);
            }
        }
        alert(billtotal);
        total = total*1 + billtotal*1;
        alert(total);

     

    The first alert gives me the number.  The loop is working fine, but when I try to add the two together, I get "NaN".  This is insane!

  6. Anyone else have any ideas?  parseFloat triggers a result of NaN.  Using eval doesn't change anything.

     

    Here is the entire function:

     

    function calculate_ger(_box)
    {
        // ger calculation including totals for GER and Billable units
        var gerbox = document.getElementById('ger'+_box);
        var billbox = document.getElementById('bill'+_box);
        var ratebox = document.getElementById('price_rate');
        var retval = billbox.value * ratebox.value;
        gerbox.disabled = "false";
        gerbox.value = retval.toFixed(2);
        gerbox.disabled = "true";
        
        // billable units total calculation
        
        var billtotal = 0;
        var totalboxes = document.getElementById('boxcount').value;
        var billtotal = parseFloat(document.getElementById('billtotalx').value);
        var billtotalbox = document.getElementById('billtotal');
        
        var i=0;
        for(i=1;i<totalboxes;i++)
        {
            if(document.getElementById('bill'+i).value != null)
            {
                billtotal += parseFloat(document.getElementById('bill'+i).value);
                //alert(billtotal);
            }
        }
        
        billtotalbox.disabled = "false";
        billtotalbox.value = billtotal;
        billtotalbox.disabled = "true";
        
    }

     

    The first part works great.  I don't understand why the second part isn't.

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