Jump to content

Array


unidox

Recommended Posts

I have a problem, all of the input fields say Array, when I want them to be saying whats in the db. Here is my code:

 

admin_settings.php:

 

<?php
$page = "settings";
$mysql_table = "cp_settings";
require_once("inc/db.inc.php");
require_once ("inc/func2.inc.php");
require_once ("req/settings.inc.php");
	$checkfields = "clan_info&website_title&owner&owner_email&clan_name&clan_tag&bdrcolour&colourone&colourtwo";
	$errors = "Enter your clan information&Enter your website title&Enter the owners name&Enter the owners email&Enter a clan name&Enter a clan tag!&Enter a border colour!&Enter a 1st colour& Enter a 2nd colour!";
	$titles = "Clan Information:&Website Title:&Owner Name:&Owner Email:&Clan Name:&Clan Tag:&Border Colour:&Colour One:&Colour Two";
	$fields = "clan_info&website_title&owner&owner_email&clan_name&clan_tag&bdrcolour&colourone&colourtwo";
	$type = "textarea&text&text&text&text&text&text&text&text";
	$size = "null&40&40&40&40&10&10&10&10";
	$maxlength = "null&100&100&100&100&15&7&7&7";
	$id_type = "setting_id";
if ($_REQUEST['m'] == "1") {
	$clan_info = remslash($_POST['clan_info']);
	$website_title = remslash($_POST['website_title']);
	$owner = remslash($_POST['owner']);
	$owner_email = remslash($_POST['owner_email']);
	$clan_name = remslash($_POST['clan_name']);
	$clan_tag = remslash($_POST['clan_tag']);
	$bdrcolour = remslash($_POST['bdrcolour']);
	$colourone = remslash($_POST['colourone']);
	$colourtwo = remslash($_POST['colourtwo']);
	MYSQL_QUERY("UPDATE $mysql_table SET clan_info='$clan_info', website_title='$website_title', owner='$owner', owner_email='$owner_email', clan_name='$clan_name', clan_tag='$clan_tag', bdrcolour='$bdrcolour', colourone='$colourone', colourtwo='$colourtwo'") or die (mysql_error());
	showSuccess('Settings Update',$_SERVER['PHP_SELF']);	
} if (!$_REQUEST['m']) {
	getHeader();
	$result = MYSQL_QUERY("SELECT * FROM $mysql_table WHERE $id_type='0'") or die (mysql_error());
	while ($mysql=mysql_fetch_array($result)) {
		$mysql_values = getContent($mysql[clan_info],'1') . "&" . getContent($mysql[website_title],'1') . "&" . getContent($mysql[owner],'1') . "&" . getContent($mysql[owner_email],'1') . "&" . getContent($mysql[clan_name],'1') . "&" . getContent($mysql[clan_tag],'1') . "&" . getContent($mysql[bdrcolour]) . "&" . getContent($mysql[colourone]) . "&" . getContent($mysql[colourtwo]) . "&" . getContent($mysql[template]);
		createJSValid($checkfields,$errors);
		createForm($titles,$fields,$type,$size,$maxlength,'1',$id_type,$id,$mysql_values,'1');
	}
}
?>

 

Settings.inc.php:

 

<?php
function showAsk($typo,$id = '',$m = '6') {
	global $bdrcolour;
	echo "
		<form action=\"" . $_SERVER['PHP_SELF'] . "?page=admin_links&m=" . $m . "";
	if ($id != '') {
	echo "&id=" . $id . "";
	} 
	echo "\" method=\"post\">
		" . startTable() . "
			<tr align=\"center\">
				<td " . setMouse('0') . ">" . $typo . "<br><br></td>
			</tr>
		</table>
		" . showDiv() . "
		<input type=\"button\" value=\"No\" onclick=\"history.back();\"></input> 
		<input type=\"button\" value=\"Yes\" onclick=\"this.form.submit();\"></input>
		</form>";
}




