...

View Full Version : Php Question



eschuppe
03-10-2009, 05:59 PM
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
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>

oesxyl
03-10-2009, 06:28 PM
check if 'checkout' table have a field full_name and check to be 'full_name'.

best regards

ninnypants
03-10-2009, 08:44 PM
Also from my experience this:

$query = "INSERT INTO checkout (full_name, user_idnum, date, book) VALUES ('$fullname', '$_POST[user_idnum]', NOW(), '$_POST[bookisbn]')";
will need to be this:

$query = "INSERT INTO checkout (full_name, user_idnum, date, book) VALUES ('$fullname', '".$_POST['user_idnum']."', NOW(), '".$_POST['bookisbn']."')";



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum