Visualizzazione dei risultati da 1 a 6 su 6

Discussione: Problema con DELETE

  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2009
    Messaggi
    27

    Problema con DELETE

    ciao ragazzi è la prima volta che provo a creare uno script PHP. Devo effettuare un operazione sul database SQL ovvero cancellare da una tabella un determinato dato. Sto usando questo script:
    //////////////////////////////////////////////////////////////////////////////////////////
    <?php
    $db = mysql_connect('xx..xxx.xxx ', 'User', 'Password') or die('Could not connect: ' . mysql_error());
    mysql_select_db('Sqlxxxxx') or die('Could not select database');

    // Strings must be escaped to prevent SQL injection attack.
    $name = mysql_real_escape_string($_GET['name'], $db);

    $hash = $_GET['hash'];

    $secretKey="xxxxx"; # Change this value to match the value stored in the client javascript below

    $real_hash = md5($name . $secretKey);
    if($real_hash == $hash) {

    $result = mysql_query("DELETE FROM scores WHERE name='$name'");
    or die(mysql_error());

    }
    ?>
    //////////////////////////////////////////////////////

    Sto richiamando questo script da Unity3d. Però quando lo richiamo non avviene nulla all'interno del database! Premettendo che la connessione avviene correttamente, credo che il problema stia nella riga del DELETE... Però non sono sicuro! Grazie in anticipo!

  2. #2
    Utente di HTML.it
    Registrato dal
    Jun 2009
    Messaggi
    27
    su

  3. #3
    Utente di HTML.it
    Registrato dal
    Jun 2009
    Messaggi
    27
    per favore sono bloccato a questo punto

  4. #4
    simona, accertati che $name valga qualcosa

  5. #5
    Utente di HTML.it
    Registrato dal
    Jun 2009
    Messaggi
    27
    ciao Optime la variabile &name dovrebbe essere fornita da questo javascript nella funzione eliminaGiocatore()


    private var secretKey="*****";
    private var inserisciGiocatoreUrl="http://www.*******.com/inserisciGiocatore.php?";
    private var cancellaGiocatoreUrl="http://www.*******.com/cancellaGiocatore.php?";
    var nome:String;

    function Start() {
    yield WaitForSeconds(3);
    var nome :Chat = GameObject.Find("Network").GetComponent("Chat");
    var name:String;
    var score:String;
    name=nome.playerName;
    inviaGiocatore(name);
    name=nome;
    }

    function inviaGiocatore(name) {
    var hash=Md5.Md5Sum(name + secretKey); //questo serve per connettersi agli scripts PHP
    var giocatore_url = inserisciGiocatoreUrl + "name=" + WWW.EscapeURL(name) + "&hash=" + hash;
    hs_post = WWW(giocatore_url);
    yield hs_post;// aspetta la ricezione dei tempi
    if(hs_post.error) {
    print("C'è qualche problema nell'invio dei tempi: " + hs_post.error);
    }
    }

    function eliminaGiocatore(name) {
    var hash=Md5.Md5Sum(name + secretKey); //questo serve per connettersi agli scripts PHP
    var giocatore1_url = cancellaGiocatoreUrl + "name=" + WWW.EscapeURL(name) + "&hash=" + hash;
    hs_post = WWW(giocatore1_url);
    yield hs_post;// aspetta la ricezione dei tempi
    if(hs_post.error) {
    print("C'è qualche problema nell'invio dei tempi: " + hs_post.error);
    }
    }

    function Update(){

    if(Input.GetKeyDown("c")){
    Debug.Log("cancella");
    eliminaGiocatore(nome);
    Debug.Log(nome);
    }
    }

  6. #6
    dovrebbe, appunto. fattela stampare a video prima di lanciare la delete e controlla

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.