Jump to content

garyed

Members
  • Posts

    176
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

garyed's Achievements

Advanced Member

Advanced Member (4/5)

1

Reputation

  1. I thought about marking this thread as solved but I would be lying because I still am in the process of trying to solve all my errors. It seems rather ridiculous that one version of php will work with errors turned off while a newer version won't. I've already fixed over a hundred errors in php 8.x & things are looking worse than before I started. I can go back to php 7.4 & the program will work flawlessly. If it's not an undefined variable error, it's a string & int error or something else. It's frustrating because I spent years writing this program & just learned as I was going along. It's been working fine for 10 years & now the upgrade to php 8.x has killed it. I've got over 1000 variables I'm dealing with & hundreds of calculations so it's not a simple task.
  2. I appreciate the help. It's a lot of good information that I've got to process. I'm a little slow at times but i'll eventually get it.
  3. I'm tried your code but it still doesn't insert the session data in the fileds & dropdown when I leave & return. I'm not sure what I'm missing but the only thing I know to do is to add something similar to what I already have to get it to work.
  4. Thanks, I'll check into "heredocs". I never even heard of it before you just mentioned it. I'm also going to study your code until I understand it better. What I'm really trying to do is to havel all 50 states in the dropdown menu from a MYSQL database & put whichever one is selected into the session. Then change the page to perform another task then return to the page & have the state from the session be already selected upon return.
  5. It seems to work fine but I would like to hear what you guys who are more versed in php think. In my previous post I was trying find a way to hide the errors but I really want to get things right this time. This is a sample code that I'm using as a test but on my site I'm going to be pulling my variables off a database & using a while loop to fill in all 50 states. <?php error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); // Starts session & uses function to keep data */ function get_value($var) { // this will check your session if it's not empty and you send an empty post if ($_POST[$var]!="" || (!empty($_SESSION[$var]) && $_POST[$var] === '')) { $_SESSION[$var]=$_POST[$var]; } if (isset($_SESSION[$var])){ return $_SESSION[$var];} else{ return $_POST[$var];} } if(!isset($_POST['submitter'])) {$_POST['submitter']="anything"; } // initialize to avoid Undefined array key error ?> <form name="test" action="" method="post"> <input type="text" style="width:255px;" name="owner" value="<?php if(isset($_POST['owner'])) {echo get_value('owner'); } else { if(isset($_SESSION['owner'])){ echo $_SESSION['owner'];} } ?>"> <br> <input type="text" style="width:255px;" name="renter" value="<?php if(isset($_POST['renter'])) {echo get_value('renter');}else { if(isset($_SESSION['renter'])){ echo $_SESSION['renter'];} } ?>"> <br> <select name="state" > <option value=""> select state </option> <?php $state1="Maine" ; $state2="Texas" ; ?> <option value="<?php echo $state1; ?>" <?php if(isset($_POST['state'])) { if(get_value('state') == $state1) { echo 'selected="selected"'; } } else { if(isset($_SESSION['state'])){ if ($_SESSION['state']==$state1) { echo 'selected="selected"'; } } } ?> > Maine </option> <option value="<?php echo $state2; ?>" <?php if(isset($_POST['state'])) {if (get_value('state')==$state2) { echo 'selected="selected"'; }} else { if(isset($_SESSION['state'])){ if ($_SESSION['state']==$state2) { echo 'selected="selected"'; } } } ?> > Texas </option> </select> <br> <br> <br> <input type="submit" value="submit"> &nbsp; &nbsp; <input name="submitter" type="submit" value="clear session"><br> </form> <?php if ($_POST['submitter']=="clear session") { echo $_POST['submitter']."<br>"; session_destroy(); }; print_r($_SESSION); ?>
  6. This seems like a hard way to do it but it looks like it works OK. Any suggestions ? value="<?php if(isset($_POST['owner'])) {echo get_value('owner'); } else { if(isset($_SESSION['owner'])){ echo $_SESSION['owner'];} } ?> "
  7. Thanks for the ideas, I can get rid of the errors by initiating $_POST['submitter'] & testing if $_POST['owner'] is initiated but then my session variable gets lost when leaving the page. Keeping the session variable is where my problem is. if(!isset($_POST['submitter'])) {$_POST['submitter']="hello"; } // insert before using $_POST['submitter'] // change value of input to this: value="<?php if(isset($_POST['owner'])) {echo get_value('owner'); }?> " The session variable is really not lost but it doesn't appear in the input field after leaving the page & coming back to it which is the problem especially if I'm dealing with a lot of inputs.
  8. Follow up with code: I didn't know if i should post this as a separate thread or not since the question is about fixing errors instead of covering them up. I'm trying to figure out how to get rid of the errors in this code because it's very similar to my site with a lot more inputs & I'm stumped. <!DOCTYPE html> <html> <head> </head> <body> <?php error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); // Starts session & uses function to keep data */ function get_value($var) { // this will check your session if it's not empty and you send an empty post if ($_POST[$var]!="" || (!empty($_SESSION[$var]) && $_POST[$var] === '')) { $_SESSION[$var]=$_POST[$var]; } if (isset($_SESSION[$var])){ return $_SESSION[$var];}else{ return $_POST[$var];} } ?> <form name="test" action="" method="post"> <input type="text" style="width:255px;" name="owner" value="<?php echo get_value('owner'); ?> "> <br> <input type="submit" value="submit"> &nbsp; &nbsp; <input name="submitter" type="submit" value="clear session"><br> </form> <?php if ($_POST['submitter']=="clear session") { session_destroy(); } print_r($_SESSION); ?> </body> </html>
  9. Thanks for the encouragement, I know I'll get it done but it's just going to take time. I just do this as a hobby & the code on the site in question I wrote about 10 years ago. When you don't do it everyday, it's easy to forget how you did something that far back. I was just hoping I could fool php8.0 like i did 7.2 for a little while longer
  10. I understand what you're saying & I definitely want to straighten the code out & get rid of all the errors properly. I had the same problem about a year ago,when my webhost upgraded the php version to 7.4. I turned off the errors to keep the site up & running & started trying to fix things but I just gave up after a couple days. I got lazy since everything was still working & just forgot about doing anything about the errors. I should have fixed things while I had the time but now I'm paying the price for procrastinating.
  11. Not that I know of but that doesn't mean they are not there. I wouldn't even know where to look for them.
  12. Yes, since my site works under php 7.4 by turning off errors, is there a stronger way to turn off errors that might allow it to still work under php 8.0?
  13. I've got about a thousand of them : Then it gets even worse because all of those errors can go away by turning off errors but then when you go further into the site it will lock up completely & go blank. If I keep the errors turned on then I can't get to the part of the site where it locks up to see what error is causing the lockup. It's actually a very involved load calculation sight with a lot of inputs & a lot of people use it & I want to keep it going.
  14. I have tried investigating but have come up dry. Error 500 is pretty generic & doesn't give any specific details & I don't know where to start looking. Even if it's a permission issue I still don't know what to do to fix it. I've tried a couple edits on config files the other day but they didn't work & I can't even remember what I tried now. My next step was to copy all the phpmyadmin config files while I have 7.2 running & then compare them with the config files with 8.1 running. That's probably a waste of time but I figured before I do that I would post here & see if anyone was familiar with the problem.
  15. I have two versions of php (7.2 & 8.1) installed along with Apache server on Ubuntu 18.04 that I can switch back & forth from. If I enable 7.2, Phpmyadmin works fine but if I enable 8.1 & try to open Phpmyadmin, then I get the " HTTP ERROR 500" along with "localhost is currently unable to handle this request" message. Any ideas?
×
×
  • 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.