View Full Version : connection/resource error

03-17-2009, 06:14 AM
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:


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);
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>"; } ?>
<table width="65%" border="0" cellpadding="0" cellspacing="0">
<td bgcolor="d5e8f9" class="mnuheader"><strong><font size="5">Register Account</font></strong></td>
<td bgcolor="e5ecf9" class="forumposts"><form name="form1" method="post" action="checkout.php" style="padding:5px;">
ID Number:
<input name="user_idnum" type="text" id="user_idnum">
<input name="bookisbn" type="text" id="bookisbn">
<p align="center">
<input type="submit" name="Submit" value="Register">
<div align="left"></div>
The page can also be found at www.ericschuppe.com/checkout.php
Thanks so much.

03-17-2009, 08:52 AM
You might have something to do with http://www.codingforums.com/showthread.php?p=617060#post617060

03-17-2009, 07:20 PM
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:
user id:
any random string of numbers > 4

Thank you so much.