Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Php Question

  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    25
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Php Question

    I've been trying to copy data from one database and insert it into another, however, I'm not exactly sure how you would go about doing that. The error I get says, "Unknown column 'full_name' in 'field list'". If it helps to view it, it is located at www.ericschuppe.com/checkout.php
    PHP Code:
    <?php 
    session_start
    ();


    include (
    'dbc.php'); 


    if (
    $_POST['Submit'] == 'Register')
    {
       if (
    strlen($_POST['user_idnum']) > 4)
       {
         
    header("Location: checkout.php?msg=ERROR: Incorrect Student ID. Please enter valid ID number.");
        }
       if (
    strlen($_POST['bookisbn']) < 4)
       {
         
    header("Location: checkout.php?msg=ERROR: Incorrect Student ID. Please enter valid ID number.");
        }

        if (
    $_POST['user_idnum'] && $_POST['bookisbn']) { // If everything is okay.
               
    $query "SELECT user_idnum FROM users WHERE user_idnum='$_POST[user_idnum]'";
               
    $result mysql_query ($query); // Run the query.
               
    if (mysql_num_rows($result) == 1) {
               
    $query "SELECT full_name FROM users";
               
    $fullname mysql_query($query);
               
            
    // Make the query.
            
    $query "INSERT INTO checkout (full_name, user_idnum, date, book) VALUES ('$fullname', '$_POST[user_idnum]', NOW(), '$_POST[bookisbn]')";
            
    $result mysql_query ($query); // Run the query.
            
    if ($result) {
            
            echo 
    '<p><b>You have been registered!</b></p>';
             exit(); 
    // Quit the script.
             
    } else { // If it did not run okay.
               
    echo '<p>You could not checkout a book due to a system error. We apologize for any inconvenience.</p><p>' mysql_error() . '</p>';
             }
             } else {
               echo 
    '<p>Your id number does not match.</p>';
               }
             
    mysql_close(); // Close the database.

        
    // End the conditionoal.

      
    }
    ?> 

    <link href="styles.css" rel="stylesheet" type="text/css">
    <?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?>
    <p>&nbsp;</p>
    <table width="65%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td bgcolor="d5e8f9" class="mnuheader"><strong><font size="5">Register Account</font></strong></td>
      </tr>
      <tr>
        <td bgcolor="e5ecf9" class="forumposts"><form name="form1" method="post" action="checkout.php" style="padding:5px;">
            <p><br>
              ID Number:
              <input name="user_idnum" type="text" id="user_idnum">
              </p>
            <p>
            Book:
             <input name="bookisbn" type="text" id="bookisbn">
             </p>
            <p align="center">
              <input type="submit" name="Submit" value="Register">
            </p>
          </form></td>
      </tr>
    </table>
    <div align="left"></div>
    </body>
    </html>

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    check if 'checkout' table have a field full_name and check to be 'full_name'.

    best regards

  • #3
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    Also from my experience this:
    PHP Code:
    $query "INSERT INTO checkout (full_name, user_idnum, date, book) VALUES ('$fullname', '$_POST[user_idnum]', NOW(), '$_POST[bookisbn]')"
    will need to be this:
    PHP Code:
    $query "INSERT INTO checkout (full_name, user_idnum, date, book) VALUES ('$fullname', '".$_POST['user_idnum']."', NOW(), '".$_POST['bookisbn']."')"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •