Call undefined function mysqli_connect()
Results 1 to 5 of 5

Thread: Call undefined function mysqli_connect()

  1. #1
    Junior Member
    Join Date
    Jun 2015
    Posts
    1

    Call undefined function mysqli_connect()

    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

  2. #2
    phpMaster
    Join Date
    Jun 2005
    Location
    Europe
    Posts
    2,988
    Run phpinfo to see if MySQLi is on the list of extensions

    Make page with
    PHP Code:
    <?php
    phpinfo
    ();
    ?>
    And run it.
    If MySQLi is enabled it should be on the long list.
    Apache2.4.12 (Win64) / PHP5.6.9 / MySQL5.6.16 / phpMyAdmin4.1.7

  3. #3
    PHP Witch laserlight's Avatar
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    13,704
    Quote Originally Posted by m4u_hoahoctro
    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.
    Use Bazaar for your version control system
    Read the PHP Spellbook
    Learn How To Ask Questions The Smart Way

  4. #4
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    14,175
    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.
    Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from Nation, by Terry Pratchett

    "But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because hes a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html


    eBookworm.us

  5. #5
    Member
    Join Date
    Apr 2015
    Posts
    53
    Not used that connection type much but I thought it required server, username, password and database as seen in the below example

    PHP Code:
    <?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();
    }

    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •