Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/27/2019 in all areas

  1. You are using PDO in your later code which is good. You next need to create a PDO connection. The docs give an example which was copied below. Obviously, you want to rename $dbh to $db. Note that if you simple searched "php pdo", the first result would be http://php.net/manual/en/book.pdo.php which doesn't give any examples. Instead of randomly going through each link (which isn't necessarily a waste of time), always check the __construct link first. PS. Get rid of all your constant definitions for your database connection values. At first you might think it is a good idea, but having too many constants gets complicated fast. I like to locate a file called config.ini in a secure location (i.e. not in your public root directory!) and use parse_ini_file() to convert it into an array. <?php /* Connect to a MySQL database using driver invocation */ $dsn = 'mysql:dbname=testdb;host=127.0.0.1'; $user = 'dbuser'; $password = 'dbpass'; try { $dbh = new PDO($dsn, $user, $password); } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); } ?>
    1 point
  2. I suggest strtr(). EG $trans = [ '105.f' => "<a href='?search=105.f'>105.f</a>", '106.g' => "<a href='?search=106.g'>106.g</a>", '107.f' => "<a href='?search=107.f'>107.f</a>" ]; $text = "lorem ipsum 105.f dolor sit 106.g amet"; echo strtr($text, $trans);
    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.