SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: mysqli_connect

  1. #1
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysqli_connect

    I am getting an error which says:

    Fatal error: Call to undefined function mysqli_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\Work\Storage\index.php on line 3

    Any script I use that calls to the mysql database gets this error: (The following code comes directly from Build your own database driven website using PHP& mysql 4th edition):

    Code PHP:
    <?php
     
    $link = mysqli_connect('localhost', 'root', 'password');
    if (!$link)
    {
    	$error = 'Unable to connect to the database server.';
    	include 'error.html.php';
    	exit();
    }
     
    if (!mysqli_set_charset($link, 'utf8'))
    {
    	$output = 'Unable to set database connection encoding.';
    	include 'output.html.php';
    	exit();
    }
     
    if (!mysqli_select_db($link, 'wcms'))
    {
    	$error = 'Unable to locate the choice database.';
    	include 'error.html.php';
    	exit();
    }
     
     
    ?>

    I have been researching this for at least two days straight and can't find an answer anyone have any ideas on how to solve this issue?

  2. #2
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    PHP Code:
    <?php
     
    $link 
    mysql_connect('localhost''root''password');
    if (!
    $link)
    {
        
    $error 'Unable to connect to the database server.';
        include 
    'error.html.php';
        exit();
    }
     
    if (!
    mysql_set_charset($link'utf8'))
    {
        
    $output 'Unable to set database connection encoding.';
        include 
    'output.html.php';
        exit();
    }
     
    if (!
    mysql_select_db($link'wcms'))
    {
        
    $error 'Unable to locate the choice database.';
        include 
    'error.html.php';
        exit();
    }
     
     
    ?>

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    same problem...

  4. #4
    SitePoint Enthusiast lkagan's Avatar
    Join Date
    Sep 2007
    Location
    Boca Raton, Florida
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The mysqli extension hasn't been installed on your version of PHP.
    Larry Kagan
    Lead Web Application Developer
    Superiocity, Inc.

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I went through and followed the directions in the book...How would I go about installing it??

  6. #6
    SitePoint Enthusiast lkagan's Avatar
    Join Date
    Sep 2007
    Location
    Boca Raton, Florida
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's a separate thread but I would recommend you google it. Search for mysqli extension php <your version> and whatever OS you are using.
    Larry Kagan
    Lead Web Application Developer
    Superiocity, Inc.

  7. #7
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have been doing that for the last two days and I even went as far as reinstalling vista on my laptop to make sure it wasn't a Vista issues because this was working on my laptop in the past. You mentioned it was a seperate thread...Would I post that thread here or in a different forum?

  8. #8
    SitePoint Enthusiast lkagan's Avatar
    Join Date
    Sep 2007
    Location
    Boca Raton, Florida
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Stay with the Sitepoint forums, just start a new topic.

    I have very little experience with Vista (thankfully) but Xampp is supposed to be a very good all-in-one installer of PHP, Apache & MySQL for Windows. Try using that free product. Download it here.
    Larry Kagan
    Lead Web Application Developer
    Superiocity, Inc.

  9. #9
    SitePoint Member JAY6390's Avatar
    Join Date
    Oct 2009
    Location
    UK
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you use WAMP you can change the extensions from the tray icon, without the need to enable them via the php.ini file

  10. #10
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I went ahead and started a new thread for the problem as suggested... here is a link to the new thread for anyone who is following this...

    http://www.sitepoint.com/forums/show...49#post4399349


Bookmarks

Posting Permissions

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