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

Ajuda! MYSQL DÁ ERRO - CADASTRO


Guest Henrique Santana

Pergunta

Guest Henrique Santana

:blush: POR FAVOR ME AJUDEM!!!!!!!!!!!!!!!!!1

Olá Amigos,

Estou construindo uma página de cadastro com apenas 3 itens, estou a dois dias tentando resolver o problemas e já estou irritado, dá um erro e não cadastra no banco de dados MySql

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 '' at line 1

SEGUE O CÓDIGO:

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

<?php

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 portal_usuarios (usu_nome, usu_email, usu_senha) VALUES (%s, %s, nd5(%s)",

GetSQLValueString($_POST['usu_nome'], "text"),

GetSQLValueString($_POST['usu_email'], "text"),

GetSQLValueString($_POST['usu_senha'], "text"));

mysql_select_db($database_portaldosaber, $portaldosaber);

$Result1 = mysql_query($insertSQL, $portaldosaber) or die(mysql_error());

$insertGoTo = "sucesso.php";

if (isset($_SERVER['QUERY_STRING'])) {

$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";

$insertGoTo .= $_SERVER['QUERY_STRING'];

}

header(sprintf("Location: %s", $insertGoTo));

}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {

$insertSQL = sprintf("INSERT INTO portal_usuarios (usu_nome, usu_email, usu_senha) VALUES (%s, %s, nd5(%s)",

GetSQLValueString($_POST['usu_nome'], "text"),

GetSQLValueString($_POST['usu_email'], "text"),

GetSQLValueString($_POST['usu_senha'], "text"));

mysql_select_db($database_portaldosaber, $portaldosaber);

$Result1 = mysql_query($insertSQL, $portaldosaber) or die(mysql_error());

$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">

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

Oi, 'Henrique Santana'

Conforme a andrea informou no post anterior, verifique a linha

$insertSQL = sprintf("INSERT INTO portal_usuarios (usu_nome, usu_email, usu_senha) VALUES (%s, %s, nd5(%s)",

Você esqueceu de fechar o parêntese da cláusula VALUES(, assim:

$insertSQL = sprintf("INSERT INTO portal_usuarios (usu_nome, usu_email, usu_senha) VALUES (%s, %s, nd5(%s)),"

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.


  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...