Jump to content

info@mkdesignmedia.co.uk

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

info@mkdesignmedia.co.uk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. function add_property ( &$add_property_id, $select_category, $select_type, $property_title, $property_county, $property_size, $property_status, $property_desc="", $location, $architect, $awards, $meta_title, $meta_keywords, $meta_description, $nu_order_id, $visible, &$submit, &$success_flag, $debug=0 ) { $debug_string = ""; $fcn_msg = ""; //test name doesnt exist in this category make sure Property name is not duplicated - by mistake or by refresh button! $sqlquery = "select property_title from ".SITE_DB_PREFIX."properties where property_title='$property_title'"; $sqlquery.= " and category_id='$select_category'"; //$sqlquery.= " and property_type_id='$select_type'"; $debug_string.= "<br />sqlquery:$sqlquery"; $result = mysql_query($sqlquery); $count = mysql_num_rows($result); if ($count>0) { $fcn_msg = "Property Title already exists in this category.<br />Try again with a different Property Title."; $submit = ""; } else { //get last order_id for this parent $order_sql = "select * from ".SITE_DB_PREFIX."properties"; $order_sql.= " where order_id is not NULL and category_id = ".$select_category; $order_sql.= " order by order_id"; $order_result = mysql_query($order_sql); $order_count = mysql_num_rows($order_result); $order_id = ($order_count + 1); //sql insert string $sql_add="INSERT INTO ".SITE_DB_PREFIX."properties ".PROPERTY_FIELDS." VALUES ("; $sql_add.="$select_category, "; $sql_add.="$select_type, "; $sql_add.="'$property_title', "; $sql_add.="'$property_county', "; $sql_add.="'$property_size', "; $sql_add.="'$property_status', "; $sql_add.="'$property_desc', "; $sql_add.="'$location',"; $sql_add.="'$architect',"; $sql_add.="'$awards',"; $sql_add .= "'" . $meta_title . "', "; $sql_add .= "'" . $meta_keywords . "', "; $sql_add .= "'" . $meta_description . "', "; $sql_add .= "'" . $order_id . "', "; $sql_add.="$visible"; $sql_add.=")"; $debug_string.= "<br />sql_add:$sql_add"; $result = mysql_query($sql_add); if (!$result) { $fcn_msg = "Error: Could not add Property."; $submit = ""; } else { $success_flag=1; //success $add_property_id = mysql_insert_id(); $fcn_msg = "Property has been Added to the Database."; //*** ORDERING *** //update order_ids $this->update_property_order_ids($add_property_id, $nu_order_id, 0); $debug_string.= "<br />mysql_insert_id():".$add_property_id."<br />nu_order_id:$nu_order_id"; //*** ORDERING *** }//end if (!$result) }//end if ($count>0) //debug code if ($debug==1) { echo "<div>add_property testvar:$debug_string</div>"; }//end if ($debug==1) return $fcn_msg; }//end add_property <!-- THIS IS THE UPDATED with property_county, property_size and property_status ADDED -->
  2. function Properties() { $this->sub_levels = 1; //1=on 0=off }//Constructor function //*********************************************************************************** //******************************* PROPERTY FUNCTIONS ********************************* //---------- START function to add property ---------- function add_property(&$add_property_id, $select_category, $select_type, $property_title, $desc_summary="", $property_desc="", $location, $architect, $awards, $meta_title, $meta_keywords, $meta_description, $nu_order_id, $visible, &$submit, &$success_flag, $debug=0) { $debug_string = ""; $fcn_msg = ""; //test name doesnt exist in this category make sure Property name is not duplicated - by mistake or by refresh button! $sqlquery = "select property_title from ".SITE_DB_PREFIX."properties where property_title='$property_title'"; $sqlquery.= " and category_id='$select_category'"; //$sqlquery.= " and property_type_id='$select_type'"; $debug_string.= "<br />sqlquery:$sqlquery"; $result = mysql_query($sqlquery); $count = mysql_num_rows($result); if ($count>0) { $fcn_msg = "Property Title already exists in this category.<br />Try again with a different Property Title."; $submit = ""; } else { //get last order_id for this parent $order_sql = "select * from ".SITE_DB_PREFIX."properties"; $order_sql.= " where order_id is not NULL and category_id = ".$select_category; $order_sql.= " order by order_id"; $order_result = mysql_query($order_sql); $order_count = mysql_num_rows($order_result); $order_id = ($order_count + 1); //sql insert string $sql_add="INSERT INTO ".SITE_DB_PREFIX."properties ".PROPERTY_FIELDS." VALUES ("; $sql_add.="$select_category, "; $sql_add.="$select_type, "; $sql_add.="'$property_title', "; //$sql_add.="'$desc_summary', "; $sql_add.="'$property_desc', "; $sql_add.="'$location',"; $sql_add.="'$architect',"; $sql_add.="'$awards',"; $sql_add .= "'" . $meta_title . "', "; $sql_add .= "'" . $meta_keywords . "', "; $sql_add .= "'" . $meta_description . "', "; $sql_add .= "'" . $order_id . "', "; $sql_add.="$visible"; $sql_add.=")"; $debug_string.= "<br />sql_add:$sql_add"; $result = mysql_query($sql_add); if (!$result) { $fcn_msg = "Error: Could not add Property."; $submit = ""; } else { $success_flag=1; //success $add_property_id = mysql_insert_id(); $fcn_msg = "Property has been Added to the Database."; //*** ORDERING *** //update order_ids $this->update_property_order_ids($add_property_id, $nu_order_id, 0); $debug_string.= "<br />mysql_insert_id():".$add_property_id."<br />nu_order_id:$nu_order_id"; //*** ORDERING *** }//end if (!$result) }//end if ($count>0) //debug code if ($debug==1) { echo "<div>add_property testvar:$debug_string</div>"; }//end if ($debug==1) return $fcn_msg; }//end add_property <!-- THIS IS THE ORIGINAL AND WORKS FINE -->
  3. class.properties.php attached as well Thanks guys! [attachment deleted by admin]
  4. Hi Guys, having one of them "why wont it work" nightmares whilst doing some updates on a web page someone else has coded, its a simple php and mysql insert string that has some validation on but no matter what I do it wont add a new property, it updates fine, i have only added three new fields to the original source files, property_county, property_size, property_status, it should have been a simple job but has got me stumped, anyone got any suggestions? The script uses three files, properties.php - which is the page which holds the form class.properties.php - which contains the functions - this is where i think the problem is.... and property_form.php - which is just the form, this is fine, just the above two that seem to be causing the problem!! any suggestions would be greatly appreciated. Thanks Matt [attachment deleted by admin]
×
×
  • 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.