Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Douglas Goulart

Problemas com o WampServer

Recommended Posts

Fala aí pessoal, beleza?

 

Não estou conseguindo criar um cadastro com o mysql, já refiz o bd várias vezes e aparece as mesmas mensagens. Uso o WampServer v 2.5, eis as mensagens:

 

Deprecated: mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\testesistema\default.php on line 10

Warning: mysql_select_db() expects parameter 2 to be resource, object given in C:\wamp\www\testesistema\default.php on line 58

Warning: mysql_query() expects parameter 2 to be resource, object given in C:\wamp\www\testesistema\default.php on line 59

 

default.php

 

<?php require_once('Connections/conexao.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 curriculo (nome, cpf, endcompleto, cep, cidade, uf, telefones, email, idade, estadocivil, qtdfilhos, objetivo, qualificacoes, formacademica, expprofissional, outinformacoes) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['cpf'], "text"),
GetSQLValueString($_POST['endcompleto'], "text"),
GetSQLValueString($_POST['cep'], "text"),
GetSQLValueString($_POST['cidade'], "text"),
GetSQLValueString($_POST['uf'], "text"),
GetSQLValueString($_POST['telefones'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['idade'], "text"),
GetSQLValueString($_POST['estadocivil'], "text"),
GetSQLValueString($_POST['qtdfilhos'], "text"),
GetSQLValueString($_POST['objetivo'], "text"),
GetSQLValueString($_POST['qualificacoes'], "text"),
GetSQLValueString($_POST['formacademica'], "text"),
GetSQLValueString($_POST['expprofissional'], "text"),
GetSQLValueString($_POST['outinformacoes'], "text"));

mysql_select_db("cv", $conexao);
$Result1 = mysql_query($insertSQL, $conexao) or die(mysql_error());

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

 

Cada cor, corresponde a um erro em específico, que já procurei no google e não encontrei nada. Não sei se é problema de versão do wamp , ou do próprio DW CS5, sei lá!

Alguém pode me socorrer?

 

Aguardo respostas!!!

 

[]'s

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

Onde você cria a variável $conexao?

 

Sobre os erros:

 

 


Deprecated: mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\testesistema\default.php on line 10

funções mysql_* estão obsoletas desde o PHP 5.5 e serão removidas do PHP em breve. Prefira usar MySQLi ou PDO. Veja mais aqui: http://www.ultimatephp.com.br/php-por-que-nao-utilizar-funcoes-mysql

 

 

Os demais erros são causados por $conexao. Essa variável deve estar recebendo um valor errado (objeto em vez de resource de conexão)

Compartilhar este post


Link para o post
Compartilhar em outros sites

Obrigado por tentar me ajudar, mas a variável $conexao estou usando no DW CS5 e criou um arquivo em php:

 

conexao.php

 

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_conexao = "localhost";
$database_conexao = "cv";
$username_conexao = "root";
$password_conexao = "";
$conexao = PDO::($hostname_conexao, $username_conexao, $password_conexao) or trigger_error(PDO::(),E_USER_ERROR);
?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Há dois problemas:

 

1. A conexão usa PDO e o resto do script usa mysql. Tem que usar um ou outro

2. Esta sintaxe está errada:

 

 

$conexao = PDO::($hostname_conexao, $username_conexao, $password_conexao) or trigger_error(PDO::(),E_USER_ERROR);

 

Não existe Classe::(). Precisa ter o nome do método, como Classe::metodo()

 

 

Se o Dreamwaver gerou código com esse tipo de erro, sugiro que largue essa ferramenta. Ela só vai te atrapalhar.

 

Veja um ótimo artigo sobre PDO: http://www.ultimatephp.com.br/php-por-que-nao-utilizar-funcoes-mysql

 

 

15 Dicas de PHP: http://www.ultimatephp.com.br/guia/

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.