Jump to content


Leo_30

Member Since 03/09/2004
Offline Last Active 06/09/2006, 00:36
-----

Topics I've Started

Preciso De Ajuda Com Sql

08/11/2004, 10:45

Tenho o seguinte código:

$link = mysql_connect("localhost", "root", "")
or die("Não pude conectar: " . mysql_error());
$db = "denuncia";
$tabela = "tb_denuncia";
print ("Conectado!");
$tabela = mysql_query("INSERT INTO tb_denuncia (A,B,C,D,E,F,G,H,I,J,L,M,N,O,P,Q,R,S,T) VALUES ('$0','$1','$2','$3','$4','$5','$6','$7','$8','$9','$10','$11','$12','$13','$14','$15','$','$16','$17'");
$cadastrar = mysql_query($tabela);

if ($cadastrar==1){
echo "O seu cadastro foi concluído com sucesso. Obrigado!";
}
else {
echo "Ocorreu um erro no servidor ao tentar se cadastrar. Tente mais tarde.";
}

As letras (A, B,....) e os números (1,2,...) não correspondem aos campos reais, neste caso.
No fim ele mostra o seguinte resultado:
Conectado!Ocorreu um erro no servidor ao tentar se cadastrar. Tente mais tarde.


Alguém me sabe dizer pq isto sempre acontece??????

Ajuda Com Php E Sql

04/11/2004, 19:02

Tenho o seguinte código:

$link = mysql_connect("localhost", "root", "")
or die("Não pude conectar: " . mysql_error());
$db = "denuncia";
$tabela = "tb_denuncia";
print ("Conectado!");
$tabela = mysql_query("INSERT INTO tb_denuncia (escolha,orgao,data,nome,telefone,mail,bairro,logradouro,cep,municipio,gecam,gerco,gepre,outro,empresalocal,rualocal,bairrolocal,municipiolocal,ocorrencia) VALUES ('$escolha','$orgao','$data','$nome','$telefone','$mail','$bairro','$logradouro','$cep','$municipio','$gecam','$gerco','$gepre','$txtoutros','$empresalocal','$rualocal','$bairrolocal','$municipiolocal','$ocorrencia'");
$cadastrar = mysql_query($tabela);

if ( $cadastrar == 1 ) {
echo "O seu cadastro foi concluído com sucesso. Obrigado!";
}
else {
echo "Ocorreu um erro no servidor ao tentar se cadastrar. Tente mais tarde.";
}


E sempre mostra o seguinte resultado:
Conectado!Ocorreu um erro no servidor ao tentar se cadastrar. Tente mais tarde.

pq??? Alguém sabe o q estou a fazer errado??????

Obrigado

Can't Connect To Mysql Server

14/09/2004, 11:02

Tenho uma página que consigo acessar em meu PC. Localmente ele acede á BD. Mas quando coloco no servidor da página web dá o seguinte erro:
Warning: mysql_pconnect(): Can't connect to MySQL server on *********
Can't connect to MySQL server on *****

O código que uso é o seguinte:

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_teste = "localhost";
$database_teste = "imaform";
$username_teste = "root";
$password_teste = "";
$teste = mysql_pconnect($hostname_teste, $username_teste, $password_teste) or die(mysql_error());
?>


O que preciso mudar???? o que está errado????

Problemas Com Asp E Access

03/09/2004, 17:12

Antes de mais, kero dizer que sou novo em programação com ASP, sei apenas o q leio nos últimos dias as apostilas. Isso porque necessito de fazer alguns formulários para inserir dados e fazer alteração nos mesmos caso seja necessário. Já fiz a BD em Access e comecei a fazer alguma coisa em ASP, acho ue não é necessário dizer ue o resultado não foi o melhor. Mas ninguém nasce a saber tudo é por isso que resolvi escrever para encontrar uma alma caridosa que me ajude. Porque eu já estou a ficar com vontade de desistir.
Bem tenho uma página:

- alterar.asp:

<html>
<head>
<title>Acesse o seu curriculo</title>
</head>
<body>
<center><font face="Arial" size="4"><b>Formulário de Alteração</b></h2></center>

