Jump to content

garyed

Members
  • Posts

    143
  • Joined

  • Last visited

Everything posted by garyed

  1. You are absolutely correct. All the errors I'm getting is from using empty strings in my calculations. I started fixing them by putting some of them in an array & then using array_sum which gets rid of the errors when empty strings are added together. Also zeroing out some worked too depending on the calculation but there are so many to do it was getting a little frustrating. I wanted to see if it was feasible to just not show the errors & by doing so everything is working just fine. Since the only errors are from using empty strings, I'm really just trying to find out what the down side is to using an empty string in a calculation other than displaying the error. I am already totally convinced that it is wrong to do but I'm just not convinced of the necessity to fix anything if its working.
  2. The problem is that I don't have any fires that I know of. The same code has been running smoothly for quite a few years. If I was having problems then it would make more sense to me. I may end up changing the code to get rid of the errors anyways but what harm does it do to have a non numeric value that is not being used? That's my question & if I hear a good reason to get rid of those non numeric values that wopuld help me make up my mind. I just don't want to throw in 50 or 100 if statements & arrays that don't help anything except keep errors from being displayed when i can accomplish the same thing with two words in an ini file. I'll know better in the future to be more careful with unused fields but I don't want to rewrite something that's already working & not get any better results..
  3. I found the answer & it was pretty simple. All i had to do was add the line "display_errors = Off" in php.ini & everything works just fine. Now I have to decide if I really want to do the work to correct all those non-numerical values or not. Other than not being notified of errors, does anyone see it causing a problem with functionality?
  4. If I didn't have so many errors I would agree but after spending an hour or two fixing some of those errors & seeing how long it was going to take to fix all of them I figured there's got to be an easier way. The program has been running fine for years on the same server & what is being called errors now have never had any effect on the functionality. I'm not saying it's the right way or the best way but I just don't see a need to fix anything if I can just get rid of the messages. Remember the error messages only appear when I add a two line php.ini file to the server to extend the session time. So I'm assuming it has just as much to do with the .ini file than the coding. It also runs fine on my server & I'm running PHP 7.2.24 where my web host is running PHP 7.2.33 so I assume there is a way to do something in the ini file. I just don't want to spend a couple days fixing errors for no reason if I can fix everything with a single line.
  5. Is there any way to disable the "A non-numeric value encountered" warning in the php.ini file? I don't get that warning on my Apache server but I do when I use the same code on my web host's server. I never got the warning until I uploaded a two line php.ini file to my web host so that I could keep my sessions longer than the default 24 minutes. This is the same online program related to my earlier post about too many inputs. I wanted to try sessions for a 24 hr. period but I'm getting tons of errors for any field that is not used which can be in the hundreds. If I delete my php.ini file from my web host & just let things default to whatever they are using then I don't get those errors,
  6. Very interesting. That seems like something to look into but I do move at a pretty slow pace. I really do appreciate the ideas.
  7. I started the project about seven years ago so I have been learning as i go. I may not have known how to put the state & cities on the same page at the time but that might be a good idea to cut it down to three pages instead of four. I know i wanted the last page & the page before it on separate pages. I didn't want things to look cluttered. The last page is going to have up to 20 rooms instead of just the one you see, so I wouldn't want anything else on it.
  8. Why don't I just give you guys a link to my site so it will be a little clearer what i'm doing. It's a load calculation program for home Heating & AC systems. https://www.loadcalc.net That site runs off a default 24 minute session & none of the data entered is anything I have any interest in at all. Now imagine that instead of calculating one room , doing 15 or 20 rooms the same way. That's what I'm working on. It can take some time do a full load calculation & almost the same amount of data needs to be entered into every separate room. I think I'm going to try keeping sessions but set my session.gc_maxlifetime to a higher number & see how things work out.
  9. I guess so, I have a basic shared server hosting package that includes (supposedly) unlimited mysql databases. I have heard that if you use more than expected whether it be traffic or load on the databases, that most web hosts will make you go to a private server.
  10. I guess I'm kinda stuck because all the things I need to do to make a session act similar to a cookie is going to put a lot more load on the server than I wanted to. I just don't know if I have any other options. I was hoping there was something I'm not aware of since i'm not very good at this stuff. I just learn as I go & I didn't even know that browsers had a limitation on cookies until after almost finishing my program. I do appreciate you telling me like it is, so I can get out of dreamland & face reality.
  11. I guess I can use sessions but I'm on a shared server & I don't know if it will be too much for my web hosting package. Also the problem with sessions is the user loses everything once they close their browser.
  12. I'm working on an online php program that can have a few hundred form inputs. Mainly just numbers from 1 to 50,000 depending on the field. I wanted to use cookies so the user can keep the data entered on their browser but i found out the hard way that the browsers have a limitation that I've exceeded. Does anyone have any ideas?
  13. Maybe what I'm trying to do can't be done in php but I would think it could be done. All I'm trying to do is be alerted in some way on my computer which is the Apache server, whenever someone accesses a particular web page on that server. Whether it's playing a wav file or sending a pop up on the screen it doesn't matter as long as it shows up on my computer. So far everything I've been able to do only creates an action on the client's computer that is accessing the web page but I can't get the client to create an action on the server(my computer).
  14. I actually tried all the steps you mentioned. I issued the same command I used in the exec() command on the php page through the terminal & the .wav file plays perfectly. I even echoed the " ls -l" command in the php file & got the correct results to make sure the path worked to the .wav file.
  15. Well I finally got music playing through php by using this code that someone had posted in this forum a while back: $_wav = "my.wav"; $_play = "<embed src='".$_wav."'>"; echo $_play; The problem is it only works on the computer who is accessing the page. Is there a way to make it work on my computer(the server) or in my browser when someone accesses the page so I can know when the page is being accessed?
  16. I'm not having any luck even getting a .wav file to play through a php file at all even from the server side let alone trying to get it to work from the client side. I've tried the suggestions in the link & nothing has worked so far. I must be missing something. I tried this in my php file: exec('/usr/bin/play /home/me/song1.wav'); When I access the php file I just get a blank screen. If replace the play command with "ls -l" it will show the file info when I access the file so i know I have the path right. If I type the same play command in a terminal the song will play so I don't understand what I'm missing.
  17. I'm running Linux Ubuntu but so far everything I've tried runs on the clients machine when they access the page & nothing has run on the server when they do so. Is "powershell -c" a Windows specific command or can it be used with Linux?
  18. So what you're saying is that I can put an exec() command on the php page that when it is accessed by another computer it would open up my mp3 player. That sounds simple enough but I'm not sure I know how to do it. I'll give it a try.
  19. This might be more than just a php question but here goes anyways. I have designed a php chat room page on my home Apache server just for a few friends & family. The problem I have is the only way for me to know if anyone is on the chat room page is if I'm actually viewing the php page. Is there a way that I can have the page alert me when someone accesses it? I was thinking something like activating a popup in my browser or even a beep so as long as I'm at my computer with my browser open that I will know someone has accessed the page.
  20. You are the man!! That did it, I removed the white space & it works like a top . I've been working on this for three days & couldn't figure out what I was missing. Thanks again
  21. Also the" xdata/tables.php" is the only path that I'm using but I guess all the path in front is because I'm on a shared server. For security reasons I changed a few numbers in the path but not the format.
  22. Here is the message that is displayed at the top of the same page where the text of the file is displayed:
  23. The code in the last post is pretty much it. That is where the problem lies. I tried taking away the if statement & substituting the name of a table so i could run that file by itself & it works fine on my server. I do the same thing on my web host server & instead of the file downloading it displays the full text of the file on the screen. I'm starting to think that there is nothing wrong with the code & that there is a problem with my web host settings. If you or anyone here using a mysql database can test this code on your server I would appreciate it. <?php $_table="table1"; // gets the table name from first page include ("mysql_login"); // opens mysql with $con as the database variable header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=table.csv'); $output = fopen("php://output", "w"); fputcsv($output, array('id', 'First_name', 'Last_name', 'email', 'phone')); $query = "SELECT * from $_table ORDER BY id ASC" or die ("Help"); $result = mysqli_query($con, $query); while($row = mysqli_fetch_assoc($result)) { fputcsv($output, $row); } fclose($output); ?>
  24. Here is the simpler code that I first used: <?php if(isset($_POST["first_page"])) { $_table=$_POST['table_name']; // gets the table name from first page include ("mysql_login.php"); // opens mysql with $con as the database variable header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=table.csv'); $output = fopen("php://output", "w"); fputcsv($output, array('id', 'First_name', 'Last_name', 'email', 'phone')); $query = "SELECT * from $_table ORDER BY id ASC" or die ("Help"); $result = mysqli_query($con, $query); while($row = mysqli_fetch_assoc($result)) { fputcsv($output, $row); } fclose($output); } ?> This works perfectly on my server. If you enter the link to my server it downloads right into the browser default download directory. It just doesn't work when i upload it to my web host. The same code just prints the .csv file to the screen instead of downloading.
  25. Okay, here goes & it might not be pretty. What I don't understand is if I type in my ip address & the path in my browser it will access my Apache server & mysql db, put the csv file on my server then automatically download it to my default browser directory. That is exactly how I intended for the code to work. When I upload it to my web host then it does everything except download to my computer. Anyways I would much rather do as suggested & never put the file on the server & just directly download it to the user's computer who has the password to access the php fil <?php ///////// Turn table into a .csv file & put it on server //////////////////// if(isset($_POST["first_page"])) // makes sure there is a submit value from the first page { $_table=$_POST['table_name']; // gets the table name from first page include ("mysql_login.php"); // opens mysql with $db as database variable // If statement is for the choice between two tables // Gets the results of the table & puts it in a .csv file on the server if ($_table=="table1") { $output = fopen("table1.csv", "w"); fputcsv($output, array('id', 'First', 'Last', 'email', 'phone')); } else { $output = fopen("table2.csv", "w"); fputcsv($output, array('id', 'First', 'Last', 'email', 'phone')); } $query = "SELECT * from $_table ORDER BY id ASC" or die ("Help it ain't working"); $result = mysqli_query($con, $query); while($row = mysqli_fetch_assoc($result)) { fputcsv($output, $row); } fclose($output); } ///////////////////// download file to user's computer depending on which table was chosen ///// if ($_table=="table1") { $file = './table1.csv'; if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.basename($file).'"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); readfile($file); exit; } } else { $file = './table2.csv'; if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.basename($file).'"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); readfile($file); exit; } } ?> e.
×
×
  • 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.