Karaethon Posted March 31, 2019 Share Posted March 31, 2019 I'm suddenly having trouble using my connection to my MySQL database... (yes it was working but now...) I have the Connection created in an include file and stored in variable $DB, in the main file that includes the file containing the$DB there are other includes for classes. These classes are SUPPOSED to use $DB to connect to and SELECT/UPDATE/INSERT, but for a reason I cant figure out they suddenly stopped seeing $DB. it keeps saying its an undefined variable. If you need to see code I can post... Quote Link to comment Share on other sites More sharing options...
requinix Posted April 1, 2019 Share Posted April 1, 2019 What's changed recently? Quote Link to comment Share on other sites More sharing options...
Karaethon Posted April 2, 2019 Author Share Posted April 2, 2019 On 3/31/2019 at 7:58 PM, requinix said: What's changed recently? Thats what I can't figure out. I undid and rolled back my changes and it still won't work.... I decided to give each class its own mysqli_connect and live with it. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted April 2, 2019 Share Posted April 2, 2019 Obviously, code is required if you really want us to try and help... BUT - please - only the relevant code? Like maybe the method that does the connection and the code that calls it and tries to go further after making/not making the connection. Quote Link to comment Share on other sites More sharing options...
gizmola Posted April 2, 2019 Share Posted April 2, 2019 13 hours ago, Karaethon said: Thats what I can't figure out. I undid and rolled back my changes and it still won't work.... I decided to give each class its own mysqli_connect and live with it. This reminds me of the old programmer joke about the code that calculates 1+2 and returns the value 4. To fix, the programmer adds: if (result = 4 then result = 3). In other words, it is never a good idea to work around something like this that should work, but doesn't. When Requinix asked what changed, we were expecting something like: "Upgraded to PHP 7" or "I added a new library" or "I am refactoring the database class." Sounds to me like you went and made your codebase a lot less DRY, which made it worse. Quote Link to comment Share on other sites More sharing options...
Karaethon Posted April 2, 2019 Author Share Posted April 2, 2019 I haven't made any system changes, only code changes, after undoing everything I still have no link. But like i said above, I'm giving eah class its own connection to the table it specifically uses. I would like the code reusability of a MySQL_Interface class but I can live with this a I can target specific table per class. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.