Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/03/2022 in all areas

  1. there's no good reason to have a try/catch block for the connection code. this is just typing for nothing. a connection error is a fatal problem for a database dependent web page. just let php catch any connection exception, where php will 'automatically' display/log the connection error for you. Keep It Simple (KISS.)
    1 point
  2. That's what confused me - your video of exactly what you did didn't show that bit. They aren't necessary as that is what your included code does. You don't need pdoConnect(). Your "connect.php" defines the $pdo connection varaiable. My db_inc.php contains const HOST = 'localhost'; const USERNAME = '????'; const PASSWORD = '????'; const DATABASE = 'test'); // default db function pdoConnect($dbname=DATABASE) { $db = new PDO("mysql:host=".HOST.";dbname=$dbname;charset=utf8",USERNAME,PASSWORD); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); return $db; } function myConnect($database=DATABASE) { mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $db = mysqli_connect(HOST,USERNAME,PASSWORD,$database); $db->set_charset('utf8'); return $db; } I use the pdoConnect() and myConnect() functions to create a connection as I have dozens of databases and, depending on who I am helping, I may need a PDO or a mysqli connection. This lets me use the same include file yet allows flexibility in my connections.
    1 point
  3. Dont be afraid of that. We have many years ahead of us. I try hard and get back to where I was 12-15 years ago, both in business and knowledge. There have been many tragedies along the way. It started with a business fall from 1000 meters and lots of lost money, many deaths in close family and relationships, one broken marriage, close personal bankruptcy, and ended up drinking two liters of vodka or whiskey straight up a day for 4-5 years, one brain stroke, one daughter (now 25) nearly left me (too), one grandchild 2 years old in October (she's the reason i was waking up ++ etc, etc. + I was exposed to a traffic accident 34 years ago that broke my body in small pieces and which was close to taking my life + ADHD that can not be medicated. Of course, it has given me a lot of life experience. This has among other things taught me to listen to others and share what I have. is knowledge, money, etc. One should never give up. Life is fragile and life is what one makes it. We must live and fulfill our dreams while we can. One day it is too late. So now my goal is to come back to where I was in knowledge and business. It's not easy as 50 years and with so many scars r, a lot of new on the front we work, but there I go. When it comes to business Barand knows a little about what a ride I had in the last half of the 90s and early 2000s. As time goes on, you will notice that Leon can also help, not just ask questions. I appreciate all of you and what you do for me. Thanks! I want to continue and be here. For me, this is the beginning of something long. 1.5 years have already passed. Take care guys 😊
    1 point
This leaderboard is set to New York/GMT-05:00
×
×
  • 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.