<%
If IsEmpty( Request.Form("submit") ) Then
Set Conexao = Server.CreateObject("ADODB.Connection")
Constr = "DBQ=Z:\Inetpub\wwwroot\teste\Cadastro\cadastro.mdb;Driver={Microsoft Access Driver (*.mdb)};"
Conexao.Open Constr
ComandoSQL = "SELECT * FROM tblpessoa"
Set bd = Server.CreateObject("ADODB.Recordset")
bd.CursorLocation = 2
bd.CursorType = 0
bd.LockType = 3
bd.Open ComandoSQL, conexao,,, &H0001

If Not bd.EOF Then
bd.Move Request.QueryString("n")
%>

<form method=post action="<%=Request.ServerVariables("script_name")%>">
<input type=hidden name="ComandoSQL" value="<%=ComandoSQL%>">
<input type=hidden name="Conexao" value="<%=Constr%>">
<table border=0 width="80%" align=center>
<tr>
<td align=right valign=top><font face="Arial" size="2">bairro:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="bairro" value="<%=bd("bairro")%>" size=15 maxlength=50 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">cpf:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="cpf" value="<%=bd("cpf")%>" size=15 maxlength=50 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">curriculo:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="curriculo" value="<%=bd("curriculo")%>" size=15 maxlength=50 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">estado:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="estado" value="<%=bd("estado")%>" size=15 maxlength=50 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">identidade:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="identidade" value="<%=bd("identidade")%>" size=15 maxlength=50 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">Logradouro:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="Logradouro" value="<%=bd("Logradouro")%>" size=15 maxlength=50 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">municipio:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="municipio" value="<%=bd("municipio")%>" size=15 maxlength=50 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">nome:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="nome" value="<%=bd("nome")%>" size=15 maxlength=20 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">senha:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=password name="senha" value="<%=bd("senha")%>" size=15 maxlength=20 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">telefone:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="telefone" value="<%=bd("telefone")%>" size=15 maxlength=50 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
</font>
</table>
<center><input type=submit name=submit value=Alterar style="{<font-family:Arial; font-size:12}"></center>
<input type="hidden" name="n" value="<%if Not IsEmpty(Request.QueryString("n"))then : Response.Write Request.QueryString("n") Else : Response.Write "0" : End If%>">
</form>
<center>
<%
If Request.QueryString("n") > 0 then
Response.Write "<a href=" & Request.ServerVariables("SCRIPT_NAME") & "?n=" & Request.QueryString("n") - 1 & ">&lt;&lt; Anterior</a>&nbsp;&nbsp;"
End If
bd.MoveNext
If Not bd.EOF then
Response.Write "&nbsp;&nbsp;<a href=" & Request.ServerVariables("SCRIPT_NAME") & "?n=" & Request.QueryString("n") + 1 & ">Próximo &gt;&gt;</a>"
End If
Conexao.Close
Set bd = Nothing
Set Conexao = Nothing
%>
</center>

<%
End If
Else
If Not IsEmpty(Request.Form("submit")) AND Trim(Request.Form("bairro")) <> "" AND Trim(Request.Form("cpf")) <> "" AND Trim(Request.Form("curriculo")) <> "" AND Trim(Request.Form("estado")) <> "" AND Trim(Request.Form("identidade")) <> "" AND Trim(Request.Form("Logradouro")) <> "" AND Trim(Request.Form("municipio")) <> "" AND Trim(Request.Form("nome")) <> "" AND Trim(Request.Form("senha")) <> "" AND Trim(Request.Form("telefone")) <> "" Then
Set Conexao = Server.CreateObject("ADODB.Connection")
Conexao.Open Request.Form("Conexao")
ComandoSQL = Request.Form("ComandoSQL")
Set bd = Server.CreateObject("ADODB.Recordset")
bd.CursorLocation = 2
bd.CursorType = 0
bd.LockType = 3
bd.Open ComandoSQL, Conexao,,, &H0001
bd.Move Request.Form("n")
bd("bairro") = Server.HTMLEncode(Request.Form("bairro"))
bd("cpf") = Server.HTMLEncode(Request.Form("cpf"))
bd("curriculo") = Server.HTMLEncode(Request.Form("curriculo"))
bd("estado") = Server.HTMLEncode(Request.Form("estado"))
bd("identidade") = Server.HTMLEncode(Request.Form("identidade"))
bd("Logradouro") = Server.HTMLEncode(Request.Form("Logradouro"))
bd("municipio") = Server.HTMLEncode(Request.Form("municipio"))
bd("nome") = Server.HTMLEncode(Request.Form("nome"))
bd("senha") = Server.HTMLEncode(Request.Form("senha"))
bd("telefone") = Server.HTMLEncode(Request.Form("telefone"))
bd.UpdateBatch
bd.Requery
%>

