I'm having a problem here. I've moved into a project where the previous developer had established 3 files: a HTML, a PHP and two JSs.
-- The HTML defines the layout of the page, with the fields and such.
-- The PHP defines what is going to happen, which function is gonna be activated, etc.
-- The JSs defines some toolbar and the MySQL queries, which are automatically built.
But there's a problem. Sometimes the combobox values work, sometimes they doesn't. And to be even worse, it's not that random. It works for all odd numbers, and doesn't for all even numbers. Here's the important bits of the code:
JS1, MySQL query Part:
Code: Select all
function insertSQL(btnobj)
{
// Cria a URL e a ação a ser executada dentro do script
var sURL = document.URL.replace("_html", "_php");
sURL = sURL.replace(".html",".php");
sURL = Left(sURL, document.URL.indexOf("?"));
sURL = sURL + "?acao=" + btnobj.title;
var sCOLUNAS = '';
// Configura as colunas que ser?o enviadas ao PHP para compor a SQL (INSERT OU UPDATE)
//alert(document.forms[0].elements[i].value);
for (i = 0; i < document.forms[0].elements.length; i++)
{
var verifica = document.forms[0].elements[i].name;
if (verifica.indexOf('table') == 0)
{
sCOLUNAS += "&" + document.forms[0].elements[i].id + "=" + verifica.substring(6,7) + "," + document.forms[0].elements[i].value;
}
}
makePOSTRequest(sURL ,sCOLUNAS);
//window.open(sURL + sCOLUNAS,"corpo");
}Code: Select all
switch (strtolower($_REQUEST["acao"]))
{
case "novo":
if (!validacao()) break;
$comando = "INSERT INTO contas SET ";
$oConexao->sql = colunasSQL($comando);
$oConexao->executaQuery();
$oConexao->sql = "SELECT LAST_INSERT_ID() AS id;";
$rs_colunas = $oConexao->executaQuery();
if (MYSQL_NUM_ROWS($rs_colunas)>0)
{
$linha = MYSQL_FETCH_ARRAY($rs_colunas, MYSQL_ASSOC);
// Refresh na página para atualizar o código da entidade
$pagina = $_SERVER['PHP_SELF'] . "?acao=procurar&where=cta_id=" . $linha["id"] . "&mensagem=<h3> Registro gravado com sucesso. ID: <strong>" . $linha["id"] . "</strong></h3><br>";
echo "<META http-equiv='refresh' content='0;URL=" . $pagina . "'>";
exit;
}
else
{
echo "Ocorreu um erro na inclusão do registro!";
}
break;Thanks for any help that you guys may give