Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Uploading a MySQL database

Options
  • 05-09-2005 1:38pm
    #1
    Registered Users Posts: 597 ✭✭✭


    Hello All,

    I'm learning php at the moment and have a basic question. I have created a page that connects and displays info from a MySQL database and I wanted to upload it to a webserver to test it. I created an sql dump from the database and uploaded it along with the php file (not 100% sure if this was the thing to do). Obviously it didn't work, but I was wondering if someone could point out the steps that I am missing.

    Heres the error message I got:

    Fatal error: Call to undefined function: mysql_connect() in /home/kspoker/www/phptests/index.php on line 6

    I've tested the webserver with a basic php page and it works fine.

    Thanks


Comments

  • Registered Users Posts: 2,157 ✭✭✭Serbian


    You need to enable the MySQL extension in the php.ini. Look for the line:

    ;extension=php_mysql.dll

    and remove the semi-colon and it should work for you.


  • Registered Users Posts: 597 ✭✭✭yeraulone


    Thanks serbian,

    I checked my php.ini file on my local server, and extension=php_mysql.dll is already enabled. So does this need to be the same on my webserver? If so, how do I access this file? Or is there something in conf.inc.php thet needs to be changed?

    Sorry if these Qs are a little lame - just trying to get my head around it.


  • Registered Users Posts: 5,335 ✭✭✭Cake Fiend


    yeraulone wrote:
    So does this need to be the same on my webserver?

    Yep. You'll probably have to get on to the server admin to enable it. Are you sure the server is actually running MySQL? I'd imagine it would be unusual for them to be running MySQL and not have the extension enabled for PHP.


  • Registered Users Posts: 597 ✭✭✭yeraulone


    Hi Sico - Yes its definetly running.

    I reckon its probably the way I'm dealing with the database. I'm guessing that its stored in the wrong place (I just placed the .sql file into the root directory). Or my database connection is pointing to the wrong place. Right now its:

    <?php
    $username="username";
    //$password="password";
    $database="contacts";

    mysql_connect(localhost,$username);
    @mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM details";

    I know Localhost needs to come out of there - but what should replace it? Do I need to get in touch with my server admin to find out what the path is?

    Once again I apolise for the silly questions - I've had no problem doing it with asp and an simple access database, but I cant seem to get my head around it.

    Thanks folks.

    J


  • Registered Users Posts: 394 ✭✭Mickah


    You need to access the control panel for your website. You should have got the address from your provider. Log in there and you should find all the paths and info you need to access mySQL. All those paths could be in your Admin email from your provider, the one with all the passwords.

    Maybe look for a program called phpMyAdmin, an admin interface for you mySQL databases. It'd be through something like this you'd upload your sql dump.

    P.S. your site is set to default to index.asp not index.php!


  • Advertisement
  • Registered Users Posts: 5,335 ✭✭✭Cake Fiend


    See, this:
    yeraulone wrote:
    Fatal error: Call to undefined function: mysql_connect() in /home/kspoker/www/phptests/index.php on line 6

    would lead me to believe that the php MySQL extension hasn't been enabled properly on the server. If it is, mysql_connect() shouldn't be an 'undefined function' - it might give an error on the username or password (or database), but it should be a recognized function. Best ask your admin about it.


  • Registered Users Posts: 597 ✭✭✭yeraulone


    ok - thanks sico and Mickah.


  • Registered Users Posts: 4,003 ✭✭✭rsynnott


    You'll need to take this up with your host, I think. Who are they? Oh, one thing you could try is using mysql_pconnect instead; they may be forcing people to use that to cut down on unneccessary traffic on their end.


  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    Ok call me foolish, but I have spotted several major problems with this

    1."I created an sql dump from the database and uploaded it along with the php file" - er I hope you uploaded the dumped sql file into your database and it merely isnt sitting on your server as a whatever.sql file - as that is not how php connects to a database

    2. mysql_connect(localhost,$username); - this function, you have specified incorrectly, it should be mysql_connect($host, $user, $pass)

    Where:
    $host = hostname - this is usually localhost
    $user = username
    $pass = password

    You should really contact your host as you seem to be going in circles on this issue


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Serbian & rsynnott at al are correct, MySQL simply isn't enabled on the server. You need to get that fixed before you do anything else.

    adam


  • Advertisement
  • Registered Users Posts: 597 ✭✭✭yeraulone


    Thanks folks - its sorted. I really appreciate all you feedback on this.


Advertisement