WordPress Custom Query ‘no database selected’ after upgrading to 4.3.1 latest version

Upgraded word press version to latest version 4.3.1 and custom queries
are not working into word press Upgrade. It’s give message like “no
database selected”.

All the database details in wp-config.php are correct and working fine before up grade. following custom query which is gives message to me after upgrading to 4.3.1 latest version.

Please help to fixing it.

$sql = "select Country_Id, Country_Code,Country_Name from mopt_country where IsActive=1 order by Country_Name ASC";

$result = mysql_query($sql) or die(mysql_error());   

Related posts

1 comment

  1. Can you use mysqli which is safer and not deprecated like mysql function?
    I had some connection problem when I used the mysql function. Dunno why honestly.

    here is a sample code

        $mysqli = @new mysqli($DBServer, $DBUser, $DBPass, $DBName);
        if(!mysqli_connect_errno())
        {
            mysqli_set_charset($mysqli,"utf8");
    
            $sql = "            
                    SELECT param1,...,param9
                    FROM Table
                    ";
    
            if($stmt = $mysqli->prepare($sql))
                {
                    $stmt->execute();
                    $stmt->bind_result($param1,...,$param9);
                    while ($stmt->fetch())
                    {   
                        //your code
                    }
                }
            $mysqli->close();       
        }
        else
        {
            echo 'Unable to connect';
            exit();
        }
    

    Post your results after it.

    Also, as I have already said in my comments, a no db problem is a no db problem. Double check your creditians (user, pass, dbname).

    It seems logic after the upgrade, WP add any extra column or delete any column, but it doesn’t logic to change your db name.

    Edited:

    Probably, this is the reason that you have that error:

    check that link: Why shouldn’t I use mysql_* functions in PHP?

    As you can see, Quentin says that :

    • The “new” password authentication method (on by default in MySQL 5.6;
      required in 5.7)
    • All of the functionality in MySQL 5.1

Comments are closed.