To administer your WestHost account, please enter your
Domain Name or Server Manager Username.

WestHost: Professional Website Hosting Company








Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Dec 2006
    Posts
    7

    Question Newbie: need help quick with sql and php

    I'm using DreamWeaver to create a website. I need to be able to update information in a database from my website. Anyway, I created a database named "symptominformation" and a table named "information" in PHPMyAdmin. I now need to be able to connect to that database in DreamWeaver. I've been using PHP inside dreamweaver and it worked for sending forms, but now it won't let me connect.
    I used this code and I get the "Unable to select database." Can anyone help me?

    "<?
    $username="I put in my username for westhost.com";
    $password="I put in my password for westhost.com";
    $database="symptominformation";

    mysql_connect(localhost,$username,$password);
    mysql_close();

    @mysql_select_db($database) or die("Unable to select database");
    ?>

  2. #2

    Default

    Two quick items at first glance....

    1. The default username for MySQL is 'root', so unless you have set up a different user for mysql, try using root.
    2. You are closing your database connection right after you connect, so that is probably why the mysql_select_db() is failing.

    If that still doesn't work then try putting your mysql_connect() in an "if" statement to ensure that you are successfully connecting to the database in the first place.

    Let us know if that doesn't work.

    -Blender

  3. #3
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,687

    Default

    To add to what Blender has suggested don't forget to enable remote access to the MySQL database in your Site Manager. Also the password for the database would not be the same as that for your main site log in unless you entered that same password when you installed MySQL via the Site Manager.

    It might be best to create a new user and password in phpMyAdmin other then the default. Click on the Permissions link and then you'll see the link to create a new user.

    Don't forget the links to documentation on both MySQL and phpMyAdmin that are in the phpMyAdmin program. They can answer many basic questions that may arise.
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  4. #4
    Junior Member
    Join Date
    Dec 2006
    Posts
    7

    Smile Thanks guys!

    Thanks! I finally got it to connect. You are lifesavers.

Similar Threads

  1. PHP and Microsoft SQL Server - Connection help
    By braestjohn in forum PHP / MySQL
    Replies: 1
    Last Post: 12-06-2007, 03:13 PM
  2. New to PHP / SQL
    By davedup in forum PHP / MySQL
    Replies: 3
    Last Post: 12-21-2006, 02:53 PM
  3. Best HTML PHP SQL Editor
    By AndreyPopov in forum PHP / MySQL
    Replies: 3
    Last Post: 01-12-2005, 09:38 PM
  4. Using PHP to connect to remote Microsoft SQL server
    By Village Hermit in forum PHP / MySQL
    Replies: 0
    Last Post: 10-26-2004, 01:17 AM
  5. PHP script to run a club.
    By Armadillo in forum PHP / MySQL
    Replies: 5
    Last Post: 05-19-2004, 11:17 PM

Posting Permissions

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