Hi, I am building an asset tracking database and I have an issue. When checking an asset in, I want to be able to query the asset table to see if the asset exists, before creating a row in the transaction table indicating the asset has been returned. My issue is I don't know what functions to use, or the correct order to use the in. As a result I didn't know what to type in when it was time to search for help. So... Please forgive if this has already been answered. Here is my code: [code] if ($HTTP_POST_VARS['submit'] == "Check-In") { // Create short variables from form data $asset_tag=$HTTP_POST_VARS['asset_tag']; $user_id=$HTTP_POST_VARS['user_id']; // Add Slashes to escape control characters $asset_tag = addslashes($asset_tag); $user_id = addslashes($user_id); // Check for asset in database db_connect(); mysql_select_db('aws_assets'); $lookup = "SELECT * FROM assets WHERE asset_tag='$aset_tag'"; $lookup_result = mysql_query($lookup); if (!lookup) { echo('<p>Asset not in database! Add Asset?</p>'); exit(); } else { // Write asset to Database $update = "UPDATE assets SET status_id='1' WHERE asset_tag='$asset_tag'"; $update_result = mysql_query($update); if ($update_result) { $insert = "INSERT INTO transactions SET asset_id='$asset_tag', user_id='$user_id', status_id='1'"; $insert_result = mysql_query($insert); if ($insert_result) echo('<p>Your transaction has been recorded</p>'); } }[/code] So... As it is currently written, if a valid asset tag is used at check in, all goes according to plan, the assets table is updated, and the transactions table has a new row added to it. If however a bogus asset tag is entered, the assets table is not updated (as it should not be) but a new row is added to the transactions table with the bogus asset tag. I am sure the issue lies in these lines... but I don't know what to do. [code] if (!lookup) { echo('<p>Asset not in database! Add Asset?</p>'); exit(); } [/code] Please Help. Thank You