0

Erro Mysql_select_db()

criado por reeges em 29/07/2015 12:42pm
Boa tarde pessoal, sou iniciante em programação php e estou com esse erro se alguém por favor puder me ajudar preciso muito.
erro :

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 meu código 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 '<script language="javascript">alert("Cadastro inserido com Sucesso!");</script>';
$insertGoTo = "HomeIpedApae.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
==================================================================
abaixo vou colocar meu código de banco de dados

# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"*/
$hostname_ipedapae = "bla bala bala";
$database_ipedapae = "u522807324_call";
$username_ipedapae = "u522807324_adm";
$password_ipedapae = "tal coisa e coisa e tal";
$ipedapae = mysql_connect($hostname_ipedapae, $username_ipedapae, $password_ipedapae) or trigger_error(mysql_error());
Data Autor Changelog Download
29/07/2015 12:42pm reeges Versão 1.0 Versão 1.0

Comentários:

Mostrando 1 - 4 de 4 comentários
Boa tarde pessoal, sou iniciante em PHP estou com problema para fazer uma lista simples de uma tabela filmes. Se alguém puder ajudar no comando abaixo:
Obrigado.
<?php
$link = mysqli_connect("localhost","root","root");
if (!$link) {
die ("could not connect to mysql: " . mysqli_errno());
}
$link->select_db("test");

include ("header.php");
?>
<body>
<h1>
Minha Lista de Filmes
</h1>

    <?php
    $query = "SELECT * FROM 'filmes'";
    $result = $link->query($query);

    while($filme = $result->fetch_object()){
    echo "
  • ".$filmes."
  • ";
    }
    ?>

</body>
<?php
include ("footer.php");
mysqli_close($link);
?>
03/05/2016 11:53am (~8 anos atrás)

A função mysql_connect() foi descontinuada, esperimente usar o pdo, ou o mysqli_connect()(gambiarra)
15/12/2015 7:04am (~8 anos atrás)

Ambos os erros apontam para falta do link da conexão. Tente seguir o exemplo dado no site oficial do PHP. Provavelmente será mais fácil identificar o erro, que aparentemente é a falha na conexão com o banco de dados.
http://php.net/manual/pt_BR/function.mysql-select-db.php (Vide Exemplo #1)
05/08/2015 8:02am (~8 anos atrás)

reeges disse:
conto com a ajuda de vocês !!! qualquer coisa meu msn é : reeges_silva@hotmail.com
29/07/2015 12:44pm (~8 anos atrás)

Novo Comentário:

(Você pode usar tags como <b>, <i> ou <code>. URLs serão convertidas para links automaticamente.)