Jump to content

charlie321

Members
  • Posts

    53
  • Joined

  • Last visited

Posts posted by charlie321

  1. I am not sure if this is a cpanel problem or coding problem.  I found another post from 4 years ago with almost an identical error code and it had something to do with an ini file in the cpanel i think.  I am not very good with the cpanel, so im at a loss.  I talked with several people from godaddy yesterday.  They said they can't help even though whatever they did caused the problem.  This is for a golf leage that I wrote most of the code for several years ago.  They could take me back to php 5.6.  This was written around 5.2 I believe.  I am not very good with php!

    This is the error I am getting:

    start error  [28-Mar-2024 12:52:36 UTC] PHP Warning: session_start(): open(/var/cpanel/php/sessions/ea-php56/sess_6308705c679006fc92d1c71ffed09d18, O_RDWR) failed: No such file or directory (2) in /home/rgxb6tc5wk5q/public_html/golf/login/login.php on line 20

    [28-Mar-2024 12:52:36 UTC] PHP Warning: session_start(): Failed to read session data: files (path: /var/cpanel/php/sessions/ea-php56) in /home/rgxb6tc5wk5q/public_html/golf/login/login.php on line 20  end of error.

    Sure would appreciate any help!!  Please let me know if you need code.

    Charlie

  2. We had to update our Linux server from php 5.4 to php 7.4.  Something has changed and I have a feeling it is due to changes in fputcsv.

    When running the code below, instead of opening a csv file in libre calc, it fills the browser with the result.  Is there a way of fixing this so I get the csv file again?

    <code>date_default_timezone_set("America/New_York");
    $filename = "import.csv";
    $fp = fopen('php://output', 'w');
    header('Content-type: application/csv');
    header('Content-Disposition: attachment; filename='.$filename);
    $then = time() - 3601;
    $query = "SELECT * FROM ppb_listings where user_id = '4' and unix_timestamp(start_time) > $then";
    $result = mysqli_query($conn, $query);
    while($row = mysqli_fetch_row($result)) {
        fputcsv($fp, $row);
    }
    echo $result;
    exit;
    ?>

    </code>

    Thanks for any help.

  3. Hi...  Thanks so much for your help.  Think I figured it out.  Works this way:

    <code> $then = time() - 3601;
    $query = "SELECT * FROM ppb_listings where user_id = '4' and unix_timestamp(start_time) > $then";

    </code>

    Nothing better than finally figuring out a stupid problem!! :)

     

  4. Thanks for the info.  I tried your query and does the same thing.  (nothing)   I'm wondering if possibly it has something to do with sql or something.  I even tried making it a week and it still finds nothing.

    Anyone have any other suggestions?

  5. Hi I am sorry.  I forgot to mention that.  start_time is a datetime field.  And yes..  If starttime is 7pm, and query for the csv file, all records starting at 7pm would show up show up on the csv file until approximately 7:59 PM.   

    Thanks for your consideration.  

  6. I am trying to import into a csv file and filter the results to a particular user and only results based on the time the data was uploaded within one hour.  In other words anything not uploaded within the last hour of the start_time will not appear in the csv file.  Everything works fine except for the time part.  I get no results at all with the 'and unix_timestamp........   For all I know possibly I am way off with my effort.  The field name is start_time.  Here is code below.  Appreciate any help.

    <code>  header('Content-type: application/csv');
    header('Content-Disposition: attachment; filename='.$filename);
    $then = time() + 3601;
    $query = "SELECT * FROM ppb_listings where user_id = '4' and unix_timestamp(start_date) < $then";
    $result = mysqli_query($conn, $query);
    while($row = mysqli_fetch_row($result)) {
        fputcsv($fp, $row);
    }
    echo $result;
    exit;

    </code>

  7. On 6/22/2020 at 11:21 PM, StevenOliver said:

    Okay, I meant semicolon....

    @charlie321, no, it was not mentioned that your file was an actual ".html" file (file with suffix .html). A server's PHP interpreter will only parse PHP if it is ".php" file (file ending with .php suffix).

    In the olden days, I stupidly had a server directive whereby php would parse both .php files AND .html files. Stupid stupid stupid. Never never never do this.

    Anyway, your code shows the input was hidden, so you probably wouldn't have seen it just casually looking at your web browser, but if you would have looked in the source code, you would probably have seen the words "<?php echo....." all spelled out :-)

    Barand, thank you -- I didn't know you could leave the semicolon off the last line. I don't think I would make a habit of it, though.... I'm so used to semicolons.

    OK  It does parse an html file on my localhost server.  So what changed the ability to parse an html file?  Linux, php, windows?  Just curious to find out why I can do it on localhost (workbench-windows) and not on linux-mariadb.  Thanks.

  8. On 6/20/2020 at 5:53 PM, Barand said:

    Are you now telling us that the php code that wasn't working was in a .html file and not in a .php file?

    No..  Actually I have been saying that from the beginning of this thread.  If I tried to pass this from the html file to the php file it passed nothing or 0.  That was on my mariadb server.  If I passed it on my localhost workbench server it worked.  When I changed the html file to a php file ie test.php  it worked on both servers.  Like I said I'd love to know why even though I did find a work around.  The original html and php scripts for this is in the original thread above.

  9. OK I have no idea why but I changed the html file to a php file and echoed the form.  It actually works now on both the localhost and server.  time() just would not pass from my html localhost script.  I would love to know why.  It might have something to do with the fact that my localhost is workbench and the server is mariadb.  Or the server could be a newer version of php.  Really appreciate the help and suggestions.

  10. 17 hours ago, StevenOliver said:

    you forgot the colon after echo time()

    While coding in PHP, having the following lines on top of all your PHP pages will save a ton of time. (Be sure to remove them before making your pages live to the public.):
    <?php
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);
    ?>

    Could you please explain further?  I think you were mistaken.  But if you are certain you are correct about the colon please explain in detail.

  11. Hi...  I have a little form and php script where I am trying to pass date() and get the seconds it takes to fill out the form.

    This works fine on localhost which is window based, but does not work on my server which is linux. 

    On my linux server a 0 or blank is showing in the passed field.

    Any ideas on what might be wrong?  I believe tjis is some sort of a minor coding error but my server shows no errors.

    Here is the script:

     

    <html>

    <form method="POST" action="test_time.php">
    <input type="hidden" name="tm" value="<?php echo time() ?>" />
    <input type="text" name="Name" size="15" placeholder="Enter Name">&nbsp;&nbsp;
    <input type="submit" value="Go" name="Submit">
    </form>
    </html>

     

    <?php
    date_default_timezone_set("America/New_York");
    $name = ucwords(strtolower($_POST['Name']));
    $st = $_POST['tm'];
    $formFilledInSeconds = time() - $st;
    echo $name."<br>";
    echo "start time: ".$st."<br>";
    echo "time: ".time()."<br>";
    echo "seconds: " .$formFilledInSeconds."<br>";
    ?>

  12.  

    Quote

    This is the final script:

    function tax_invoice($state,$subtotal,$credit,$shipping) {
       if ($state == "FL") {
         $stax = ($subtotal-$credit+$shipping) * .07;
            } else {
         $stax = 0;
    }
    return $stax;
    }

    I found php functions to be confusing, but at least I finally got it done.  Thanks for the suggestions which helped get me on the right track.

     

  13. Yes that was the problem with the script which I finally figured out just after my last post.  And then I realized this would work better.   $stax = tax_invoice($state,$subtotal,$credit,$shipping);   Blood dribbling down my head from the wall punches.   Take care.

  14. This is the code that is calling the function:

    tax_invoice($state,$subtotal,$credit,$shipping);

    I wrote an example that should show what is happening.  It does the exact same thing:

    <?php
    $stax = 0;
    $subtotal = 100;
    $ship = 15;
    echo (($subtotal+$ship) * .07). "  This is outside the function  Correct answer.<p>";

    function example($subtotal,$ship,$stax)  {

    $stax == (($subtotal+$ship) * .07);
    echo $stax . "  This is inside the function. Wrong answer.<p>";
    return $stax;
    }

    example($subtotal,$ship,$stax);  ##calling function.  Nothing there.

    echo " This is calling the function.  Gives a null which is wrong.";
    ?>

    There is something I'm not getting.  I would appreciate someone who knows php functions show me what I am doing wrong in the little script that describes the problem.

    I'd really appreciate it!

  15. I have posted a modified function above already.  Please reference that.

    Below is the code that woks fine as a non- function:

    if ($state == "FL") {
       $stax = ($subtotal-$credit+$shipping) * .07;
      }

    As I have said, this works but is redundant as it is presented several times throughout the code.  Thus my wanting to make it a function.

  16. I had taken the FL if statement out to see if that was the problem.  But did not work that way either.  This works fine in code.  Basically  am trying to get the result as sales tax for the state of Florida using subtotal of invoice, credit, and shipping totals.  Something within the function is preventing that from happening as it never gives anything but 0 for sales tax variable ($stax)  As I said it works fine in code.  I believe it is something to do with the variables not passing into or out of the function.  I have worked with functions in other languages with no problems passing variables. Has to be something I am missing.

  17. I tried this which I thought might be what you were getting at but no success.  More help please.

    function tax_invoice($subtotal,$credit,$shipping,$state) {
    if ($state == "FL") {
       $stax = ($subtotal-$credit+$shipping) * .07;
       return $stax;
    }
    }

  18. Trying to understand php functions.

    function tax_invoice() {
    if ($state == "FL") {
       $stax = ($subtotal-$credit+$shipping) * .07;
    }
    }

    #call function:

    tax_invoice();

    I have tried different variations including in script, on own functions program, using return, adding variables, etc.  Nothing seems to work unless I use it as a non-function in code.

    Please help.

     

     

  19. Sorry you feel that way.  I guess he will think for himself.  It's not that I am ignoring anything.  What I have done so far is working although I'm sure it isn't proper.  I guess I'm not a proper guy.  What works for me works.  I'm just learning how to do things.  I don't know arrays at all and more or less I am fumbling through this.  I don't know what question you are talking about but I'm only looking for the answers that will work for me the way I do things.  And I do realize I might turn people off for this.  But to be honest I find responses from people on this board in particular to be somewhat insulting and ignorant on their own.  Not all.  There are some cool people on here.  But there are also some pompous type people here.  There is no understanding that not everyone on this board has been doing this for a very long time.  There are people who are trying their best to get through this.  There are people who get overwhelmed by head banging problems and might miss some posts.  There are people who probably would rather not come to this board and ask questions only to be ridiculed by php gods.  The purpose of this board is to help others.  You sound like a professor I had in college who was very intelligent, but he didn't understand that he had no clue how to help others.  This I feel is a very unfriendly board with exceptions and to be honest I would rather not have to ask questions on it.  As a matter of fact earlier today I asked on a non-php board a php question because I really like that board.  The people are friendly and want to help others.  They aren't as much concerned that someone asks questions in the proper way, but they try their best to help others. 

    If I ask another question on this board, (and I probably will), you have absolutely no obligation to answer me just as anyone else doesn't.  But to make a comment such as you did in your post is ridiculous.  You sound like a person I'd rather not associate with.  You probably don't even golf!

    But still I wish you well in anything you pursue.  Just try to remember we are all human and not too many are perfect like you!

     

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