Results 1 to 3 of 3

Thread: PHP Help for a n00b

  1. #1
    Far Superior To Meths EvilWeevil's Avatar
    Join Date
    Apr 2005
    Location
    London
    Posts
    936
    Thanks
    14
    Thanked
    8 times in 6 posts
    • EvilWeevil's system
      • Motherboard:
      • Asus P5W-DH Deluxe
      • CPU:
      • Intel Core 2 Duo E6600
      • Memory:
      • 2GB (2x1GB) Corsair XMS-2 PC2-6400
      • Storage:
      • 320GB Caviar, 320GB DiamondMax 10, 400GB Spinpoint, 1TB MyBook External
      • Graphics card(s):
      • Asus EAX1900XT
      • PSU:
      • OCZ GameXStream 700W
      • Case:
      • Lian-Li PC-G70B
      • Monitor(s):
      • Dell 2407WFP
      • Internet:
      • Homechoice/Tiscali 8 down/1 up

    Question PHP Help for a n00b

    I'm trying to write a simple script to store four bits of info about a user in a MySQL database, taking info from a form, using this :

    <?
    $server="myserver"
    $username="myuser";
    $password="mypassword";
    $database="mydatabse";

    $first=$_POST['first'];
    $last=$_POST['last'];
    $email=$_POST['email'];
    $password=md5($_POST['password']);


    mysql_connect($server,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");

    $query = "INSERT INTO users VALUES ('$email','$first','$last','$password')";
    mysql_query($query);

    mysql_close();
    ?>


    But when I execute I get

    Warning: mysql_connect(): Access denied for user: 'myuser@myserver' (Using password: YES) in /home/www/hendriks.freeserverhost.net/eclipseware/signup.php on line 13



    I have connected fine to this same database with other scripts, the table I'm accessing is definitely there, and of course all the myuser, myserver etc. have just replaced my real info, but I definitely have it right.

    Any ideas?

    My DeviantArt | tomhendriks.co.uk | Need something (reasonable) hosted? PM me!

  2. #2
    Agent of the System ikonia's Avatar
    Join Date
    May 2004
    Location
    South West UK (Bath)
    Posts
    3,736
    Thanks
    39
    Thanked
    75 times in 56 posts
    this means the user you are connecting to the database does not have access to the database your connecting to, either the user does not have the right level of access on the database, or the actual host won't allow that user to connect from that host

    Try using some basic mysql outside of php to test where its failing

    mysql -u youruser -h yourhost -p

    then try

    mysql -u root -h yourhost -p

    then

    mysql -u root -h localhost -p

    and try combinations,

    most commonly that use will not have permissions from any other host other than local host, and then only if you explicitly grant that permission on database creation
    It is Inevitable.....


  3. #3
    Registered+
    Join Date
    Jun 2005
    Location
    Hereford, UK
    Posts
    29
    Thanks
    0
    Thanked
    0 times in 0 posts
    make sure these are all set correctly
    $server="myserver" -- normally localhost
    $username="myuser"; -- database username
    $password="mypassword"; -- database password
    $database="mydatabse"; -- database itself


    and ofcourse make sure you have a database setup
    Last edited by Durinthiam; 19-07-2005 at 12:01 PM.

    Computer Technician -- Now a smug daddy!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. PHP 4.3 vs 5 (which one should I start learning?)
    By malfunction in forum Software
    Replies: 8
    Last Post: 08-02-2005, 03:28 PM
  2. PHP Questions and a book recommendation
    By Dorza in forum Software
    Replies: 2
    Last Post: 02-09-2004, 01:26 PM
  3. Need help, php masters!
    By Allen in forum Software
    Replies: 10
    Last Post: 07-07-2004, 07:16 AM
  4. PHP and MySQL
    By Kezzer in forum Software
    Replies: 4
    Last Post: 28-10-2003, 02:59 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
  •