Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Senior Member iphong's Avatar
    Join Date
    Mar 2003
    Location
    Arlington, VA
    Posts
    751
    Member #
    916
    Here i got a problem while inserting a row in a table: here is my code:
    Code:
      mysql_connect("localhost","myusername","mypassword");
      mysql_select_db("test");
      $result = mysql_query("INSERT INTO user (name,password)
                          VALUES ('NULL', 'phong', 'abcdefgh')"); 
      print "<p>This file has the Database";
    the table "user" and two fields "name" and "password" are exist. anybody know???

    And i want to know how to display a database! does any one know the code for php? thank....!
    Vu Tuan Phong
    iPhongDesign

    http://iphong.com
    http://adstudio1.com

  2.  

  3. #2
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    138 times
    In table user, you're inserting 3 values where you're only showing 2 variables.

    The following code will display a basic table of your code.

    PHP Code:
    <html>
    <head>
    <title>bbbbbbbb</title>
    </head>
    <body>
    <?php

    //insert database connection code here
    $result mysql_query"select * from TABLENAME" );
    $num_rows mysql_num_rows$result );
    print 
    "There are currently $num_rows rows in the table<P>";
    print 
    "<table border=1>\n";
    while ( 
    $a_row mysql_fetch_row$result ) )
    {
    print 
    "<tr>\n";
    foreach ( 
    $a_row as $field )
    print 
    "\t<td>$field</td>\n";
    print 
    "</tr>\n";
    }
    print 
    "</table>\n";
    mysql_close$link );
    ?>
    </body>
    </html>
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  4. #3
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Also NULL shouldn't be in quotes unless you mean the literal text "NULL."
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  5. #4
    Senior Member iphong's Avatar
    Join Date
    Mar 2003
    Location
    Arlington, VA
    Posts
    751
    Member #
    916
    Ok thankx, i will try this. im glad to have some more help for this.
    Vu Tuan Phong
    iPhongDesign

    http://iphong.com
    http://adstudio1.com


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:00 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com