Jump to content


webmastermichael

Member Since 12/09/2008
Offline Last Active 16/09/2009, 16:51
-----

Posts I've Made

In Topic: Meu Código Não Está Efetuando Cadastro?

29/10/2008, 15:58

sem chance ja tentei não estou tendo sucesso so dúvidas ?????????????? :wacko: :wacko: :wacko: :wacko:

[codebox]<?php
mb_http_input("utf-8");
mb_http_output("utf-8");
?>
<?php require_once('Connections/data.php'); ?><?php require_once('Connections/data.php'); ?><?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;

// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}

$MM_restrictGoTo = "index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO add_conta_receber (campo_fim) VALUES (%s)",
GetSQLValueString($_POST['campo_fim'], "text"));
mysql_select_db($database_data, $data);
$Result1 = mysql_query($insertSQL, $data) or die(mysql_error());

$insertGoTo = "visualiza_receber.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$maxRows_DetailRS1 = 10;
$pageNum_DetailRS1 = 0;
if (isset($_GET['pageNum_DetailRS1'])) {
$pageNum_DetailRS1 = $_GET['pageNum_DetailRS1'];
}
$startRow_DetailRS1 = $pageNum_DetailRS1 * $maxRows_DetailRS1;

$colname_DetailRS1 = "-1";
if (isset($_GET['recordID'])) {
$colname_DetailRS1 = $_GET['recordID'];
}
mysql_select_db($database_data, $data);
$query_DetailRS1 = sprintf("SELECT * FROM add_conta_receber WHERE Cod_Equipamento = %s", GetSQLValueString($colname_DetailRS1, "int"));
$query_limit_DetailRS1 = sprintf("%s LIMIT %d, %d", $query_DetailRS1, $startRow_DetailRS1, $maxRows_DetailRS1);
$DetailRS1 = mysql_query($query_limit_DetailRS1, $data) or die(mysql_error());
$row_DetailRS1 = mysql_fetch_assoc($DetailRS1);

if (isset($_GET['totalRows_DetailRS1'])) {
$totalRows_DetailRS1 = $_GET['totalRows_DetailRS1'];
} else {
$all_DetailRS1 = mysql_query($query_DetailRS1);
$totalRows_DetailRS1 = mysql_num_rows($all_DetailRS1);
}
$totalPages_DetailRS1 = ceil($totalRows_DetailRS1/$maxRows_DetailRS1)-1;
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
&lt;script src="SpryAssets/SpryEffects.js" type="text/javascript"></script>
</head>

<body>

&lt;script type=text/javascript>
function copia(nome,campo_fim) {
if(nome.checked)
{
campo_fim.value += nome.value + '\r\n';
}
else
{
campo_fim.value = campo_fim.value.toString().replace(nome.value,"");
campo_fim.value = campo_fim.value.toString().replace("\r\n","");
}
}
</script>

<?php
//Conectando com o banco de dados MysQL e selecionando a base de dados.
$con=mysql_connect('xxxxxxxxxxx','xxxxxxxxxx','xxxxxxxxxxx')or die('Erro na conexção, verifique os dados'.mysql_error($con));
mysql_select_db('ubccriative1',$con)or die('Erro ao selecionar a tabela'.mysql_error($con));
//Varrendo a tabela dados, para pegar todos os dados.
$selecao=mysql_query("SELECT codigo,nome FROM cliente")or die('Erro na consulta SQL'.mysql_error($con));

if (mysql_num_rows($selecao) != 0)
{
echo "<form name=\"nome\" method=\"POST\">";

while($ver = mysql_fetch_array($selecao)){
echo "$ver[1]<input type=\"checkbox\" name=\"excluir[]\" value=\"$ver[1]\" onClick=\"copia(this,campo_fim);\">";
}

echo "<textarea name='campo_fim' rows='3' cols='20'></textarea></form>";


echo "<input type=\"submit\" name=\"ok\" value=\"Adicionar\" /></form>";
//Libramos a memória ocupada pela consulta com o free_result.
mysql_free_result($selecao);
//Fechamos a conexão com a base de dados após as operações.
mysql_close($con);
}
?>
</body>
</html>
<?php
mysql_free_result($DetailRS1);
?>[/codebox]


