SitePoint Sponsor

User Tag List

Results 1 to 20 of 20
  1. #1
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Is there anything wrong with the code i use to create the table? Cause I can't select the table! Produces an error. ( I can connect to database successfully ).

    Thank you for your help.

    Code:
    CREATE TABLE Accounts (
       Username varchar(10) NOT NULL,
       Password varchar(8) NOT NULL,
       Name varchar(15) NOT NULL,
       Country varchar(15) NOT NULL,
       Age int(11) DEFAULT '0' NOT NULL,
       Date date DEFAULT '0000-00-00' NOT NULL,
       PRIMARY KEY (Username)
    );

  2. #2
    Feel my RewiredMind KMxRetro's Avatar
    Join Date
    Jan 2001
    Location
    Exeter, Devon, UK
    Posts
    477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope, worked OK for me.

    Maybe something in your SELECT statement? Post the query and I'll have a look.

    Cheers,

  3. #3
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Thanks for your Reply.

    Here's my SELECT statement.

    Code:
    $table_user = @mysql_select_db("Accounts");
    if (!$table_user) {
        echo "error";
        exit();
    }

  4. #4
    Database Jedi MattR's Avatar
    Join Date
    Jan 2001
    Location
    buried in the database shell (Washington, DC)
    Posts
    1,107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the "mysql_select_db" function is used to move the database context from one DATABASE to another..

    A database consisits of many tables, and you can have many databases in MySQL.

    What you want is the mysql_query( "SELECT ... FROM Accounts ..." );
    function.

  5. #5
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BTW,

    Her'e smy updated Database

    Code:
    #
    # Table structure for table 'Accounts'
    #
    
    CREATE TABLE Accounts (
       ID int(11) NOT NULL auto_increment,
       Username varchar(10) NOT NULL,
       Password varchar(8) NOT NULL,
       Country varchar(20) NOT NULL,
       Name varchar(20) NOT NULL,
       Age int(11) DEFAULT '0' NOT NULL,
       Email varchar(20) NOT NULL,
       Date date DEFAULT '0000-00-00' NOT NULL,
       PRIMARY KEY (ID)
    );
    Thanks MattR..I'll take a look when I'm home again. =) Dinner time~!
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  6. #6
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is not a reply

    I don't know what's going on with vBulletin - I would like to post some code but I cant post

    In the post below is there ant reason why I can't put the last snippet of code in php tags?
    Last edited by freakysid; Apr 12, 2001 at 04:44.

  7. #7
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So for every script that you want to access the database you need a connection to the database. You only need to open the connection once per script. Eg:
    PHP Code:
    $dbconx = @mysql_pconnect("host:3306""user""pword")
       or die( 
    $strError);
    @
    mysql_select_db("database"$dbconx)
       or die( 
    $strError); 
    Then when you want to perform an sql query on a table or tables in the database you format a query string and use mysql_query() as matt explans. An example would be
    PHP Code:
    $sql "SELECT * FROM Accounts";
    $result mysql_query($sql$dconx); 
    Now $result is a handle to a result set which is sitting around waiting for you to extract data from. Usually you will want to loop through the result set and extract one row at a time (temporarily storing it into an associative array) and say, for example format it as html. An example where we display each user and their country

    echo '<table>';
    while ($row = mysql_fetch_array($result) {
    echo '<tr><td>' . $row["Username"] . '</td><td>' . $row["Country"] . '</td></tr>';
    }
    echo '</table>';
    Last edited by freakysid; Apr 12, 2001 at 04:41.

  8. #8
    SitePoint Enthusiast nguip's Avatar
    Join Date
    Apr 2001
    Location
    Malaysia
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What wrong with vbulletin ? I can't post code here
    Ngu I.P.
    Web Developer

  9. #9
    Feel my RewiredMind KMxRetro's Avatar
    Join Date
    Jan 2001
    Location
    Exeter, Devon, UK
    Posts
    477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Seems to be having some problems. I just got the message "The server is too busy, try again later" in a vBulletin fully formatted page.

    Sudden boom in subscribers/viewers? Server probs? Who can tell?

    Not me

  10. #10
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So is there actually any problem with my code? Casue I still can't select the table.
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  11. #11
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BTW..I managed to get an error query, and it says Access Denied? WHY?

    I can connect to the database successfully.
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  12. #12
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BLEH!!! I'm stupid!!!!

    Accounts was the name of the table! I was suppose to specify the database name! ARGH!

    LOL
    Thanks once agian for ALL your help!
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  13. #13
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Blah - I was in the middle of typing a long winded post when I saw you got it sorted

  14. #14
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL Freaksid....you didn't post in the end?
    It would be good experience..

    I'm just starting out in this mysql thingy...so I'm really unclear about the whole process...well ( getting through slowly though )

    Thanks fro your ingenius help!
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  15. #15
    SitePoint Enthusiast nguip's Avatar
    Join Date
    Apr 2001
    Location
    Malaysia
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LoL

    You all just so cute ! So, I'll joinn you all loh.. I just finished Kelvin's tutorial.. so, I'm also newbies here.

    But, I haven't found the tutorial lynlimz talked about, the jump start of URL.

    I guess I may want to go thru that one as well
    Ngu I.P.
    Web Developer

  16. #16
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by nguip
    But, I haven't found the tutorial lynlimz talked about, the jump start of URL.
    Hmm...While you can read, practising and actually making the effort to do it is another. I read KYank's tutorials ages ago...when it was first released...geez...

    LOL

    What you mean bu the jump start url? lol...odn't get you on that! =)
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  17. #17
    SitePoint Enthusiast nguip's Avatar
    Join Date
    Apr 2001
    Location
    Malaysia
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well.. I probably get the title wrong here...

    Anyway it's "Jump-Start to easy URL's". I found it at last
    Ngu I.P.
    Web Developer

  18. #18
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh....BTW..Did I even mention that? lol
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  19. #19
    SitePoint Enthusiast nguip's Avatar
    Join Date
    Apr 2001
    Location
    Malaysia
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Huh ?

    Not you meh ? Oopss ... Sorry wrong person
    Ngu I.P.
    Web Developer

  20. #20
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL
    hmm..maybe it was me..just that i can't remember.
    haha
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein


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
  •