My function returns true but my code does not execute
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

My function returns true but my code does not execute

From: John Moore <nobody@nomail.com>
Date: Mon Oct 31 2005 - 03:08:16 CET

Hi,

I must be missing something obvious.

I cannot get this function to run the update query on Line 6, although
the call to run the query evaluates true, and both update_cat_total
functions execute, while the function itself returns true.

A var_dump shows that all the variables are valid, and I can run the
exact same update query at the mysql command line without errors. I've
echoed mysql_error() before and after the call to mysql_query() and no
errors show up.

But the update itself never runs! Can anyone see why?

function new_category($category_id=null) {
  global $category_id_new;

  if (create_category($_SESSION['cat_name'])) {
    // update this page with the new category_id
    $query = "UPDATE
                about
              SET
                category_id = $category_id_new
              WHERE
                about_id = $_SESSION[about_id]";

    if ($result = mysql_query($query)) {
    if (update_cat_total('add', $category_id_new) &&
update_cat_total('remove', $category_id)) {
        return true;
      }
      else {
        return false;
      }
    }
    else {
      return false;
    }
  }
  else {
    return false;
  }
}

Thanks

J Moore
Received on Mon Nov 21 02:53:16 2005