meu código ta assim agora com POST mas nao esta indo

eu fiz um código novo como eu faço para esse código fazer um insert ??


[codebox]<?php
//Conectando com o banco de dados MysQL e selecionando a base de dados.
$con=mysql_connect('xxxxxxx','uxxxxxxxxx','xxxxxxxxxxxx')or die('Erro na conexção, verifique os dados'.mysql_error($con));
mysql_select_db('ubccriative1',$con)or die('Erro ao selecionar a tabela'.mysql_error($con));

//Verificamos se o método enviado pelo formulário é realmente o POST.
if($_SERVER['REQUEST_METHOD']=='POST'){
//Se sim, pegamos os dados em forma de vetor (array) e passamos para a variável $apagar.
$apagar=$_POST['excluir'];
/*Dou um loop para pegar os arrays e comparar com o valor de $i
Aqui que está o segredo da coisam se a variável $i que inicia em 0 for menor que os dados contidos
no array $apagar, ele vai incrementar até chegar ao valor, repetindo dentro do laço a função para deletar
a quantidade correta de dados selecionados...
*/
for($i=0; $i<count($apagar); $i++){
$sql=mysql_query("INSERT INTO pre_predio WHERE codigo='$apagar[$i]' VALUES ($s)")or die('Erro ao apagar os dados'.mysql_error($con));
}
/* verificamos com um IF simplificado se os dados foram excluídos. */
($sql) ? (print('Dados excluídos com êxito !')) : die('Erro ao excluir os dados.');
}
?>

<?
echo "<meta HTTP-EQUIV='Refresh' CONTENT='0;URL=submenu2.php'>";
?>[/codebox]


por que quando mando ele fazer insert ele da um erro assim WHERE codigo='4'' at line 1


e os meus insert eu usso isso para fazer

[codebox]"INSERT INTO add_conta_receber (Funcionario, Cliente, descricao, pago, pago1, pago2, pago3, pago4, pago5, pago6, pago7, pago8, pago9, pago10, predio, valor_d, valor_e, valor_f, valor_g, valor_h, valor_i, valor_j, valor_telefone, valor_l, valor_m, parcela_n, parcela_o, parcela_p, valor_a, parcela_q, parcela_r, parcela_m, parcela_s, parcela_l, parcela_t, parcela_u, parcela_cnpj, parcela_banco, valor_b, valor_c, insc_estadual, data_contrato, custo_criacao, valor, lancamento, documento, Hora_Entrada) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Funcionario'], "text"),
GetSQLValueString($_POST['Cliente'], "text"),
GetSQLValueString($_POST['descricao'], "text"),
GetSQLValueString($_POST['predio'], "text"),
GetSQLValueString($_POST['pago'], "text"),
GetSQLValueString($_POST['pago1'], "text"),
GetSQLValueString($_POST['pago2'], "text"),
GetSQLValueString($_POST['pago3'], "text"),
GetSQLValueString($_POST['pago4'], "text"),
GetSQLValueString($_POST['pago5'], "text"),
GetSQLValueString($_POST['pago6'], "text"),
GetSQLValueString($_POST['pago7'], "text"),
GetSQLValueString($_POST['pago8'], "text"),
GetSQLValueString($_POST['pago9'], "text"),
GetSQLValueString($_POST['pago10'], "text"),
GetSQLValueString($_POST['valor_d'], "text"),
GetSQLValueString($_POST['valor_a'], "text"),
GetSQLValueString($_POST['valor_e'], "text"),
GetSQLValueString($_POST['valor_f'], "text"),
GetSQLValueString($_POST['valor_g'], "text"),
GetSQLValueString($_POST['valor_h'], "text"),
GetSQLValueString($_POST['valor_i'], "text"),
GetSQLValueString($_POST['valor_j'], "text"),
GetSQLValueString($_POST['valor_telefone'], "text"),
GetSQLValueString($_POST['valor_l'], "text"),
GetSQLValueString($_POST['valor_m'], "text"),
GetSQLValueString($_POST['parcela_n'], "text"),
GetSQLValueString($_POST['parcela_m'], "text"),
GetSQLValueString($_POST['parcela_o'], "text"),
GetSQLValueString($_POST['parcela_p'], "text"),
GetSQLValueString($_POST['parcela_l'], "text"),
GetSQLValueString($_POST['parcela_q'], "text"),
GetSQLValueString($_POST['parcela_r'], "text"),
GetSQLValueString($_POST['parcela_s'], "text"),
GetSQLValueString($_POST['parcela_t'], "text"),
GetSQLValueString($_POST['parcela_u'], "text"),
GetSQLValueString($_POST['parcela_cnpj'], "text"),
GetSQLValueString($_POST['parcela_banco'], "text"),
GetSQLValueString($_POST['valor_b'], "text"),
GetSQLValueString($_POST['valor_c'], "text"),
GetSQLValueString($_POST['insc_estadual'], "text"),
GetSQLValueString($_POST['data_contrato'], "text"),
GetSQLValueString($_POST['custo_criacao'], "text"),
GetSQLValueString($_POST['valor'], "text"),
GetSQLValueString($_POST['lancamento'], "text"),
GetSQLValueString($_POST['documento'], "text"),
GetSQLValueString($_POST['Hora_Entrada'], "text"));[/codebox]