<font face="Arial" size="2">
<center><br>Os dados foram enviados com sucesso!

<br><a href="index.asp"><b>Clique aqui</b></a> para continuar</font></center>

<%
Else
%>

<font face="Arial" size="2">
<center><br>Atenção: Alguns dados necessário não foram preenchidos corretamente

<br><a href="java script:history.go(-1)"><b>Clique aqui</b></a> para voltar</font></center>

<%
End If
End If
%>

</body>
</html>
- consulta.asp (Neste momento está assim, porue não sei fazer melhor mas o meu objetivo era fazer uma consulta por por nome. Isto é, que o utilizador ao clicar na letra A, aparecesse todos os nomes começados pela letra A e assim sucessivamente):

<html>
<head>
<title>Acesse o seu curriculo</title>
</head>
<body>
<center><font face="Arial" size="4"><b>Formulário de Consulta</b></h2></center>
<table border=0 width="80%" align=center>
<%
Set Conexao = Server.CreateObject("ADODB.Connection")
Conexao.Open "DBQ=cadastro.mdb;Driver={Microsoft Access Driver (*.mdb)};"
ComandoSQL = "SELECT * FROM tblpessoa"
Set bd = Conexao.Execute(ComandoSQL)
If Not bd.EOF Then
bd.Move Request.QueryString("n")
%>
<tr>
<td align=right valign=top>
<font face="Arial" size="2">bairro:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<b><%=bd("bairro")%></b></font></td></tr>
<tr>
<td align=right valign=top>
<font face="Arial" size="2">cpf:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<b><%=bd("cpf")%></b></font></td></tr>
<tr>
<td align=right valign=top>
<font face="Arial" size="2">curriculo:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<b><%=bd("curriculo")%></b></font></td></tr>
<tr>
<td align=right valign=top>
<font face="Arial" size="2">estado:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<b><%=bd("estado")%></b></font></td></tr>
<tr>
<td align=right valign=top>
<font face="Arial" size="2">identidade:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<b><%=bd("identidade")%></b></font></td></tr>
<tr>
<td align=right valign=top>
<font face="Arial" size="2">Logradouro:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<b><%=bd("Logradouro")%></b></font></td></tr>
<tr>
<td align=right valign=top>
<font face="Arial" size="2">municipio:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<b><%=bd("municipio")%></b></font></td></tr>
<tr>
<td align=right valign=top>
<font face="Arial" size="2">nome:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<b><%=bd("nome")%></b></font></td></tr>
<tr>
<td align=right valign=top>
<font face="Arial" size="2">senha:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<b><%=bd("senha")%></b></font></td></tr>
<tr>
<td align=right valign=top>
<font face="Arial" size="2">telefone:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<b><%=bd("telefone")%></b></font></td></tr>

</table><br><center>

<%
If Request.QueryString("n") > 0 then
Response.Write "<a href=" & Request.ServerVariables("SCRIPT_NAME") & "?n=" & Request.QueryString("n") - 1 & ">&lt;&lt; Anterior</a>&nbsp;&nbsp;"
End If

bd.MoveNext
If Not bd.EOF then
Response.Write "&nbsp;&nbsp;<a href=" & Request.ServerVariables("SCRIPT_NAME") & "?n=" & Request.QueryString("n") + 1 & ">Próximo &gt;&gt;</a>"
End If

