Hi, i have done away from the function instead i done it like this, but i am now getting another problem, its like this really doesnt want to work!!
This is the whole function
function manage($current)
{
global $db, $config, $HTTP_POST_VARS, $HTTP_GET_VARS;
if ($HTTP_POST_VARS['newcat'])
{
$rank=$db->get_var("SELECT max(rank) FROM ".TBL_CATEGORIES." WHERE parent=$current")+1;
$db->query("SELECT catcase FROM ".TBL_CONFIG." WHERE value='$case'");
if ($case == "0") {
$newcat = $HTTP_POST_VARS['newcat'];
} else if ($case == "1") {
$oldcat = $HTTP_POST_VARS['newcat'];
$newcat = strtoupper($oldcat);
} else if ($case == "2") {
$oldcat = $HTTP_POST_VARS['newcat'];
$newcat = strtolower($oldcat);
}
$db->query("INSERT INTO ".TBL_CATEGORIES." SET name='".mysql_escape_string($newcat)."', parent=$current, rank=$rank");
fixcounters();
recreate();
header("Location: admin.php?m=c&c=$current");
exit;
}
if ($HTTP_POST_VARS['reorder'])
{
asort($HTTP_POST_VARS["rank"]);
$rank=1;
foreach ($HTTP_POST_VARS["rank"] as $id=>$dummy)
{
$db->query("UPDATE ".TBL_CATEGORIES." SET rank='$rank' WHERE id='$id'");
$rank++;
}
fixcounters();
makestatic();
header("Location: admin.php?m=c&c=$current");
exit;
}
elseif ($HTTP_POST_VARS['alphabetize'])
{
$current = 0 + $current;
$cats = $db->get_col("select id from ".TBL_CATEGORIES." where parent = '$current' order by name");
$rank = 1;
if ( count($cats) > 0 ) foreach($cats as $id)
{
$db->query("update ".TBL_CATEGORIES." set rank='$rank' where id='$id'");
$rank++;
}
fixcounters();
recreate();
header("location: admin.php?m=c&c=$current");
exit;
}
elseif ($HTTP_POST_VARS['selected'])
{
if ($HTTP_POST_VARS['rename'] && $HTTP_POST_VARS['edit']) {
$db->query("UPDATE ".TBL_CATEGORIES." SET name='".mysql_escape_string($HTTP_POST_VARS['rename'])."', description='".mysql_escape_string($HTTP_POST_VARS['description'])."', meta_keywords='".mysql_escape_string($HTTP_POST_VARS['meta_keywords'])."', meta_description='".mysql_escape_string($HTTP_POST_VARS['meta_description'])."', meta_usecatdesc='".mysql_escape_string($HTTP_POST_VARS['meta_usecatdesc'])."', meta_useparentinfo='".mysql_escape_string($HTTP_POST_VARS['meta_useparentinfo'])."' WHERE id=".$HTTP_POST_VARS['selected']);
}
elseif ($HTTP_POST_VARS['move'] && $HTTP_POST_VARS['moveto']) movelinks ($HTTP_POST_VARS['selected'],$HTTP_POST_VARS['moveto']);
elseif ($HTTP_POST_VARS['delete']) deletecategory($HTTP_POST_VARS['selected']);
elseif ($HTTP_POST_VARS['parent'] && ($HTTP_POST_VARS['newparent']!=$HTTP_POST_VARS['selected']))
{
if (!isparent($HTTP_POST_VARS['newparent'],$HTTP_POST_VARS['selected']))
{
$db->query("UPDATE ".TBL_CATEGORIES." SET parent=".$HTTP_POST_VARS['newparent']." WHERE id=".$HTTP_POST_VARS['selected']);
updateranks();
}
}
fixcounters();
recreate();
header("Location: admin.php?m=c&c=$current");
exit;
}
subtitle("Manage Categories");
$subcat=$db->get_results("SELECT * FROM ".TBL_CATEGORIES." WHERE parent=$current ORDER BY rank",ARRAY_A);
categoriespage($current,$subcat,$current?"Sub-":"");
}
function addsister($id){
global $db, $config, $HTTP_POST_VARS, $HTTP_GET_VARS;
subtitle($id?"Update Sister Site Information":"Add Sister Site");
if ( $HTTP_POST_VARS['goback'] ){
header("location: admin.php?m=vs");
}
elseif ( $HTTP_POST_VARS['getinfo'] || $HTTP_POST_VARS['addsister'] ){
$recipman_url = $HTTP_POST_VARS['url'];
$uinfo = @parse_url($recipman_url);
if ( !$uinfo['scheme'] ) $recipman_url = "http://".$recipman_url;
$sep ="";
if ( substr($recipman_url, -1) != "/" ) $sep = "/";
$data['method'] = "GET";
$req = new HTTP_Request(gethostbyname($recipman_url.$sep."user.php?returninfo=1"), $data);
$res = $req->sendRequest();
//print "RES: $res <br>".$recipman_url.$sep."user.php?returninfo=1";
if ( !$res || substr($req->getResponseCode(), 1) == "4" || substr($req->getResponseCode(), 1) == "5"){
$errors[] = "There was an error connecting to the Reciprocal Manager URL, check to make sure you have entered the correct URL (to the user.php page of your sister site) and path to your installation of Reciprocal Manager.";
}
if ( !$errors ){
$text = $req->getResponseBody();
$info = explode(chr(30), $text);
if ( count($info) > 0 ) foreach( $info as $line ){
$a = explode(chr(31), $line);
$field[trim($a[0])] = trim($a[1]);
}
if ( $field['return'] != "OK" ){
$errors[] = "Error parsing data returned from Reciprocal Manager";
}
$pv['url'] = $recipman_url;
$pv['reciprocal'] = $field['backlink'];
$pv['title'] = $field['sitetitle'];
$pv['description'] = $field['sitedesc'];
if ( !$errors && $HTTP_POST_VARS['addsister'] ){
if ( $id && duplicateLink($recipman_url, TBL_SISTERSITES, " AND id != '".$id."' ") ) $errors[] = "This URL is already in use";
else if ( !$id && duplicateLink($recipman_url, TBL_SISTERSITES) ) $errors[] = "Cannot add site: Site already included";
if ( !$errors ){
//print "ID: $id";
if ( $id ){
//Update info
$db->query("UPDATE ".TBL_SISTERSITES." SET url='".mysql_escape_string($recipman_url)."' where id='$id'");
}
else{
//Insert info
$db->query("INSERT INTO ".TBL_SISTERSITES." SET url='".mysql_escape_string($recipman_url)."'");
}
header("location: admin.php?m=vs");
exit;
}
}
}
}
elseif ( $id ){
$pv = $db->get_row("SELECT * FROM ".TBL_SISTERSITES." WHERE id='$id'", ARRAY_A);
}
addsister_form($id, $pv['title'], $pv['url'], $pv['description'], $pv['reciprocal'], $errors);
}
The part the needs to work is:
if ($HTTP_POST_VARS['newcat'])
{
$rank=$db->get_var("SELECT max(rank) FROM ".TBL_CATEGORIES." WHERE parent=$current")+1;
$db->query("SELECT catcase FROM ".TBL_CONFIG." WHERE value='$case'");
if ($case == "0") {
$newcat = $HTTP_POST_VARS['newcat'];
} else if ($case == "1") {
$oldcat = $HTTP_POST_VARS['newcat'];
$newcat = strtoupper($oldcat);
} else if ($case == "2") {
$oldcat = $HTTP_POST_VARS['newcat'];
$newcat = strtolower($oldcat);
}
$db->query("INSERT INTO ".TBL_CATEGORIES." SET name='".mysql_escape_string($newcat)."', parent=$current, rank=$rank");
Ok it used to give the new cat name but not correcting the case, but now it doesnt it just comes up as blank.
I have added a image, so you can see the mysql table... make sure i am selecting the correct areas on the database.
Cheers
Aaron