nabilfx 0 Denunciar post Postado Setembro 23, 2015 Estou mandando um email para o mysql, ele esta registrando certo no mysql, mas na hora de chamar ele para dar display no Unity através do Gethighscore.php aparece so o que esta na frente da arroba, tipo email (nabil@gmail.com) aparece no display no Unity (gmail.com) Alguém poderia ne dar um help, para conseguir dar o display do email completo. Aqui esta os scripts Serverconect.php <?php $secretKey = 'test'; //Set your secret key, must match same secret in Highscore script $hostName = 'mysql6.000webhost.com'; //Set your database hostname $userName = 'a9838040_mira'; //Set your database user name $password = 'MODERADO'; //Set your databse password $database = 'a9838040_mira'; //Set your actual database name function Connect(){ //Set global variables so they can be used in this function global $hostName; global $userName; global $password; global $database; $status = mysql_connect($hostName,$userName,$password); //Attempt to connect to Database if(!$status){echo 'Server Not Found'; exit;} //Hosting Server not found if(!@mysql_select_db($database)){echo 'Database Not Found'; exit;} //Database not found return $status; //Return link on established connection } function CheckKey($hash,$name){ //Check weather Md5 hash matches global $secretKey; $checkHash = md5($name.$secretKey); if(strcmp($checkHash,$hash) == 0){ return 'pass'; //hash matches }else{ return 'fail'; //hash failed } } function CleanInput($input){ //Sanitize user input $cleanInput = mysql_real_escape_string($input); //Use string escape if(preg_match('/[^@.a-z_\-0-9\s]/i',$cleanInput) == 1){ // Using regular expression echo 'Bad Input ==> ' . $input; exit; //Failed, exit to prevemt sql injection hacks } return $cleanInput; //Return clean input } ?> SendHighScore.php <?php include('ServerConnect.php'); $connection = Connect(); //Attempt to Connect to MYSQL Server & DataBase //Get variables from Unity $table = $_POST['table']; $name = $_POST['name']; $score = $_POST['score']; $updating = $_POST['updating']; $date = strtotime(date("Y-m-d")); //Get Time //Security Check $hash = $_POST['hash']; if(CheckKey($hash,$name) == 'fail'){ //Check if hash is valid echo 'Security Failure'; exit; } //Make sure all input is sql injection safe $name = CleanInput($name); $table = CleanInput($table); $score = CleanInput($score); $updating = CleanInput($updating); //Run Query (inser or update) if($updating == 0){ //Free entry So make new row $sql = "INSERT INTO $table (name,score,date) VALUES('$name','$score','$date')"; }else{ //We are updating a previously registered user $sql = "UPDATE $table SET score = '$score', date = '$date' WHERE name = '$name'"; } $result = mysql_query($sql) or Die('Query failed: ' . mysql_error()); //Now update our table, by ordering it by descending score $sql = "ALTER TABLE $table ORDER BY score DESC,id DESC"; $result = mysql_query($sql) or Die('Query failed: ' . mysql_error()); echo 'Accepted'; ?> GetHighScore.php <?php include('ServerConnect.php'); $connection = Connect();//Attempt to Connect to MYSQL Server & DataBase //Get variables from unity $table = $_POST['table']; $scope = $_POST['scope']; $limit = $_POST['limit']; //Security Check $hash = $_POST['hash']; if(CheckKey($hash,$table) == 'fail'){ //Check if hash is valid echo 'Security Failure'; exit; } //Make sure all input is sql injection safe $table = CleanInput($table); $scope = CleanInput($scope); $limit = CleanInput($limit); //Create a Query For The Right Table if($scope == 'AllTime'){ //Get All scores $sql = "SELECT * FROM $table LIMIT 0,$limit"; }else{ //Get scores posted today $date = strtotime(date("Y-m-d")); //Today's date $sql = "SELECT * FROM $table WHERE date = '$date' LIMIT 0,$limit"; } $result = mysql_query($sql) or Die('Query failed: ' . mysql_error()); //1.Build a string of all scores to send back $info = ""; while($found = mysql_fetch_array($result)){ $info = $info .'@'. $found['name'] .':'. $found['score']; } echo $info; ?> Compartilhar este post Link para o post Compartilhar em outros sites
LandersonAlmeida 31 Denunciar post Postado Setembro 24, 2015 Deve ser aqui :unsure:: $info = ""; while($found = mysql_fetch_array($result)): $infos = $info .'@'. $found['name'] .':'. $found['score']; endwhile; echo $infos; Lembrando que dentro deste while vc ta falando que a várivavel info vai ser igual a ela mesma concatenada com outras vars, só que a $info é null, como definido: ' $info = "" ', verifique isto também Compartilhar este post Link para o post Compartilhar em outros sites