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
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    25
    Thanks
    3
    Thanked 0 Times in 0 Posts

    connection/resource error

    When executing the script I first recieved a resource id error 5(only posting in the sql in the collumn full_name), so I went and altered the section related to this field and when I enter the fields and try to execute the script, the script posts a blank page and does not insert any data into the database.
    Here is my code:
    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_string "SELECT full_name FROM users WHERE user_idnum='$_POST[user_idnum]'";
               
    $query_result mysql_query($query_string);
               
    $query_result_row mysql_fetch_object($query_result);
               
    $query_result_row->full_name;
               while (
    $query_result_row mysql_fetch_object($query_result)) {
                
    $query "INSERT INTO checkout (full_name, user_idnum, date, book) VALUES ('$query_result_row', '$_POST[user_idnum]', NOW(), '$_POST[bookisbn]')";
                 
    $result mysql_query ($query); // Run the query.
                
    }
            if (
    $result) {
            
    // Send an email.
            
    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>
    The page can also be found at www.ericschuppe.com/checkout.php
    Thanks so much.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    You might have something to do with http://www.codingforums.com/showthre...060#post617060
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

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

    Question

    I fixed something, that now it will take me to the "You have been registered!" screen instead of the previously blank screen. Additionally the only warning outputted is "Notice: Undefined index: Submit in /home/ericschu/public_html/checkout.php on line 12" but i assume thats be the submit button hasn't been pressed. Finally, now it appears everything works but no data is being inserted in the MySQL tables. I really have no idea and would be really appreciative of any help.

    to try the script:
    www.ericschuppe.com/checkout.php
    user id:
    0001
    book:
    any random string of numbers > 4

    Thank you so much.


  •  

    Posting Permissions

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