Conexao.Close
Set bd = Nothing
Set Conexao = Nothing
%>
</table>
</body>
</html>

- inserir.asp:

<html>
<head>
<title>Acesse o seu curriculo</title>
</head>
<body>
<center><font face="Arial" size="4"><b>Formulário de Inclusão</b></h2></center>
<%
If IsEmpty( Request.Form("submit") ) Then
%>
<form method=post action="<%=Request.ServerVariables("script_name")%>">
<table border=0 width="80%" align=center>
<tr>
<td align=right valign=top><font face="Arial" size="2">bairro:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="bairro" value="" size=15 maxlength=50 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">cpf:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="cpf" value="" size=15 maxlength=50 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">curriculo:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<textarea name="curriculo" rows=5 cols=20 style="{<font-family:Arial; font-size:12}"></textarea>
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">estado:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<select size="1" name="estado" style="{<font-family:Arial; font-size:12}">
<option value=""></option>
<option value="AL" selected>AL</option>
<option value="BA">BA</option>
<option value="CE">CE</option>
<option value="DF">DF</option>
<option value="ES">ES</option>
<option value="MG">MG</option>
<option value="PR">PR</option>
<option value="RJ">RJ</option>
<option value="RS">RS</option>
<option value="SC">SC</option>
<option value="SE">SE</option>
<option value="SP">SP</option>
</select>
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">identidade:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="identidade" value="" size=15 maxlength=50 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">Logradouro:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="Logradouro" value="" size=15 maxlength=50 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">municipio:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="municipio" value="" size=15 maxlength=50 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">nome:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="nome" value="" size=15 maxlength=20 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">senha:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=password name="senha" value="" size=15 maxlength=20 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
<tr>
<td align=right valign=top><font face="Arial" size="2">telefone:</font></td>
<td align=left valign=top>
<font face="Arial" size="2">
<input type=text name="telefone" value="" size=15 maxlength=50 style="{<font-family:Arial; font-size:12}">
</td>
</tr>
</table>
<center><input type=submit name=submit value=Incluir style="{<font-family:Arial; font-size:12}">
</center>
</form>
<%
Else
If Not IsEmpty(Request.Form("submit")) AND Trim(Request.Form("bairro")) <> "" AND Trim(Request.Form("cpf")) <> "" AND Trim(Request.Form("curriculo")) <> "" AND Trim(Request.Form("estado")) <> "" AND Trim(Request.Form("identidade")) <> "" AND Trim(Request.Form("Logradouro")) <> "" AND Trim(Request.Form("municipio")) <> "" AND Trim(Request.Form("nome")) <> "" AND Trim(Request.Form("senha")) <> "" AND Trim(Request.Form("telefone")) <> "" Then
Set Conexao = Server.CreateObject("ADODB.Connection")
Conexao.Open "DBQ=Z:\Inetpub\wwwroot\teste\Cadastro\cadastro.mdb;Driver={Microsoft Access Driver (*.mdb)};"
ComandoSQL = "INSERT INTO tblpessoa (bairro, cpf, curriculo, estado, identidade, Logradouro, municipio, nome, senha, telefone)"
ComandoSQL = ComandoSQL & " VALUES ("
ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("bairro")) & "',"
ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("cpf")) & "',"
ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("curriculo")) & "',"
ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("estado")) & "',"
ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("identidade")) & "',"
ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("Logradouro")) & "',"
ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("municipio")) & "',"
ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("nome")) & "',"
ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("senha")) & "',"
ComandoSQL = ComandoSQL & "'" & Server.HTMLEncode(Request.FORM("telefone")) & "')"
Set bd = Conexao.Execute(ComandoSQL)
Conexao.Close
Set bd = Nothing
Set Conexao = Nothing
%>
</body>
</html>

Neste momento é todo o código que tenho. Será ue alguém me consegue ajudar?
Fico a aguardar.
Obrigado

Estas páginas estão a ser colocadas em(talvez ajude):

- http://www.perfilcom...ro/inserir.asp;
- http://www.perfilcom...ro/alterar.asp;
http://www.perfilcom...ro/consulta.asp.

IPB Skin By Virteq