SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Thread: localhost?

  1. #1
    SitePoint Addict singersower's Avatar
    Join Date
    Nov 2004
    Location
    TX
    Posts
    240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question localhost?

    Hi,
    I'm running mySQL 5.0 with PHP 5.0 and trying to follow Kevin Yank's Database driven website.

    I keep getting
    Fatal error: Call to undefined function mysql_connect() in C:\Inetpub\wwwroot\ddw\chapter4\connection.php on line 10
    when I try to connect to the mysql server. I think that my problem is that I haven't correctly defined my string that defines my hostname and path.

    Here is the code I have so far:
    PHP Code:
    <?php 
    $dbcnx 
    mysql_connect('208.54.95.1''root' 'mysql');
    if (!
    $dbcnx) {
     echo( 
    '<p>Unable to connect to the '.
        
    'database server at this time.</p>' );
        exit();
        }
        
    ?>
    Thank you so much in advance, I feel like a dummy b/c it's probably something so simple.

    Singersower
    HopeSpring Design

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    did you try to use localhost instead of '208.54.95.1'
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Addict singersower's Avatar
    Join Date
    Nov 2004
    Location
    TX
    Posts
    240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, same error:
    I'm kinda wondering if it means that I was supposed to have to define the function in the configuration files??? I followed every step exactly in the book...

    I've tried C:/localhost and localhost and 208.54.95.1 and none of them work


    ho hum

    Singersower
    HopeSpring Design

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    is MySQL running?

    Edit: actully i think it might be the MySQL extension...did you activate it?
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Member sabinega's Avatar
    Join Date
    Jan 2006
    Location
    Vancouver
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    database connection

    Hi there,

    I attached my protocol. Of course you have to include your password and database name...

    <?php
    # FileName="Connection_php_mysql.htm"
    # Type="MYSQL"
    # HTTP="true"
    $hostname_con_web = "localhost";
    $database_con_web = "databasename";
    $username_con_web = "username";
    $password_con_web = "password";
    $con_web = mysql_connect($hostname_con_web, $username_con_web, $password_con_web) or trigger_error(mysql_error(),E_USER_ERROR);
    ?>

    It's been a while since I configurated my php etc.. But you have to find out what your testserver is called. On apple it's localhost. After that I remember that I had to put a password and username in mysql.
    The name con_web is my connection name in your case I guess it's dbcnx.
    If you don't use myAdmin yet I highley recommand it. It is opensource and really good. www.phpmyadmin.net
    If you install myadmin you have to look for the file config.inc.php
    there you have the change the $cfg['PmaAbsoluteUri'] to $cfg['PmaAbsoluteUri']= 'http://localhost/phpmyadmin/';
    After that you should be able to start myAdmin under http://localhost/phpmyadmin
    I hope I could help you. Good luck. You can find a lot of information about this stuff in the internet.

  6. #6
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Code:
    Fatal error: Call to undefined function mysql_connect() in C:\Inetpub\wwwroot\ddw\chapter4\connection.php on line 10
    this has nothing to do with the wrong username, host, etc. your php is misconfigured.

    very simply, the mysql extension for PHP is not installed or enabled. edit your php.ini file and look for the line that says extension_dir= and note that directory. then find the line that says php_mysql.dll and uncomment it. look for that file in your PHP directory and copy it to the directory you noted earlier if it's not already there. then restart you webserver service.

    if you're using a recenty version of PHP and mysql 4.1 or newer, then use php_mysqli.dll instead and replace all references in your PHP code from mysql_ to mysqli_

  7. #7
    SitePoint Addict singersower's Avatar
    Join Date
    Nov 2004
    Location
    TX
    Posts
    240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up Awesome!

    That is exactly what happened! I hadn't uncommented the extensions and directed the php.ini file.

    Thank you so much for your insight!

    Woo hoo I have liftoff!


    Singersower
    HopeSpring Design

  8. #8
    SitePoint Addict singersower's Avatar
    Join Date
    Nov 2004
    Location
    TX
    Posts
    240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Sabinega,
    Thank you for the tip about configuring my phpMyAdmin,
    I had downloaded it and then never installed it. Works like a charm now

    Thanks to all of you, each of your comments are helpful
    Singersower
    HopeSpring Design

  9. #9
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Installation really sucks, doesn't it? Are Kevin Yank's instructions amiss or did you not follow them correctly?

    A suggestion: write down everything you did to get your installation to work including any false steps and the corrections you made, and save your notes. There will undoubtedly be someone next week going through the same problems you did, and then you'll be able to help them get php installed.

  10. #10
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why dont people just use one of the programs like xampp, everythings built in. Works like a charm for me so far. Maybe Kevin will add something like this in a later version of the book, or are we learning how to do it properly
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  11. #11
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    XAMPP is cool, but I prefer to set up everything just how I want it. I guess I'm not the only one

    Plus, I can switch between PHP 442 and PHP 512 very easily, simply by editing a couple of lines in httpd.conf and restarting Apache. I tried that once using one of the XAMPP-like setups, and it just kept moaning about stuff >.<


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
  •