I am a newbie, and I have just learned some knowledges about php
Today I tried using some command to work with database MySQL
In editor of phpdesigner, I typed this code:

<?php
phpinfo();

// Create connection
$db = mysqli_connect("localhost", "booksdb", "TABLEname") or die(mysqli_connect_error());

// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

?>

but when Ctrl + F9 to compile, It show error: Fatal error: Call undefined function mysqli_connect()

I saw some questions same me asked on stackoverlow, some ones said the reason is extension mysql has't been enabled yet. But I don't know how to to that ? ( I also setuped Xampp and Vertrigo )

So I need a suggestion from other members

Thanks for reading

    Run phpinfo to see if MySQLi is on the list of extensions

    Make page with

    <?php
    phpinfo();
    ?>

    And run it.
    If MySQLi is enabled it should be on the long list.

      m4u_hoahoctro wrote:

      some ones said the reason is extension mysql has't been enabled yet. But I don't know how to to that ? ( I also setuped Xampp and Vertrigo )

      What version of PHP was installed using XAMPP? What operating system are you using? According to the PHP manual's entry on MySQLi Installation:

      On Windows, for PHP versions 5.3 and newer, the mysqli extension is enabled and uses the MySQL Native Driver by default. This means you don't need to worry about configuring access to libmysql.dll.

      If you are not on Windows, then you should look at your php.ini file to find the appropriate configuration setting.

        It could be that PHPDesigner's syntax checking uses a different instance of a PHP installation. You may want to check its configuration to see what it's using and if it can be reconfigured to use the version you have installed under XAMPP. Maybe the quickest way to check that would be to create a simple script that just does the mysqli_connect(), put it in the web root directory configured for XAMPP, make sure XAMPP is up and running, then launch the script directly from your browser via http://localhost/name_of_script.php. If that works okay, then I suspect the culprit is PHPDesigner.

          4 days later

          Not used that connection type much but I thought it required server, username, password and database as seen in the below example

          <?php
          phpinfo(); 
          
          // Create connection
          $db = mysqli_connect("localhost", "booksdb","my password", "my database") or die(mysqli_connect_error());
          
          
          // Check connection
          if (mysqli_connect_errno()) {
          echo "Failed to connect to MySQL: " . mysqli_connect_error();
          }
          
          ?>
          
            Write a Reply...