function createForm($titles,$fields,$type,$size,$maxlength,$m,$idtype = '',$id = '',$mysql_values ='',$backoff = '') {
	global $selecta;
	$title = explode("&",$titles);
	$field = explode("&",$fields);
	$fieldtype = explode("&",$type);
	$fieldsize = explode("&",$size);
	$fieldmax = explode("&",$maxlength);
	if ($mysql_values != '') {
		$mysql = explode("&",$mysql_values);
	} if (count($title) != count($field)) {
		showError('Your $title/$fields do not match');
	} elseif (count($title) != count($fieldtype)) {
		showError('Your $title/$type do not match');
	} elseif (count($title) != count($fieldsize)) {
		showError('Your $title/$size do not match');
	} elseif (count($title) != count($fieldmax)) {
		showError('Your $title/$maxlength do not match');
	} elseif (count($field) != count($fieldtype)) {
		showError('Your $fields/$type do not match');
	} elseif (count($field) != count($fieldsize)) {
		showError('Your $fields/$size do not match');
	} elseif (count($field) != count($fieldmax)) {
		showError('Your $fields/$maxlength do not match');
	} elseif (count($fieldtype) != count($fieldsize)) {
		showError('Your $type/$size do not match');
	} elseif (count($fieldtype) != count($fieldmax)) {
		showError('Your $type/$maxlength do not match');
	} elseif (count($fieldsize) != count($fieldmax)) {
		showError('Your $size/$maxlength do not match');
	} else {
		echo "
		<form action=\"" . $_SERVER['PHP_SELF'] . "?page=admin_links&m=" . $m;
		if ($id != '') {
			echo "&id=" . $id;
		}
		echo "\" method=\"post\"";
		if ($m == '8' || $m == '12') {
			echo " enctype=\"multipart/form-data\"";
		}
		echo ">
		" . startTable();
		$total = count($field);
		for ($i = 0; $i < $total; $i++) {
			if ($fieldtype[$i] == "date") {
				echo "
		<input type=\"hidden\" name=\"" . $field[$i] . "\" value=\"";
				if ($m == "2") {
					echo date("m/d/Y");
				} else {
					echo $mysql[$i];
				}
				echo "\"></input>";
			} else {
				echo "
			<tr valign=\"top\">
				<td " . setMouse("title" . $i) . ">" . $title[$i] . "</td>
				<td " . setMouse("input" . $i) . ">";
				if ($fieldtype[$i] == "select") {
					echo "<select name=\"" . $field[$i] . "\">";
					$options = explode("&",$selecta);
					for ($o = 0; $o < count($options); $o++) {
					echo "<option value=\"" . $options[$o] . "\"";
						if ($mysql_values != '') {
							if ($mysql[$i] == $options[$o]) {
								echo " selected";
							}
						}
					echo ">" . $options[$o] . "</option>";
					}
				echo "</select>";
				} elseif ($fieldtype[$i] == "textarea") {
					echo "<textarea cols=\"60\" rows=\"10\" name=\"" . $field[$i] . "\">";
					if ($mysql_values != '') {
						echo $mysql[$i];
					}
					echo "</textarea>";
				} else {
					echo "<input type=\"" . $fieldtype[$i] . "\" name=\"" . $field[$i] . "\"";
						echo " value=\"" . $mysql[$i] . "\"";
					if ($mysql_values != '') {

					} if ($fieldsize[$i] != 'false') {
						echo " size=\"" . $fieldsize[$i] . "\"";
					} if ($maxfield[$i] != 'false') {
						echo " maxlength=\"" . $fieldmax[$i] . "\"";
					} 
					echo "></input>";
				}
				echo "</td>
			</tr>";
			}
		}
		echo "
		</table>". showDiv();
		if ($backoff == '') {
			echo "<input type=\"button\" value=\"Back\" onclick=\"history.back();\"></input> ";
		}
		echo "
		<input type=\"button\" value=\"Go!\" onclick=\"isformValid(this.form);\"></input> 
		<input type=\"reset\" value=\"Refresh\"></input></div>
		</form>";
	}
}
?>

 

func2.inc.php:

 

<?php
require_once 'config.inc.php';
$oncolour = "#BCD5FE";
$offcolour = "#FFFFFF";
$bdrcolour = "#F0F0F0";

$islogged = preg_match("/index.php?page=login/", $_SERVER['PHP_SELF']);
if ($islogged == "0") {
	if ($_COOKIE['uniqueid'] == "") {
		header ("Location: index.php?page=login");
		exit;
	}
}

if ((!$_REQUEST['method']) || (!$_COOKIE['uniqueid'])) {
	$access = $_COOKIE['access'];
	if (array_search($page,$levels)) {
		if ($access > $levels[$page]) {
			echo $access . $levels[$page];
			//showError('You do not have access to this page.');
			exit;
		}
	}
}

