lookee Posted November 4, 2008 Share Posted November 4, 2008 Everything works except the verification of whether a row is already in table. Basicially if 1 row exists, code should quit running and echo "already purchased" message. Code ---------------------------- // Select the Database $db_select=mysql_select_db($db_name); if (!$db_select) { die ("Couldn't select the database: <br/>". mysql_eror()); } // Assign the Query $query = "SELECT * FROM shoes WHERE username = '$username' AND size > 0"; <---------- If size greater than 0 already placed an order) // Execute the Query $result = mysql_query($query); if (!$result) { die ("Line 117 Could not query the database: <br />". mysql_error()); } if ($query == 1) <----- if 1 row exists - order for shoes already in database, so exit { die ("You already made a request!"); } mysql_query("INSERT INTO shoes VALUES('purchase_number','$username','$first_name','$last_name','$address','$city','$state','$zip','$email','$size','date') ") or die(mysql_error()); Header("Location: successful_purchase.php"); include 'close_db.php'; ?> Any help with my logic would greatly help! Link to comment https://forums.phpfreaks.com/topic/131301-solved-datebase-wont-verify/ Share on other sites More sharing options...
BoltZ Posted November 4, 2008 Share Posted November 4, 2008 Put your code in code tags [ code] [ /code]. It makes code easier to read Link to comment https://forums.phpfreaks.com/topic/131301-solved-datebase-wont-verify/#findComment-681861 Share on other sites More sharing options...
lookee Posted November 4, 2008 Author Share Posted November 4, 2008 Solved... if (mysql_num_rows($result) > 0) Link to comment https://forums.phpfreaks.com/topic/131301-solved-datebase-wont-verify/#findComment-681871 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.