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

Erro Mysql select db e query


reeges_silva

Pergunta

Bom dia galera estou com um problema e sou iniciante em php e preciso da ajuda estou com o seguinte erro ao inserir os dados : ========================================================================================================= Warning: mysql_select_db() expects parameter 2 to be resource, string given in /home/u522807324/public_html/HomeIpedApae.php on line 56 Warning: mysql_query() expects parameter 2 to be resource, null given in /home/u522807324/public_html/HomeIpedApae.php on line 57 ========================================================================================================= segue abaixo o meu codigo fonte : /////////////////////////////////////////////////////////////////////////////////////////////////////// <?php require_once('Connections/ipedapae.php');?> <?php 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") ? 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 iped (nome, cpf, datanascimento, endereco, complemento, bairro, cep, telefonemovel, telefonerecado, email, cidade, uf, profissao, localtrabalho) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['nome'], "text"), GetSQLValueString($_POST['cpf'], "text"), GetSQLValueString($_POST['datanascimento'], "date"), GetSQLValueString($_POST['endereco'], "text"), GetSQLValueString($_POST['complemento'], "text"), GetSQLValueString($_POST['bairro'], "text"), GetSQLValueString($_POST['cep'], "int"), GetSQLValueString($_POST['telefonemovel'], "text"), GetSQLValueString($_POST['telefonerecado'], "text"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['cidade'], "text"), GetSQLValueString($_POST['uf'], "text"), GetSQLValueString($_POST['profissao'], "text"), GetSQLValueString($_POST['localtrabalho'], "text")); $base= mysql_select_db($database_ipedapae,"ipedapae"); $Result1 = mysql_query($insertSQL, $base) or die(mysql_error()); echo ''; $insertGoTo = "HomeIpedApae.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } ?> ///////////////////////////////////////////////////////////////////////////////////////////////// ta ai meu codigo quem puder me ajudar por favor preciso muito de rodar esse codigo .

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

ola galera vou postar novamente o meu codigo fonte que a primeira ficou meio bagunçado : codigo fonte : <?php require_once('Connections/ipedapae.php');?> <?php 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") ? 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 iped (nome, cpf, datanascimento, endereco, complemento, bairro, cep, telefonemovel, telefonerecado, email, cidade, uf, profissao, localtrabalho) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['nome'], "text"), GetSQLValueString($_POST['cpf'], "text"), GetSQLValueString($_POST['datanascimento'], "date"), GetSQLValueString($_POST['endereco'], "text"), GetSQLValueString($_POST['complemento'], "text"), GetSQLValueString($_POST['bairro'], "text"), GetSQLValueString($_POST['cep'], "int"), GetSQLValueString($_POST['telefonemovel'], "text"), GetSQLValueString($_POST['telefonerecado'], "text"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['cidade'], "text"), GetSQLValueString($_POST['uf'], "text"), GetSQLValueString($_POST['profissao'], "text"), GetSQLValueString($_POST['localtrabalho'], "text")); $base= mysql_select_db($database_ipedapae,"ipedapae"); $Result1 = mysql_query($insertSQL, $base) or die(mysql_error()); echo ''; $insertGoTo = "HomeIpedApae.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } ?>

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...