function getContent($content,$sql = '') {
	global $special_character;
	if ($sql == '') {
		$content = eregi_replace( "([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])","<a href=\"\\1://\\2\\3\" target=\"_blank\" target=\"_new\"><b>\\1://\\2\\3</b></a>", $content);
		$content = eregi_replace("([_a-z0-9\-\.]+)@([a-z0-9\-\.]+)\."."(net|com|gov|mil|org|edu|int|biz|info|name|pro|[A-Z]{2})"."($|[^a-z]{1})", "<a href=\"mailto:\\1@\\2.\\3\"><b>\\1@\\2.\\3</b></a>\\4", $content);
		$content = nl2br($content);
	}
	$content = str_replace($special_character,"'",$content);

	return $content;
}

function remslash($content) {
	global $special_character;
	$output = str_replace("\'",$special_character,$content);
	return $output;
}

function setMouse($id = '') {
	global $oncolour, $offcolour;
	$output = "class=\"bdr\" bgcolor=\"" .$offcolour . "\" id=\"area" . $id . "\" onmouseover=\"bgOn(this,'" . $oncolour . "');\" onmouseout=\"bgOff(this,'" . $offcolour . "');\"";
	return $output;
}

function showDiv() {
	$output = "<div width=\"100%\" style=\"padding-top: 3px\" align=\"right\">";
	return $output;
}

function startTable() {
	global $bdrcolour;
	$output = "<table cellspacing=\"1\" cellpadding=\"7\" width=\"100%\" bgcolor=\"" . $bdrcolour . "\">";
	return $output;
}

function createTr($content,$id = '',$class = '') {
	echo "<tr>
		<td " . setMouse($id) . ">";
	if ($class != '') {
		echo "<span class=\"" . $class . "\">";
	}
	echo $content;
	if ($class != '') {
		echo "</span>";
	}
		echo "</td>
	</tr>";
}

function showError($error) {
	echo"
		<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
		<html><head>
		<META http-equiv=Content-Type content=\"text/html; charset=windows-1252\">
		<title>Error</title>
		<link rel=\"stylesheet\" href=\"req/global.css\" type=\"text/css\"></head>
		<body bgcolor=\"#FFFFFF\">
		<div align=\"center\"><b>An Error has occured: <span class=\"error\">" . $error . "</span></b></div>
		</body></html>
	";		
}

function showSuccess($success,$page,$refresh = '1') {
	echo "
		<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
		<html><head>
		<META http-equiv=Content-Type content=\"text/html; charset=windows-1252\">
		<meta http-equiv=\"Refresh\" content=\"" . $refresh . "; url='" . $page . "'\">
		<title>Congratulations</title>
		<link rel=\"stylesheet\" href=\"req/global.css\" type=\"text/css\"></head>
		<body bgcolor=\"#EEEEEE\">
		<div class=\"success\" align=\"center\">Congratulations: " . $success . " successfull<br>Redirecting to " . $page . ".<br>If this does not work <a href=\"" . $page . "\">click here</a>.</div>
		</body></html>";
}

function getHeader() {
	global $page, $imagefullpath, $imagefilepath;
	if (file_exists("req/header.inc.php")) {
		include("req/header.inc.php");
	} else {
		showError("Unable to Require file : \"req/header.inc.php\"");
	}
}

function getFooter() {
	if (file_exists("req/footer.inc.php")) {
		include("req/footer.inc.php");
	} else {
		showError("Unable to Require file : \"req/footer.php\"");
	}
}

function createJSValid($required,$errors) {
	$field = explode("&",$required);
	$alert = explode("&",$errors);;
	if (count($alert) != count($field)) {
		showError('Required Fields/Error Msgs do not match');
	} else {
		echo "<script language=\"javascript\">
			<!--
				function isformValid(form) {";
		$i = 0;
			while ($i < count($field)) {
			$thisfield = $field[$i];
			$thiserror = $alert[$i];
			echo "
					if (!form." . $thisfield . ".value) {
						alert(\"" . $thiserror . "\");
						form." . $thisfield . ".focus();
						return false;
					}";
			$i++;
		}
		echo "
					else {
					form.submit();
					}
				}
			//-->
		</script>";
	}
}
?>

 

What is wrong?

Link to comment
https://forums.phpfreaks.com/topic/66656-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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