Ir para conteúdo
Fórum Script Brasil

ReDNoS

Membros
  • Total de itens

    170
  • Registro em

  • Última visita

Tudo que ReDNoS postou

  1. ReDNoS

    Ajuda com SMTP

    Tenho este código: <?PHP class smtp_class { var $user=""; var $realm=""; var $password=""; var $workstation=""; var $authentication_mechanism=""; var $host_name=""; var $host_port=25; var $localhost=""; var $timeout=0; var $data_timeout=0; var $direct_delivery=0; var $error=""; var $debug=0; var $html_debug=0; var $esmtp=1; var $esmtp_host=""; var $esmtp_extensions=array(); var $maximum_piped_recipients=100; var $exclude_address=""; var $getmxrr="GetMXRR"; var $pop3_auth_host=""; var $pop3_auth_port=110; /* private variables - DO NOT ACCESS */ var $state="Disconnected"; var $connection=0; var $pending_recipients=0; var $next_token=""; var $direct_sender=""; var $connected_domain=""; var $result_code; /* Private methods - DO NOT CALL */ Function Tokenize($string,$separator="") { if(!strcmp($separator,"")) { $separator=$string; $string=$this->next_token; } for($character=0;$character<strlen($separator);$character++) { if(GetType($position=strpos($string,$separator[$character]))=="integer") $found=(IsSet($found) ? min($found,$position) : $position); } if(IsSet($found)) { $this->next_token=substr($string,$found+1); return(substr($string,0,$found)); } else { $this->next_token=""; return($string); } } Function OutputDebug($message) { $message.="\n"; if($this->html_debug) $message=str_replace("\n","<br />\n",HtmlEntities($message)); echo $message; flush(); } Function SetDataAccessError($error) { $this->error=$error; if(function_exists("socket_get_status")) { $status=socket_get_status($this->connection); if($status["timed_out"]) $this->error.=": data access time out"; elseif($status["eof"]) $this->error.=": the server disconnected"; } } Function GetLine() { for($line="";;) { if(feof($this->connection)) { $this->error="reached the end of data while reading from the SMTP server conection"; return(""); } if(GetType($data=fgets($this->connection,100))!="string" || strlen($data)==0) { $this->SetDataAccessError("it was not possible to read line from the SMTP server"); return(""); } $line.=$data; $length=strlen($line); if($length>=2 && substr($line,$length-2,2)=="\r\n") { $line=substr($line,0,$length-2); if($this->debug) $this->OutputDebug("S $line"); return($line); } } } Function PutLine($line) { if($this->debug) $this->OutputDebug("C $line"); if(!fputs($this->connection,"$line\r\n")) { $this->SetDataAccessError("it was not possible to send a line to the SMTP server"); return(0); } return(1); } Function PutData(&$data) { if(strlen($data)) { if($this->debug) $this->OutputDebug("C $data"); if(!fputs($this->connection,$data)) { $this->SetDataAccessError("it was not possible to send data to the SMTP server"); return(0); } } return(1); } Function VerifyResultLines($code,&$responses) { $responses=array(); Unset($this->result_code); while(strlen($line=$this->GetLine($this->connection))) { if(IsSet($this->result_code)) { if(strcmp($this->Tokenize($line," -"),$this->result_code)) { $this->error=$line; return(0); } } else { $this->result_code=$this->Tokenize($line," -"); if(GetType($code)=="array") { for($codes=0;$codes<count($code) && strcmp($this->result_code,$code[$codes]);$codes++); if($codes>=count($code)) { $this->error=$line; return(0); } } else { if(strcmp($this->result_code,$code)) { $this->error=$line; return(0); } } } $responses[]=$this->Tokenize(""); if(!strcmp($this->result_code,$this->Tokenize($line," "))) return(1); } return(-1); } Function FlushRecipients() { if($this->pending_sender) { if($this->VerifyResultLines("250",$responses)<=0) return(0); $this->pending_sender=0; } for(;$this->pending_recipients;$this->pending_recipients--) { if($this->VerifyResultLines(array("250","251"),$responses)<=0) return(0); } return(1); } Function ConnectToHost($domain, $port, $resolve_message) { if(ereg('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$domain)) $ip=$domain; else { if($this->debug) $this->OutputDebug($resolve_message); if(!strcmp($ip=@gethostbyname($domain),$domain)) return("could not resolve host \"".$domain."\""); } if(strlen($this->exclude_address) && !strcmp(@gethostbyname($this->exclude_address),$ip)) return("domain \"".$domain."\" resolved to an address excluded to be valid"); if($this->debug) $this->OutputDebug("Connecting to host address \"".$ip."\"..."); if(($this->connection=($this->timeout ? @fsockopen($ip,$port,$errno,$error,$this->timeout) : @fsockopen($ip,$port)))) return(""); $error=($this->timeout ? strval($error) : "??"); switch($error) { case "-3": return("-3 socket could not be created"); case "-4": return("-4 dns lookup on hostname \"".$domain."\" failed"); case "-5": return("-5 connection refused or timed out"); case "-6": return("-6 fdopen() call failed"); case "-7": return("-7 setvbuf() call failed"); } return("could not connect to the host \"".$domain."\": ".$error); } Function SASLAuthenticate($mechanisms, $credentials, &$authenticated, &$mechanism) { $authenticated=0; if(!function_exists("class_exists") || !class_exists("sasl_client_class")) { $this->error="it is not possible to authenticate using the specified mechanism because the SASL library class is not loaded"; return(0); } $sasl=new sasl_client_class; $sasl->SetCredential("user",$credentials["user"]); $sasl->SetCredential("password",$credentials["password"]); if(IsSet($credentials["realm"])) $sasl->SetCredential("realm",$credentials["realm"]); if(IsSet($credentials["workstation"])) $sasl->SetCredential("workstation",$credentials["workstation"]); if(IsSet($credentials["mode"])) $sasl->SetCredential("mode",$credentials["mode"]); do { $status=$sasl->Start($mechanisms,$message,$interactions); } while($status==SASL_INTERACT); switch($status) { case SASL_CONTINUE: break; case SASL_NOMECH: if(strlen($this->authentication_mechanism)) { $this->error="authenticated mechanism ".$this->authentication_mechanism." may not be used: ".$sasl->error; return(0); } break; default: $this->error="Could not start the SASL authentication client: ".$sasl->error; return(0); } if(strlen($mechanism=$sasl->mechanism)) { if($this->PutLine("AUTH ".$sasl->mechanism.(IsSet($message) ? " ".base64_encode($message) : ""))==0) { $this->error="Could not send the AUTH command"; return(0); } if(!$this->VerifyResultLines(array("235","334"),$responses)) return(0); switch($this->result_code) { case "235": $response=""; $authenticated=1; break; case "334": $response=base64_decode($responses[0]); break; default: $this->error="Authentication error: ".$responses[0]; return(0); } for(;!$authenticated;) { do { $status=$sasl->Step($response,$message,$interactions); } while($status==SASL_INTERACT); switch($status) { case SASL_CONTINUE: if($this->PutLine(base64_encode($message))==0) { $this->error="Could not send the authentication step message"; return(0); } if(!$this->VerifyResultLines(array("235","334"),$responses)) return(0); switch($this->result_code) { case "235": $response=""; $authenticated=1; break; case "334": $response=base64_decode($responses[0]); break; default: $this->error="Authentication error: ".$responses[0]; return(0); } break; default: $this->error="Could not process the SASL authentication step: ".$sasl->error; return(0); } } } return(1); } /* Public methods */ Function Connect($domain="") { if(strcmp($this->state,"Disconnected")) { $this->error="connection is already established"; return(0); } $this->error=$error=""; $this->esmtp_host=""; $this->esmtp_extensions=array(); $hosts=array(); if($this->direct_delivery) { if(strlen($domain)==0) return(1); $hosts=$weights=$mxhosts=array(); $getmxrr=$this->getmxrr; if(function_exists($getmxrr) && $getmxrr($domain,$hosts,$weights)) { for($host=0;$host<count($hosts);$host++) $mxhosts[$weights[$host]]=$hosts[$host]; KSort($mxhosts); for(Reset($mxhosts),$host=0;$host<count($mxhosts);Next($mxhosts),$host++) $hosts[$host]=$mxhosts[Key($mxhosts)]; } else { if(strcmp(@gethostbyname($domain),$domain)!=0) $hosts[]=$domain; } } else { if(strlen($this->host_name)) $hosts[]=$this->host_name; if(strlen($this->pop3_auth_host)) { $user=$this->user; if(strlen($user)==0) { $this->error="it was not specified the POP3 authentication user"; return(0); } $password=$this->password; if(strlen($password)==0) { $this->error="it was not specified the POP3 authentication password"; return(0); } $domain=$this->pop3_auth_host; $this->error=$this->ConnectToHost($domain, $this->pop3_auth_port, "Resolving POP3 authentication host \"".$domain."\"..."); if(strlen($this->error)) return(0); if(strlen($response=$this->GetLine())==0) return(0); if(strcmp($this->Tokenize($response," "),"+OK")) { $this->error="POP3 authentication server greeting was not found"; return(0); } if(!$this->PutLine("USER ".$this->user) || strlen($response=$this->GetLine())==0) return(0); if(strcmp($this->Tokenize($response," "),"+OK")) { $this->error="POP3 authentication user was not accepted: ".$this->Tokenize("\r\n"); return(0); } if(!$this->PutLine("PASS ".$password) || strlen($response=$this->GetLine())==0) return(0); if(strcmp($this->Tokenize($response," "),"+OK")) { $this->error="POP3 authentication password was not accepted: ".$this->Tokenize("\r\n"); return(0); } fclose($this->connection); $this->connection=0; } } if(count($hosts)==0) { $this->error="could not determine the SMTP to connect"; return(0); } for($host=0, $error="not connected";strlen($error) && $host<count($hosts);$host++) { $domain=$hosts[$host]; $error=$this->ConnectToHost($domain, $this->host_port, "Resolving SMTP server domain \"$domain\"..."); } if(strlen($error)) { $this->error=$error; return(0); } $timeout=($this->data_timeout ? $this->data_timeout : $this->timeout); if($timeout && function_exists("socket_set_timeout")) socket_set_timeout($this->connection,$timeout,0); if($this->debug) $this->OutputDebug("Connected to SMTP server \"".$domain."\"."); if(!strcmp($localhost=$this->localhost,"") && !strcmp($localhost=getenv("SERVER_NAME"),"") && !strcmp($localhost=getenv("HOST"),"")) $localhost="localhost"; $success=0; if($this->VerifyResultLines("220",$responses)>0) { $fallback=1; if($this->esmtp || strlen($this->user)) { if($this->PutLine("EHLO $localhost")) { if(($success_code=$this->VerifyResultLines("250",$responses))>0) { $this->esmtp_host=$this->Tokenize($responses[0]," "); for($response=1;$response<count($responses);$response++) { $extension=strtoupper($this->Tokenize($responses[$response]," ")); $this->esmtp_extensions[$extension]=$this->Tokenize(""); } $success=1; $fallback=0; } else { if($success_code==0) { $code=$this->Tokenize($this->error," -"); switch($code) { case "421": $fallback=0; break; } } } } else $fallback=0; } if($fallback) { if($this->PutLine("HELO $localhost") && $this->VerifyResultLines("250",$responses)>0) $success=1; } if($success && strlen($this->user) && strlen($this->pop3_auth_host)==0) { if(!IsSet($this->esmtp_extensions["AUTH"])) { $this->error="server does not require authentication"; $success=0; } else { if(strlen($this->authentication_mechanism)) $mechanisms=array($this->authentication_mechanism); else { $mechanisms=array(); for($authentication=$this->Tokenize($this->esmtp_extensions["AUTH"]," ");strlen($authentication);$authentication=$this->Tokenize(" ")) $mechanisms[]=$authentication; } $credentials=array( "user"=>$this->user, "password"=>$this->password ); if(strlen($this->realm)) $credentials["realm"]=$this->realm; if(strlen($this->workstation)) $credentials["workstation"]=$this->workstation; $success=$this->SASLAuthenticate($mechanisms,$credentials,$authenticated,$mechanism); if(!$success && !strcmp($mechanism,"PLAIN")) { /* * Author: Russell Robinson, 25 May 2003, http://www.tectite.com/ * Purpose: Try various AUTH PLAIN authentication methods. */ $mechanisms=array("PLAIN"); $credentials=array( "user"=>$this->user, "password"=>$this->password ); if(strlen($this->realm)) { /* * According to: http://www.sendmail.org/~ca/email/authrealms.html#authpwcheck_method * some sendmails won't accept the realm, so try again without it */ $success=$this->SASLAuthenticate($mechanisms,$credentials,$authenticated,$mechanism); } if(!$success) { /* * It was seen an EXIM configuration like this: * user^password^unused */ $credentials["mode"]=SASL_PLAIN_EXIM_DOCUMENTATION_MODE; $success=$this->SASLAuthenticate($mechanisms,$credentials,$authenticated,$mechanism); } if(!$success) { /* * ... though: http://exim.work.de/exim-html-3.20/doc/html/spec_36.html * specifies: ^user^password */ $credentials["mode"]=SASL_PLAIN_EXIM_MODE; $success=$this->SASLAuthenticate($mechanisms,$credentials,$authenticated,$mechanism); } } if($success && strlen($mechanism)==0) { $this->error="it is not supported any of the authentication mechanisms required by the server"; $success=0; } } } } if($success) { $this->state="Connected"; $this->connected_domain=$domain; } else { fclose($this->connection); $this->connection=0; } return($success); } Function MailFrom($sender) { if($this->direct_delivery) { switch($this->state) { case "Disconnected": $this->direct_sender=$sender; return(1); case "Connected": $sender=$this->direct_sender; break; default: $this->error="direct delivery connection is already established and sender is already set"; return(0); } } else { if(strcmp($this->state,"Connected")) { $this->error="connection is not in the initial state"; return(0); } } $this->error=""; if(!$this->PutLine("MAIL FROM:<$sender>")) return(0); if(!IsSet($this->esmtp_extensions["PIPELINING"]) && $this->VerifyResultLines("250",$responses)<=0) return(0); $this->state="SenderSet"; if(IsSet($this->esmtp_extensions["PIPELINING"])) $this->pending_sender=1; $this->pending_recipients=0; return(1); } Function SetRecipient($recipient) { if($this->direct_delivery) { if(GetType($at=strrpos($recipient,"@"))!="integer") return("it was not specified a valid direct recipient"); $domain=substr($recipient,$at+1); switch($this->state) { case "Disconnected": if(!$this->Connect($domain)) return(0); if(!$this->MailFrom("")) { $error=$this->error; $this->Disconnect(); $this->error=$error; return(0); } break; case "SenderSet": case "RecipientSet": if(strcmp($this->connected_domain,$domain)) { $this->error="it is not possible to deliver directly to recipients of different domains"; return(0); } break; default: $this->error="connection is already established and the recipient is already set"; return(0); } } else { switch($this->state) { case "SenderSet": case "RecipientSet": break; default: $this->error="connection is not in the recipient setting state"; return(0); } } $this->error=""; if(!$this->PutLine("RCPT TO:<$recipient>")) return(0); if(IsSet($this->esmtp_extensions["PIPELINING"])) { $this->pending_recipients++; if($this->pending_recipients>=$this->maximum_piped_recipients) { if(!$this->FlushRecipients()) return(0); } } else { if($this->VerifyResultLines(array("250","251"),$responses)<=0) return(0); } $this->state="RecipientSet"; return(1); } Function StartData() { if(strcmp($this->state,"RecipientSet")) { $this->error="connection is not in the start sending data state"; return(0); } $this->error=""; if(!$this->PutLine("DATA")) return(0); if($this->pending_recipients) { if(!$this->FlushRecipients()) return(0); } if($this->VerifyResultLines("354",$responses)<=0) return(0); $this->state="SendingData"; return(1); } Function PrepareData(&$data,&$output,$preg=1) { if($preg && function_exists("preg_replace")) $output=preg_replace(array("/\n\n|\r\r/","/(^|[^\r])\n/","/\r([^\n]|\$)/D","/(^|\n)\\./"),array("\r\n\r\n","\\1\r\n","\r\n\\1","\\1.."),$data); else $output=ereg_replace("(^|\n)\\.","\\1..",ereg_replace("\r([^\n]|\$)","\r\n\\1",ereg_replace("(^|[^\r])\n","\\1\r\n",ereg_replace("\n\n|\r\r","\r\n\r\n",$data)))); } Function SendData($data) { if(strcmp($this->state,"SendingData")) { $this->error="connection is not in the sending data state"; return(0); } $this->error=""; return($this->PutData($data)); } Function EndSendingData() { if(strcmp($this->state,"SendingData")) { $this->error="connection is not in the sending data state"; return(0); } $this->error=""; if(!$this->PutLine("\r\n.") || $this->VerifyResultLines("250",$responses)<=0) return(0); $this->state="Connected"; return(1); } Function ResetConnection() { switch($this->state) { case "Connected": return(1); case "SendingData": $this->error="can not reset the connection while sending data"; return(0); case "Disconnected": $this->error="can not reset the connection before it is established"; return(0); } $this->error=""; if(!$this->PutLine("RSET") || $this->VerifyResultLines("250",$responses)<=0) return(0); $this->state="Connected"; return(1); } Function Disconnect($quit=1) { if(!strcmp($this->state,"Disconnected")) { $this->error="it was not previously established a SMTP connection"; return(0); } $this->error=""; if(!strcmp($this->state,"Connected") && $quit && (!$this->PutLine("QUIT") || $this->VerifyResultLines("221",$responses)<=0)) return(0); fclose($this->connection); $this->connection=0; $this->state="Disconnected"; if($this->debug) $this->OutputDebug("Disconnected."); return(1); } Function SendMessage($sender,$recipients,$headers,$body) { if(($success=$this->Connect())) { if(($success=$this->MailFrom($sender))) { for($recipient=0;$recipient<count($recipients);$recipient++) { if(!($success=$this->SetRecipient($recipients[$recipient]))) break; } if($success && ($success=$this->StartData())) { for($header_data="",$header=0;$header<count($headers);$header++) $header_data.=$headers[$header]."\r\n"; if(($success=$this->SendData($header_data."\r\n"))) { $this->PrepareData($body,$body_data); $success=$this->SendData($body_data); } if($success) $success=$this->EndSendingData(); } } $error=$this->error; $disconnect_success=$this->Disconnect($success); if($success) $success=$disconnect_success; else $this->error=$error; } return($success); } }; ?> Ele está dando o seguinte erro: "Fatal error: Cannot redeclare class smtp_class in c:\arquivos de programas\easyphp1-8\www\site\smtp\smtp.php on line 4" Ele está dando erro na linha 4 "{ var $user="";" Alguém sabe como resolver isso?
  2. ReDNoS

    Ajuda com Form

    Olá pessoal, eu preciso bloquear um caracter específico, o underline para dois inputs do meu form. E também preciso bloquear a tecla Ctrl+C e Ctrl+V, porque se a pessoa copia e cola caracteres, meus inputs as aceitam, mesmo que eu tenha configurado um onkeypress que as bloqueia... Eu encontrei esse Script para bloquear caracteres, mas não consegui usá-lo. $pattern = "[^a-zA-Z0-9]"; if(ereg($pattern,$password) == TRUE) { die('Caracters não permitidos'); } Por favor, isso é urgente. Aguardo respostas... Abraços!
  3. Olá pessoal da Script Brasil, eu tenho esse Script: <script language="Javascript"> function validaCPF() { nome = document.validacao.nome.value; erro = new String; if (nome.length < 3) erro += "são necessarios 3 digitos para verificacao do nome! \n\n"; var nonNumbers = /\D/; if (nonNumbers.test(nome)) erro += "A verificacao de nome suporta apenas numeros! \n\n"; if (erro.length > 0){ alert(erro); return false; } return true; } </script> Mas nele, ao invés de aceitar apenas letras, ele aceita apenas números. a linha do código responsável por isso é var nonNumbers = /\D/;, alguém sabe como modificar isso para aceitar apenas letras? (Sem ser caracteres especiais). Editado --------------------------------------------------------------------------------- Não precisa mais, eu já consegui...
  4. ReDNoS

    Dúvida Input

    Olá pessoal da ScriptBrasil, eu estou tendo dificuldades, eu gostaria de criar 2 Inputs onde seriam colocados strings e essas strings dos inputs fossem unidas ex: Input1 = "test" + Input2 = "ando" = Input1 + Input2 = "testando". Mas eu gostaria que a string @ fosse colocada no meio dos dois inputs. Basicamente, o que estou fazendo é um cadastro de e-mail aonde no primeiro input a pessoal coloca o nome do e-mail (armindo_123) e no segundo input coloca o serviço de e-mail (gmail.com, hotmail.com...) e no meio desses dois inputs ficasse a String @ e somasse as 3 strings (Input1 + @ + Input2 = nome_do_input1@input2.com) Espero que tenham entendido... Bem que tentei procurar aki pelo fórum mesmo, mas não achei nenhum tópico que falasse diretamente sobre esse problema... :blush: Bom é isso...
  5. ReDNoS

    Dúvida com um Código

    Olá pessoal da Script Brasil. Tenho um código em que ele a classe de uma pessoa (se ela é Normal, VIP, Super VIP...) Meu código é esse: <?=''.ucfirst($user['Authority'] = 4 ? 'VIP' : 'Normal').''?> Nesse caso, se o Campo Authority da tabela user for = 4, então ele me retorna a String "VIP", senão me retorna "Normal". Eu gostaria de no mesmo código, colocar mais 2 tipos de retorno, queria colocar se o Campo Autority fosse = 3 e se fosse = 2 então me retornasse as Strings "Royal" e "Cash". Acho que não deve ser um problema de difícil resolução e acredito que não seja impossível, portanto, estou aqui de plantidão a espera de uma resposa que me ajude^^ OBrigado, vocês tem me ajudado a beça ;D
  6. Vixi, mas eu to usando Easy PHP 1.8 para criar meu site, tem algum tutorial explicando o modo fopen/fwrite/fclose que você citou? É que eu também ainda não sei qual versão do PHP o host que eu hospedarei estará usadno, portanto acho melhor estar por dentro das duas explicações =D
  7. Hum...entendi, mas como eu farei para que a minha página atualizacao.php gere esse XML e como fazer para que a minha página rank.php mostre os dados do XML ao em vez dos dados diretos do meu BD?
  8. Olá pessoal da ScriptBrasil, estou novamente aqui com uma dúvida que está me arrepiando os cabelos, procurei e não achei nada de concreto... Eu mostro os valores do Campo TotalScore da tabela game em uma página PHP organizado por DESC (do maior para o menor). Mas é só um valor do campo TotalScore ser modificado que ele mostrará o novo valor na minha página. Eu gostaria de congelar todos os valores dessa página até que eu executasse o meu arquivo atualizacao.php, caso contrário, os valores seriam mantidos conforme os valores da ultima atualização... Bom, espero ter explicado o que eu quero de forma que vocês entendam. Fico na espera...Vlw ScriptBrasil!
  9. :rolleyes: Funciono perfeitamente :rolleyes: , obrigado :blush:
  10. Sim, mas estou tendo dificuldades em fazer esse if. minha função está assim: function rankup($rankupimage, $rankdownimagem, $noimage) { $rankupimagem = "<img src=image/rank_up.gif>"; $rankdownimagem = "<img src=image/rank_down.gif>"; $noimage = "<img src=image/noimage.gif>"; if ($game['TotalRankUp'] >= 1) { return $rankupimagem; }else{ if ($game['TotalRankUp'] <= -1) { return $rankdownimagem; }else{ return $noimage; } } } O Problema é que não está dando quase nada certo, primeiro que ele mostra a imagem igual para todos os usuários, segundo que ele não mostra a imagem de acordo com os meus ifs... por isso estou pedindo ajuda, meu if deve ter vários erros e eu não estou sabendo quais são...
  11. Olá novamente pessoal da ScriptBrasil, eu gostaria de criar uma Função que: -mostra a imagem "rank_up.gif" Se o campo TotalRankUp da minha tabela game for maior ou igual a 1. -mostra a imagem "rankd_down.gif" Se o campo TotalRankUp da minha tabela game for menor ou igual a -1. -Se for 0, não mostra nada. E Gostaria de estar fazendo esse Retorno de imagem para cada usuário de acordo com o seu TotalRankUp... Fico na espera...
  12. ReDNoS

    Mostrar notícia desejada

    Meu Deus do céu, mas nem assim deu. Talvez seja necessário definir algo na central_noticias.php para que o $id seja reconhecido na página noticias.php. Vejam o código-fonte das minhas duas páginas: central_noticias.php: (a tag <a href=noticia.php?id=numero_do_id> fica inserido em $title ($title = título da notícia)) <?PHP $pesquisa = mysql_query ("SELECT * FROM gbnews ORDER BY id DESC"); $linhas = mysql_num_rows ($pesquisa); while ($x = mysql_fetch_array ($pesquisa)) { $date = $x["Date"]; $Title = $x["Title"]; echo "<tr> <td background=\"template/gb-extreme/images/t_01.gif\"></td> <td background=\"template/gb-extreme/images/t_02.gif\"><font color=\"#00000000\"><b>$date: </b>Title</font></td> <td background=\"template/gb-extreme/images/t_03.gif\"></td> </tr>"; } ?> noticia.php <?php $seleciona = mysql_query ("SELECT * FROM gbnews"); $id=$_GET["id"]; $resultado = mysql_query("SELECT id, Title, Text FROM gbnews WHERE id=$id"); echo $resultado; { $registro=mysql_fetch_row($resultado); //echo "<span class='txt'>Id: $registro[0]<br></span>";// O 'Id' está oculto aqui na posiçao '0' do array $id=$registro[0];// armazeno o valor da posicao '0' na varialvel '$id' //$registro[1] - data //$registro[2] - titulo //$registro[3] - texto } echo " <table width='550' border='0' cellpadding='0' cellspacing='0'> <tr> <td height='20'></td> </tr> <tr> <td height='30' class='dataInt' valign='top'>» $registro[1]</td> </tr> <tr> <td height='20' class='titulo_az2'><div align='justify'>$registro[2]</div></td> </tr> <tr><td height='15'></td></tr> <tr> <td height='20' class='txtInt'>$registro[3]</td> </tr> <tr> <td height='50'></td> </tr> <tr> <td align='left'><a href='central_noticia.php' class='mais_not' target='_top'>» Ler outras noticias</a></td> </tr> <tr> <td height='90'></td> </tr> </table> "; ?> Se algo está errado, deve ser na cetral_noticias.php...
  13. ReDNoS

    Mostrar notícia desejada

    Alguém pode me ajudar? Alguém tem outra solução ou outro script que se encaixe com o que eu quero? Por favor, ajudem-me, estou criando um site e já estou ficando atrasado...
  14. ReDNoS

    Mostrar notícia desejada

    Nenhum resultado =/, continua a mesma coisa...
  15. ReDNoS

    Mostrar notícia desejada

    Mas quando mudei a linha para $Id = $_GET["Id"]; também mudei o meu link com o Id com I maiúsculo. <a href=noticia.php?Id=1> E mesmo assim, ao clicar no link, ele não mostra nenhuma informação da notícia...
  16. ReDNoS

    Mostrar notícia desejada

    Cara, não deu certo! E olha que eu coloquei todos os "Id´s" com I maísculos igual está no meu banco de dados, e mesmo assim não foi... Se eu retiro o "WHERE Id = $Id", os meus links mostram a notícia de Id = 0, se eu coloco o "WHERE Id = $Id", meus links não mostram nada... o que mais pode ser? Quando eu faço $resultado = mysql_query("SELECT * FROM gbnews WHERE Id=2"); ele me mostra certinho as informações da notícia com Id=2...
  17. Alguém pode ajudar-me? Quero evitar os caracteres especiais que eu desejo!
  18. ReDNoS

    Mostrar notícia desejada

    Eu li o tópico, tentei adaptar para o meu, e agora ele está dando o mesmo erro do cara, quando clico no link ele mostra a notícia de Id=1 em todas as notícias, e quando coloco ("Select * FROM gbnews WHERE Id=$id"); ele não mostra nada ao clicar no link para ir para a notícia. Os links das notícias estão com a tag <a href=noticia.php?id=X> (X = ao número do Id) e o código noticia.php, onde aparece as notícias está assim: <?php $id = $_GET["Id"]; $resultado = mysql_query("SELECT * FROM gbnews WHERE Id=$Id"); { $registro=mysql_fetch_row($resultado); //echo "<span class='txt'>Id: $registro[0]<br></span>";// O 'Id' está oculto aqui na posiçao '0' do array $id=$registro[0];// armazeno o valor da posicao '0' na varialvel '$id' //$registro[1] - data //$registro[2] - titulo //$registro[3] - texto } echo " <table width='550' border='0' cellpadding='0' cellspacing='0'> <tr> <td height='20'></td> </tr> <tr> <td height='30' class='dataInt' valign='top'>» $registro[1]</td> </tr> <tr> <td height='20' class='titulo_az2'><div align='justify'>$registro[2]</div></td> </tr> <tr><td height='15'></td></tr> <tr> <td height='20' class='txtInt'>$registro[3]</td> </tr> <tr> <td height='50'></td> </tr> <tr> <td align='left'><a href='central_noticia.php' class='mais_not' target='_top'>» Ler outras noticias</a></td> </tr> <tr> <td height='90'></td> </tr> </table> "; ?> O que está errado?
  19. Olá pessoal, eu estou fazendo um sistema de notícias pelo Banco de Dados. Meu códio no site em PHP é esse: <?PHP $pesquisa = mysql_query ("SELECT * FROM gbnews ORDER BY id DESC"); $linhas = mysql_num_rows ($pesquisa); while ($x = mysql_fetch_array ($pesquisa)) { $date = $x["Date"]; $Title = $x["Title"]; echo "<tr> <td background=\"template/gb-extreme/images/t_01.gif\"></td> <td background=\"template/gb-extreme/images/t_02.gif\"><font color=\"#00000000\"><b>$date: </b>$Title</font></td> <td background=\"template/gb-extreme/images/t_03.gif\"></td> </tr>"; echo "<br><br>"; } ?> Esse códio mostra o Título da notícia e a data em que ela foi adicionada. No comando $Title tem o título, aonde eu coloco uma Tag <a href> para direcionar para a notícia completa, pois é, eis o meu problema, preciso direcionar para a notícia desejada mostrando o $Title, %Date e %Text da notícia. Eu não consigo de jeito nenhum, o máximo que consegui foi mostrar todas as notícias, porém eu quero apenas mostrar a notícia onde $Id = ao Id da notícia que foi aberto. Se alguém souber como ajudar, por favor não se acude em me ajudar :rolleyes: OBS: eu gostaria de utilizar apenas um notice.php aonde será mostrado as notícias completas de acordo com a notícia que o usuário abrir no código acima. Seria muit chato ter de fazer uma página para cada notícia...
  20. eu não consegui adaptar, alguém me passa ou outro script pronto?
×
×
  • Criar Novo...