1
votes
<?php

  $con=mysql_connect('$url','$dbuser','$dbpass');

  if(!$con){
  die('cannot establish connection:'.mysql_error());
}
 $db=mysql_select_db("$db");
 if(!$db){
die('cannot found database:'.mysql_error());
 }
 ?>

Giving warnings :-

Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known. in D:\xampp\htdocs\connection.php on line 3

Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known. in D:\xampp\htdocs\connection.php on line 3 cannot establish connection:php_network_getaddresses: getaddrinfo failed: No such host is known.

Can anyone help ?

1
dl() but that isn't what's triggering these errorsMark Baker
Your problem here is using single quotes in your connect criteria: a value like $url in single quotes will be treated as a literal string $url not as a variable..... why are you quoting in the first place?Mark Baker
And you really shouldn't be using the MySQL extension anyway; start living in the 21st century, use MySQLi or PDO insteadMark Baker

1 Answers

0
votes

Use dl()

dlLoads a PHP extension at runtime

as well as use extension_loaded() to check extension is loaded

For mssql - dl('php_pdo_sqlsrv_56_ts.dll');

Example

<?php
// Example loading an extension based on OS
if (!extension_loaded('sqlite')) {
    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
        dl('php_sqlite.dll');
    } else {
        dl('sqlite.so');
    }
}