Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

raphaeltsr

ERRO: [function] not callable

Recommended Posts

Olá,

 

estava editando um sistema AJAX/JS/PHP feito por um outro programador para o mesmo serviço que está rodando dentro de um conteudo de um CMS (Drupal versão 4.7). Quando atualizei o CMS para a versão mais recente (5.2), o script subitamente parou de funcionar dando erro na função que me exibe os resultados da consulta [getClientes() is not callable]. Gostaria de saber como poderia resolver essa questão que está me tirando o sono já.

 

Função getClientes() no PHP

function getCliente($id){	global $bd;		$sql = "SELECT 				  `cliente`.id_cliente,				  `cliente`.nome_cliente,				  `cliente`.contato_cliente,				`cliente`.tel_cliente,				`cliente`.fax_cliente,				`cliente`.obs_cliente			FROM				  `cliente`			WHERE				`cliente`.id_cliente =".$id;		$rs = $bd->query($sql);	while($row = $rs->fetchRow()){		$txt = array($row[0],utf8_encode($row[1]),utf8_encode($row[2]),utf8_encode($row[3]),utf8_encode($row[4]),utf8_encode($row[5]));	}	return $txt;}

 

Chamando função no AJAX

sajax_export("getCliente","getClientes","insertCode","updateCode","deleteCode"); // lista de funcoes a ser exportadas

Todo o código

