+ Reply to Thread
Results 1 to 2 of 2

Thread: Help connecting PHP to SQL

  1. #1
    shellybranchportfolio is offline x10Hosting Member shellybranchportfolio is an unknown quantity at this point
    Join Date
    Aug 2009
    Posts
    1

    Help connecting PHP to SQL

    Hi,

    I keep getting an access denied error when I try to connect my php file to the MySQL database. Here is my connection code, please tell me what I am doing wrong.

    $dbhost = 'localhost';
    $dbuser = 'search';
    $dbpass = '1Search2';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
    $dbname = 'shellyb_dbFamily1';
    mysql_select_db($dbname);

    Thanks

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Help connecting PHP to SQL

    What's the exact error message?

    DB usernames on X10 begin with your cPanel user name, e.g. shellyb_search. "search" is wrong for a DB username.

    Make sure you add the DB username to the 'shellyb_dbFamily1' database so it has access.

    Before asking a question, search the forum and the web at large for your error message. If it's a basic question, it's been asked before.

    Don't put your password in posts; use '***' or similar. Edit the post right now and change the p/w in cPanel.

    Don't use "or die()" in production code.

    The MySQL driver is outdated. Use MySQLi or (better yet) PDO.
    Last edited by misson; 08-30-2009 at 02:05 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. some php sql help needed
    By daktarie in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 12-05-2007, 05:04 PM
  2. Noticia De upgrade PHP espaņol
    By figu120 in forum General
    Replies: 2
    Last Post: 11-22-2007, 04:42 PM
  3. Important PHP Information
    By Bryon in forum News and Announcements
    Replies: 0
    Last Post: 11-21-2007, 02:08 PM
  4. PHP and SQL issues.
    By DarkDragonLord in forum Free Hosting
    Replies: 17
    Last Post: 03-29-2007, 10:05 PM
  5. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 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
x10hosting free hosting for the masses
dedicated servers