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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.