<?phpinclude('includes/apl/inc/Sajax.php');include('includes/apl/inc/connect.inc');function getCliente($id){	global $bd;		$sql = "SELECT 				  `cliente`.id_cliente,				  `cliente`.nome_cliente,				  `cliente`.contato_cliente,				`cliente`.tel_cliente,				`cliente`.fax_cliente,				`cliente`.obs_cliente			FROM				  `cliente`			WHERE				`cliente`.id_cliente =".$id;		$rs = $bd->query($sql);	while($row = $rs->fetchRow()){		$txt = array($row[0],utf8_encode($row[1]),utf8_encode($row[2]),utf8_encode($row[3]),utf8_encode($row[4]),utf8_encode($row[5]));	}	return $txt;}function getClientes(){	global $bd;		$sql = "SELECT 				  `cliente`.id_cliente,				  `cliente`.nome_cliente,				  `cliente`.tel_cliente,				  'Editar'			FROM				  `cliente`";		$rs = $bd->query($sql);	$txt[] = array($rs->numRows(),$rs->numCols(),'');	$txt[] = array('','250','220','100');	$txt[] = array('','Nome','Setor','Tipo');	while($row = $rs->fetchRow()){		$txt[] = array($row[0],utf8_encode($row[1]),utf8_encode($row[2]),'Apagar/Editar');	}	return $txt;}function insertCode($nome,$contato,$tel,$fax,$obs){	global $bd;	$table_name = 'cliente';	$fields_values = array(						'nome_cliente' => utf8_encode($nome),						'contato_cliente'  => utf8_encode($contato),						'tel_cliente'  => $tel,						'fax_cliente'  => $fax,						'obs_cliente'  => $obs					);		$types = array('text','text','text','text');	$affectedRows = $bd->extended->autoExecute($table_name, $fields_values,						MDB2_AUTOQUERY_INSERT, null, $types);	if (PEAR::isError($affectedRows)) {		return $affectedRows->getMessage();	}	else return 1;}function updateCode($nome,$contato,$tel,$fax,$obs,$id){	global $bd;	$table_name = 'cliente';	$fields_values = array(						'nome_cliente' => utf8_encode($nome),						'contato_cliente'  => utf8_encode($contato),						'tel_cliente'  => $tel,						'fax_cliente'  => $fax,						'obs_cliente'  => $obs					);		$types = array('text','text','text','text');	$affectedRows = $bd->extended->autoExecute($table_name, $fields_values,						MDB2_AUTOQUERY_UPDATE, 'id_cliente ='.$bd->quote($id, 'integer'),$types);	if (PEAR::isError($affectedRows)) {		return $affectedRows->getMessage();	}	else return 1;}function deleteCode($id){	global $bd;	$table_name = 'cliente';		$affectedRows = $bd->extended->autoExecute($table_name, null,						MDB2_AUTOQUERY_DELETE, 'id_cliente ='.$bd->quote($id, 'integer'),$types);		if (PEAR::isError($affectedRows)) {		return $affectedRows->getMessage();	}	else return 1;}$sajax_request_type = "GET"; //forma como os dados serao enviadossajax_init(); //inicia o SAJAX#$sajax_debug_mode = 1;sajax_export("getCliente","getClientes","insertCode","updateCode","deleteCode"); // lista de funcoes a ser exportadassajax_handle_client_request();// serve instancias de clientes?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><script type="text/javascript"><? sajax_show_javascript(); ?></script><script type="text/javascript">combo1 = '';combo2 = '';combo3 = '';combo4 = '';function checkMail(obj){	var x = obj.value;	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;	if (!filter.test(x)){		alert('Endereço de e-mail incorreto !!!');		obj.value = '';	}}function checkData(obj){	var x = obj.value;	var filter  = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;	if (!filter.test(x)){		alert('Data inválida - Utilize o formato DD/MM/YYYY !!!');		obj.value = '';	}}function makeData(tmp){	var final = new Array();	alert(tmp.lenght);	//if(tmp.lenght == 0) return '';	final = tmp.split('-');	if(final.length == 3) return (final[2]+"/"+final[1]+"/"+final[0]);	else{		final = tmp.split('/');		return (final[2]+"-"+final[1]+"-"+final[0]);	}}function updCliente(){	x_updateCode(getValor('nome_cliente'),getValor('contato_cliente'),getValor('tel_cliente'),getValor('fax_cliente'),getValor('obs_cliente'),getValor('id_cliente'),showUpdate);}function insCliente(){	x_insertCode(getValor('nome_cliente'),getValor('contato_cliente'),getValor('tel_cliente'),getValor('fax_cliente'),getValor('obs_cliente'),showInsert);}function delCliente(id){	x_deleteCode(id,showDelete);}function showDelete(resp){	if(resp == 1){		alert('Excluido com sucesso !!!');		startCad();		Load();	}	else alert(resp);}function editCliente(id){	bt = '<center><input type="button" value="atualizar" id="botao_form" name="botao_form" onclick="java script:updCliente()"/></center>';	innerHTML('botao',bt);	x_getCliente(id,showCad);}function showCad(resp){	setValor('id_cliente',resp[0]);	setValor('nome_cliente',resp[1]);	setValor('contato_cliente',resp[2]);	setValor('tel_cliente',resp[3]);	setValor('fax_cliente',resp[4]);	setValor('obs_cliente',resp[5]);}function startCad(){	setValor('nome_cliente','');	setValor('contato_cliente','');	setValor('tel_cliente','');	setValor('fax_cliente','');	setValor('obs_cliente','');}function showInsert(resp){	if(resp == 1){		alert('Incluido com sucesso !!!');		startCad();		Load();	}	else alert(resp);}function showUpdate(resp){	if(resp == 1){		alert('Alterado com sucesso !!!');		startCad();		Load();	}	else alert(resp);}function setStyle(obj,classe){	if( window.getComputedStyle ) atrib = 'class';	else atrib = 'className';	mycurrent_cell.setAttribute(atrib,classe);}function makeTab(resp) {				// get the reference for the body		//var mybody = document.getElementsByTagName("body")[0];		// creates a <table> element and a <tbody> element		mytable = getObj("listaContato");		//mytable.removeChild(mytable.lastChild);		if(mytable.childNodes[0] != null) mytable.removeChild(mytable.childNodes[0]);		mytablebody = document.createElement("tbody");		// creating all cells		//alert (resp[0][1]);		//total = resp[0][0] + 1;		//alert(total);				//for(p=1;p<resp[0][1];p++) alert('Titulo '+p+' : '+resp[1][p]);						if(resp[0][0] == 0){			mycurrent_row = document.createElement("tr");			mycurrent_cell = document.createElement("td");			mycurrent_cell.setAttribute("width","550");			mycurrent_cell.setAttribute("align","center");			currenttext = document.createTextNode("Não foram encontrados registros com os dados informados !");			mycurrent_cell.appendChild(currenttext);			mycurrent_row.appendChild(mycurrent_cell);			mytablebody.appendChild(mycurrent_row);			mytable.appendChild(mytablebody);					}				else{			for(var j = 1; j < (resp[0][0])+2; j++) {			// creates a <tr> element			mycurrent_row = document.createElement("tr");			for(var i = 1; i < resp[0][1]; i++) {				// creates a <td> element				mycurrent_cell = document.createElement("td");								if(i==3 && j!=1){				mycurrent_cell.setAttribute("width",resp[1][i]);				//Varia as cores das opções dos dados tabulados				if((j % 2) != 0)				{					mycurrent_cell.setAttribute("bgcolor", "#AEB8DA");				}				// creates a link node				acao1 = document.createElement("a");				acao1.setAttribute("href","java script:editCliente("+resp[j+1][0]+")");				// creates a text node				currenttext1 = document.createTextNode('Editar ');				// appends the text node we created into the cell <td>				acao1.appendChild(currenttext1);				//acao2.appendChild(currenttext);								mycurrent_cell.appendChild(acao1);				//mycurrent_cell.appendChild(acao2);								acao2 = document.createElement("a");				acao2.setAttribute("href","java script:delCliente("+resp[j+1][0]+")");				// creates a text node				currenttext2 = document.createTextNode('Excluir');				// appends the text node we created into the cell <td>				acao2.appendChild(currenttext2);				//acao2.appendChild(currenttext);								mycurrent_cell.appendChild(acao2);				//mycurrent_cell.appendChild(acao2);				}				else {					mycurrent_cell.setAttribute("width",resp[1][i]);					//Varia as cores dos dados tabulados					if((j % 2) != 0)					{						mycurrent_cell.setAttribute("bgcolor", "#AEB8DA");						}										// creates a text node					currenttext = document.createTextNode(resp[j+1][i]);					// appends the text node we created into the cell <td>					mycurrent_cell.appendChild(currenttext);				}								switch(i){				case 1:{					/*					mycurrent_cell.setAttribute("width",resp[1][i]);					// creates a link node					acao = document.createElement("a");					acao.setAttribute("href","java script:getProp("+resp[j+1][i-1]+")");					// creates a text node					currenttext = document.createTextNode(resp[j+1][i]);					// appends the text node we created into the cell <td>					acao.appendChild(currenttext);					mycurrent_cell.appendChild(acao);*/					setStyle(mycurrent_cell,'tabTextoL');										}break;				default:{					/*					mycurrent_cell.setAttribute("width",resp[1][i]);					// creates a text node					currenttext = document.createTextNode(resp[j+1][i]);					// appends the text node we created into the cell <td>					mycurrent_cell.appendChild(currenttext);*/					setStyle(mycurrent_cell,'tabTextoC');				}break;						}				/*				if(i==1) {					mycurrent_cell.setAttribute("width",resp[j][i]);					// creates a link node					acao = document.createElement("a");					acao.setAttribute("href","java script:getProp("+resp[j+1][i-1]+")");					// creates a text node					currenttext = document.createTextNode(resp[j+1][i]);					// appends the text node we created into the cell <td>					acao.appendChild(currenttext);					mycurrent_cell.appendChild(acao);										}				else{					mycurrent_cell.setAttribute("width","125");					// creates a text node					currenttext = document.createTextNode(resp[j+1][i]);					// appends the text node we created into the cell <td>					mycurrent_cell.appendChild(currenttext);				}*/									// appends the cell <td> into the row <tr>				if(j==1) setStyle(mycurrent_cell,'tabTitulo');								mycurrent_row.appendChild(mycurrent_cell);			}			// appends the row <tr> into <tbody>			mytablebody.appendChild(mycurrent_row);		}		// appends <tbody> into <table>		mytable.appendChild(mytablebody);		// appends <table> into <body>		//mybody.appendChild(mytable);		// sets the border attribute of mytable to 2;		//mytable.setAttribute("border", "1");		}}function setValor(obj,valor){	objeto = document.getElementById(obj);	if(objeto == null) alert('O campo '+obj+' não existe !!!');	else document.getElementById(obj).value = valor;}function getValor(obj){	//objeto = document.getElementById(obj);	//if(objeto == null) return ('O campo '+obj+' não existe !!!');	if(document.getElementById(obj) == null) return ('O campo '+obj+' não existe !!!');	else return document.getElementById(obj).value;}function getObj(obj){	objeto = document.getElementById(obj);	if(objeto == null) alert('O campo '+obj+' não existe !!!');	else return document.getElementById(obj);}function addEvent(obj, evType, fn){	if (obj.addEventListener)	{	   obj.addEventListener(evType, fn, false);	   return true;	}	else if (obj.attachEvent)	{	   var r = obj.attachEvent("on"+evType, fn);	   return r;	} 	else	{	   return false;	}}function makeCombo(combo,valor){	this.combo = combo;	this.valor = valor;	this.showCombo = showCombo;}function showCombo(resp){	this.resp = resp;	i= 0;	opt = document.getElementById(this.combo);	lgth = document.getElementById(this.combo).options.length = 0;	document.getElementById(this.combo).options[i] = null;		while(resp[i] != null){		opt.options[i] = new Option(this.resp[i][1],this.resp[i][0]);		if(this.valor == this.resp[i][0]) tmp = i;		i++;	}	if(tmp!=0)opt.options[tmp].selected = true;}function innerHTML(obj,valor){	objeto = document.getElementById(obj);	if(objeto == null) alert('O campo '+obj+' não existe !!!');	else document.getElementById(obj).innerHTML = valor;}function Load(){	bt = '<center><input type="button" value="cadastrar" id="botao_form" name="botao_form" onclick="java script:insCliente()"/></center>';	innerHTML('botao',bt);	x_getClientes(makeTab);}addEvent(window,'load', Load);</script><style>fieldset{	float:left;	font-family:Verdana, Arial, Helvetica, sans-serif;	font-size:11px;}#form {	height: 70%;	padding: 5px;}.tabTitulo {	font-family: Verdana, Arial, Helvetica, sans-serif;	font-size: 10px;	font-weight:bold;	background-color: #CCCCCC;	text-align: center;}.tabTituloL {	font-family: Verdana, Arial, Helvetica, sans-serif;	font-size: 10px;	font-weight:bold;	background-color: #CCCCCC;	text-align: left;}.tabTextoC {	font-family: Verdana, Arial, Helvetica, sans-serif;	font-size: 10px;	text-align: center;}.tabTextoL {	font-family: Verdana, Arial, Helvetica, sans-serif;	font-size: 10px;	text-align: left;}#cad{	position:absolute;	width:528px;}#resp{	position:relative;	width:530px;	top: 200px;;}#nome_cliente{	width:300px;}#cnpj_cliente{	width:150px;}input{	font-family:Verdana, Arial, Helvetica, sans-serif;	font-size:11px;}select{	font-family:Verdana, Arial, Helvetica, sans-serif;	font-size:11px;}.borda{	text-align: center;}#tel_cliente {	width:150px;}#contato_cliente {	width:300px;}#obs_cliente {	width:450px;}</style></head><body><div id='cad'>  <table width="330" border="0" id="cad_contato">	<tr>	  <td class="tabTitulo">Nome</td>	  <td width="144" colspan="2" class="tabTitulo">Tel</td>	</tr>	<tr>	  <td class="borda"><input name="nome_cliente" type="text" id="nome_cliente" /></td>	  <td colspan="2" class="borda"><input name="tel_cliente" type="text" id="tel_cliente" /></td>	</tr>	<tr>	  <td class="tabTitulo">Contato</td>	  <td colspan="2" class="tabTitulo">Fax</td>	</tr>	<tr>	  <td class="borda"><input name="contato_cliente" type="text" id="contato_cliente" /></td>	  <td colspan="2" class="borda"><input name="fax_cliente" type="text" id="fax_cliente" /></td>	</tr>	<tr>	  <td colspan="3" class="tabTitulo">OBS</td>	</tr>	<tr>	  <td colspan="3" class="borda"><textarea name="obs_cliente" id="obs_cliente"></textarea></td>	</tr>		<tr>	  <td height="50" colspan="3"><div id="botao"></div></td>	</tr>  </table>  <input name="id_cliente" id="id_cliente" type="hidden" value="" /> </div><div id='resp'><table id="listaContato" cellpadding="3" cellspacing="3"></table></div></body></html>

PS: conhecimento de AJAX = 0 !

Compartilhar este post


Link para o post
Compartilhar em outros sites

getClientes() is not callable

tradução

getClientes() não está acessivel

esse erro é no PHP ao que aparenta

tente rodar apenas a parte PHP e e veja qual linha esta errada

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.