Ir para conteúdo
Fórum Script Brasil
  • 0

PHP Dreamweaver


lfelipecoutinho

Pergunta

Caros,
Sou novo no forum e também não sou um desenvolvedor. Estou, com a ajuda do Dreamweaver, tentando criar um protótipo de sistema web based para então repassar a demanda ao TI. Sei dos problemas encontrados com o MY de mysql com mysqli, mas para alguém sem experiência o suporte do DW é importante, e como quero criar algo simples que sirva de exemplo acho que passar por estes inconvenientes na marra e com a ajuda de vocês será a forma mais rápida. Segue abaixo o erro e o coódigo. Antecipadamente grato,


Erro:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'clientes (cli_Nome, cli_CNPJ, cli_Telefone, cli_endereço, cli_responsavel, cli_' at line 1

Code:

<?php require_once('Connections/conexao.php'); ?>
<?php

$hostname_conexao = "localhost";
$database_conexao = "urbanforo";
$username_conexao = "root";
$password_conexao = "paizao10";
$conexao = mysqli_connect($hostname_conexao, $username_conexao, $password_conexao,$database_conexao);

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

$theValue = function_exists("mysql_real_escape_string") ? mysqli_real_escape_string(dbconnect(),$theValue) : mysqli_escape_string(dbconnect(),$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 cadastro clientes (cli_Nome, cli_CNPJ, cli_Telefone, cli_endereço, cli_responsavel, cli_e-mail, cli_senha) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['cli_Nome'], "text"),
GetSQLValueString($_POST['cli_CNPJ'], "int"),
GetSQLValueString($_POST['cli_Telefone'], "int"),
GetSQLValueString($_POST['cli_endereo'], "text"),
GetSQLValueString($_POST['cli_responsavel'], "text"),
GetSQLValueString($_POST['cli_email'], "text"),
GetSQLValueString($_POST['cli_senha'], "text"));

mysqli_select_db($conexao,$database_conexao);
$Result1 = mysqli_query($conexao,$insertSQL) or die(mysqli_error($conexao));

$insertGoTo = "sucesso.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Cadastro Clientes</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Nome:</td>
<td><input type="text" name="cli_Nome" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">CNPJ:</td>
<td><input type="text" name="cli_CNPJ" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Telefone:</td>
<td><input type="text" name="cli_Telefone" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Endereço:</td>
<td><input type="text" name="cli_endereo" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Responsavel:</td>
<td><input type="text" name="cli_responsavel" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">E-mail:</td>
<td><input type="text" name="cli_email" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Senha:</td>
<td><input type="text" name="cli_senha" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
</body>
</html>

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

Pelo erro que dá, sugiro que não uses caracteres especiais, isto é, substitui 'endereço' por 'endereco' e 'e-mail' por 'email'. 

Ou, em alternativa, utiliza delimitadores `` nos nomes dos campos, assim:

INSERT INTO cadastro clientes (`cli_Nome`, `cli_CNPJ`, `cli_Telefone`, `cli_endereço`, `cli_responsavel`, `cli_e-mail`, `cli_senha`) VALUES (...)

 

Editado por wootzor
Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...