ae mudei meu código agora eu consigo madar paga o banco de dados mas tem um problema o campo está null?????


o meu código novo fico assim

[codebox]<select multiple=multiple id=s1>
<?php
//conexão com o BD
$sql = mysql_query ("Select * From cliente");
while ($x = mysql_fetch_array($sql)){
echo "<option value=\"".$x['codigo']."\">".$x['nome']."</value>\r\n";// o \r\n é só para organizar o HTML em linhas diferentes
}
?>
</select>

<br />
<input type=button value=SWAP onclick=forum(); />
<br />

<select name="s2" multiple=multiple id=s2>
</select>[/codebox]


:angry: :angry: :angry: :angry: :angry:

consegui arrumar mas a um problema quando cadastro no banco ele so ta pegando a primeira linha do list/menu obvio tem como arrumar isso????


[codebox]<select multiple=multiple id=s1>
<?php
//conexão com o BD
$sql = mysql_query ("Select * From cliente");
while ($x = mysql_fetch_array($sql)){
echo "<option value=\"".$x['nome']."\">".$x['nome']."</value>\r\n";// o \r\n é só para organizar o HTML em linhas diferentes
}
?>
</select>
<br />
<input type=button value=Adicionar onclick=forum(); />
<br />
<select name="s2" id="s2">
</select>
&nbsp;
<label>

</label>
[/codebox]

In Topic: Meu Código Não Está Efetuando Cadastro?

27/10/2008, 15:09

A velho foi mau e que programo a pouco tempo no php rsrsrsr onde eu uso o código que vc me passo no meu botão desculpa a ignorância :lol: :lol: :lol: :lol: :lol: vlwww

deixei um link aqui para vc ver como esta !!!


https://ssl790.websi.../system/ver.php

In Topic: Dúvida Sobre Insert

03/10/2008, 17:00

ainda está apagando

In Topic: Dúvida Sobre Insert

03/10/2008, 15:58

Num sei se tem como mas eu quero o seguinte nesse cadastro que eu estou puxando eu puxo o nome dos prédios e vou fazer um insert no contas a receber sim quero fazer um insert nos dados que eu selecionei???? te como???

In Topic: Dúvida Sobre Insert

03/10/2008, 14:20

então velho num sei se você viu mas o código puxa dados do meu mysql e gerra um array que mostra todos os dados o que eu quero fazer e pegar esse dados que eu puxei e fazer um insert em outra tabela do meu bando entendeu???

IPB Skin By Virteq