Skip to main content
paulc89302236
Participating Frequently
February 8, 2022
Question

Warning: strpos(): Empty needle in ...

  • February 8, 2022
  • 2 replies
  • 1069 views

DW created PhP (v7.4) page is throwing this warning linked to my DB connection file.

Seen a few suggestions recommending adding the following to the php.ini file

Under dynamic extenstions; 

 

extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll

 

But it hasnt resolved the warning issue.

Any other suggestions ?

    This topic has been closed for replies.

    2 replies

    B i r n o u
    Legend
    February 9, 2022

    what is your connexion piece of code ?

    paulc89302236
    Participating Frequently
    February 9, 2022

    I use WebAssists extention to create my local and remote connection:

    The warning cites line 15 - ive highlighted it below.

     

    <?php
    # FileName="WADYN_MYSQLI_CONN.htm"
    # Type="MYSQL"
    # HTTP="true"
    $hostname_MyDevDB = "localhost";
    $database_MyDevDB = "mydevices";
    $username_MyDevDB = "devuser";
    $password_MyDevDB = "pE8/AOzpL(";
    @15938396_start();
    $foundConnection = false;
    if ($foundConnection == false) {
    $domains = explode(",","192.168.0.143");
    for ($domindex = 0; $domindex<sizeof($domains) && !$foundConnection; $domindex++) {
    $domainCheck = trim($domains[$domindex]);
    if (strpos(strtolower($_SERVER["SERVER_NAME"]),strtolower($domainCheck)) !== false && ($domainCheck == "" || strpos(strtolower($_SERVER["SERVER_NAME"]),strtolower($domainCheck)) == strlen($_SERVER["SERVER_NAME"])-strlen($domainCheck))) {
    $hostname_MyDevDB = "192.168.0.143";
    $database_MyDevDB = "mydevices";
    $username_MyDevDB = "devuser";
    $password_MyDevDB = "pE8/AOzpL(";
    $foundConnection = true;
    }
    }
    }

    $MyDevDB = mysqli_init();
    if (defined("MYSQLI_OPT_INT_AND_FLOAT_NATIVE")) $MyDevDB->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, TRUE);
    $MyDevDB->real_connect($hostname_MyDevDB, $username_MyDevDB, $password_MyDevDB, $database_MyDevDB) or die("Connect Error: " . mysqli_connect_error());

    ?>

    B i r n o u
    Legend
    February 10, 2022

    For those wishing to avoid fiddling with two or more connection scripts for say test and live scenarios. 


    quote

    For those wishing to avoid fiddling with two or more connection scripts for say test and live scenarios. 


    By @paulc89302236

     

    Personally, for each projects, I generally work with several servers, for different purpose (tests, research team, customer proposal, beta version, production...) and depending on the projects and the teams, the problem rarely comes from the connection scripts, but from the (fine) configuration, and uses, of the servers themselves...


    in this sense, I have taken for habit, maybe wrongly, to set up a series of files that manage connections, rebalancing settings, constant dispatching, etc... that I place in a cloaked way, on my local space.

    I name them in a very HARD way, for example __connect-server-foo.php or __SESSION_settings_server-foo.php... and so on.
    In fact, these files are placed, modified, adapted only very rarely on their respective servers, where of course, they are named in a polymorphic way such as __connect.php or __SESSION_settings.php,

    Then, in order to be invoked only in a unique way in the form of rectification due to the access path so different according to the servers :

    <?php
        include_once('/'.trim( $_SERVER['DOCUMENT_ROOT'], '/' ).'/fooshared/__connect.php');
    ?>

     

    Nancy OShea
    Community Expert
    Community Expert
    February 9, 2022
    Nancy O'Shea— Product User & Community Expert