SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: MySQL beginner

  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    aquí
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL beginner

    Hi guys. I am a beginner in databases. I am actually reading a book in which I have found this single code to create a database:

    <HTML>
    <HEAD>
    <TITLE>Creating a Database</TITLE>
    </HEAD>
    <BODY>
    <?php
    // Set the variables for the database access:
    $Host = "localhost";
    $User = "user";
    $Password = "password";
    $DBName = "NewDatabase";

    $Link = mysql_connect ($Host, $User, $Password);
    if (mysql_create_db ($DBName, $Link))
    {
    print ("The database, $DBName, was successfully created!<BR>\n");
    }
    else
    {
    print ("The database, $DBName, could not be created!<BR>\n");
    }

    mysql_close ($Link);
    ?>
    </BODY>
    </HTML>


    I'm trying to execute it in a local way (I have PHPTriad) but it doesn't work. I have launched apache and MySQL (for Windows 98). I really don't understand these variables: 'user' and 'password'. If I'm working in my computer, what is the user? and what is the password?...

    Any idea about the problem?

    Thank you very much

  2. #2
    SitePoint Member bellaco's Avatar
    Join Date
    Jul 2003
    Location
    Earth :)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The user and the password to your database. If you haven't created a user yet, you can set $User to 'root' and $Password to ''.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    aquí
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the answer but it still doesn't work.
    I have written:

    $User="root";
    $Password="";

    ¿?¿?

  4. #4
    SitePoint Member bellaco's Avatar
    Join Date
    Jul 2003
    Location
    Earth :)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how do you login to your database (with mysql)?

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    aquí
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I am trying to create a database but not in my hosting cos I still don't know how to use them. I just want to practice in my computer. I just launch 'apache' and 'MySQL' and execute that code and it works but the database is not created:

    "The database, ..., could not be created!"

    So, I don't understand what do you mean when you say How do I login to the database.

    What is happening??.....THANKS AGAIN!...


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
  •