Jump to content

Help with an apparently rare php/mysql question


floppyraid

Recommended Posts

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();
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.