close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Admin Category Manager?

Thread began 8/31/2012 4:38 pm by elevy388997 | Last modified 9/05/2012 11:53 am by elevy388997 | 4327 views | 26 replies

elevy388997Beta Tester

Hello Morgan,

Thanks for the great sample. I am able to figure out a good bit through a source code. I created proper tables in my database (main and sub with correct foreign key), but I cannot seem to get a local working version. I have a proper connection to the database which I created via the SQL you included. I test the site and get a lot of code before the insert main cat section:

sqlWhereClause." ORDER BY ".$WA_joinedKeyField; $WA_mrtJoinRS = mysql_query($WA_Sql, $WA_connection) or die(mysql_error()); if (mysql_num_rows($WA_mrtJoinRS) > 0) { while ($row_WA_mrtJoinRS = mysql_fetch_assoc($WA_mrtJoinRS)) { $WA_formerString .= "^" . $row_WA_mrtJoinRS[$WA_joinedKeyField] . "^"; $WA_formerList[] = $row_WA_mrtJoinRS[$WA_joinedKeyField]; } } for ($n=0; $nsqlWhereClause; $MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error()); } } for ($n=0; $nWA_setValues . " WHERE " . $WhereObj->sqlWhereClause . ""; $MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error()); } } else { $insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1); $WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")"; $MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error()); } } } class WA_AB_InsertParams { var $WA_tableValues; var $WA_dbValues; var $WA_setValues; function WA_AB_InsertParams($WA_tableValues = "", $WA_dbValues = "", $WA_setValues = "") { $this->WA_tableValues = $WA_tableValues; $this->WA_dbValues = $WA_dbValues; $this->WA_setValues = $WA_setValues; } } function WA_AB_generateInsertParams($fieldNameList, $columnTypeList, $fieldValueList, $ignoreIndex) { $obj = new WA_AB_InsertParams(); for ($i=0; $i < sizeof($fieldNameList); $i++) { if ($i !== $ignoreIndex) { $formVal = $fieldValueList[$i]; $WA_typesArray = explode(",", $columnTypeList[$i]); $delim = ($WA_typesArray[0] != "none") ? $WA_typesArray[0] : ""; $altVal = ($WA_typesArray[1] != "none") ? $WA_typesArray[1] : ""; $emptyVal = ($WA_typesArray[2] != "none") ? $WA_typesArray[2] : ""; if ($formVal == "" || $formVal == "undefined") { $formVal = $emptyVal; } else { if ($altVal != "") { $formVal = $altVal; } else if ($delim == "'") { // escape quotes $formVal = "'".((!(preg_match("/(^|[^\\\\])'/", $formVal))) ? $formVal : addslashes($formVal))."'"; } else if ($delim == "") { //numeric if (is_numeric($formVal)) { $formVal = "".floatval($formVal); } else { $formVal = "0"; } } else { $formVal = $delim.WA_AB_clearOutSQLKeywords($formVal).$delim; } } $obj->WA_tableValues .= (($obj->WA_tableValues != "") ? "," : "") . "`" . WA_AB_cleanUpColumnName($fieldNameList[$i]) . "`"; $obj->WA_dbValues .= (($obj->WA_dbValues != "") ? "," : "") . $formVal; $obj->WA_setValues .= (($obj->WA_setValues != "") ? ", " : "") . "`" . WA_AB_cleanUpColumnName($fieldNameList[$i]) ."`" . " = " . $formVal; } } return $obj; } class WA_AB_WhereClause { var $sqlWhereClause; function WA_AB_WhereClause($sqlWhereClause = "") { $this->WA_AB_WhereClause = $sqlWhereClause; } } function WA_AB_generateWhereClause($fieldNameList, $columnTypeList, $fieldValueList, $comparisonList) { $obj = new WA_AB_WhereClause(); for ($i = 0; $i < sizeof($fieldNameList); $i++) { $formVal = $fieldValueList[$i]; $WA_typesArray = explode(",", $columnTypeList[$i]); $delim = ($WA_typesArray[0] != "none") ? $WA_typesArray[0] : ""; $altVal = ($WA_typesArray[1] != "none") ? $WA_typesArray[1] : ""; $emptyVal = ($WA_typesArray[2] != "none") ? $WA_typesArray[2] : ""; if ($formVal == "" || $formVal == "undefined") { $formVal = $emptyVal; } else { if ($altVal != "") { $formVal = $altVal; } else if ($delim == "'") { // escape quotes $formVal = "'".((!(preg_match("/(^|[^\\\\])'/", $formVal))) ? $formVal : addslashes($formVal)); if ($comparisonList[$i] == " LIKE ") $formVal .= "%";; $formVal .= "'"; } else if ($delim == "") { //numeric if (is_numeric($formVal)) { $formVal = "".floatval($formVal); } else { $formVal = "0"; } } else { $formVal = $delim.WA_AB_clearOutSQLKeywords($formVal).$delim; } } if (!($delim == "" && strpos($formVal,"()")>0)) { if ($formVal == "NULL") { $obj->sqlWhereClause .= (($i != 0) ? " AND " : "")."`". WA_AB_cleanUpColumnName($fieldNameList[$i])."`"." IS ".$formVal; } else { $obj->sqlWhereClause .= (($i != 0) ? " AND " : "")."`". WA_AB_cleanUpColumnName($fieldNameList[$i])."`".WA_AB_cleanUpEquality($comparisonList[$i]).$formVal; } } } return $obj; } function WA_AB_cleanUpColumnName($colName) { if (strpos($colName, ";") !== false) { $colName = substr($colName, 0, strpos($colName, ";")); } if (strpos($colName, "(") !== false) { $colName = substr($colName, 0, strpos($colName, "(")); } if (strpos($colName, "=") !== false) { $colName = substr($colName, 0, strpos($colName, "=")); } return $colName; } function WA_AB_cleanUpEquality($tEquality) { if (preg_replace('/^\\s*|\\s*$/', "", $tEquality) != "=") { return WA_AB_cleanUpColumnName($tEquality); } return $tEquality; } function WA_AB_clearOutSQLKeywords($tString) { if (strpos(strtolower($tString), "select") !== false) { return ""; } if (strpos(strtolower($tString), "drop") !== false) { return ""; } if (strpos(strtolower($tString), "alter") !== false) { return ""; } if (strpos(strtolower($tString), "create") !== false) { return ""; } if (strpos(strtolower($tString), "update") !== false) { return ""; } if (strpos(strtolower($tString), "insert") !== false) { return ""; } if (strpos(strtolower($tString), "delete") !== false) { return ""; } if (strpos(strtolower($tString), "'") !== false) { return ""; } if (strpos(strtolower($tString), "#") !== false) { return ""; } return $tString; } ?>



I made a new schema in my localhost called testdb, changed the conneciton file you included, updated the databases panel to make sure I had a proper connection, and i do.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...