floppyraid Posted May 25, 2011 Share Posted May 25, 2011 Greetings, I'm building a very basic form and one of the checks I want to preform is far more difficult for me than I would have imagined. I am not very proficient (at all) with php, any help would be extremely appreciated. All I am trying to do is add a test/check with an error that the end user would see if they are trying to 'check out' a unit number that has already been checked out and has not been flagged as not 'returned'. Here is the snippet in question: $checkunitid = $_POST['uniid']; //checkexists($checkunitid); $q="select unit_id from check_in_out where `returned` = 'N' and unit_id = '" . $uniid . "'" function checkexists() { $result = mysql_query($q) or die(mysql_error()); if($row = mysql_fetch_array($result)) { return 1; } return 0; } if (checkexists()) { echo "<font size=7 color=red>record exists</font>"; exit(); } Link to comment https://forums.phpfreaks.com/topic/237424-help-with-an-apparently-rare-phpmysql-question/ Share on other sites More sharing options...
trq Posted May 25, 2011 Share Posted May 25, 2011 The first thing I notice is that you are using the variable $q within your function. It does not exist within the function. You should develop code with error reporting set to E_ALL and display errors on, this will display these simple errors. Link to comment https://forums.phpfreaks.com/topic/237424-help-with-an-apparently-rare-phpmysql-question/#findComment-1219978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.