Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by prateek1234 · May 02, 2017 at 06:58 PM · phpwebsiteserver-hosting

getting error undefine index in uploading score

i am using this tutorial http://wiki.unity3d.com/index.php?title=Server_Side_Highscores

i am getting an error

Notice: Undefined index: name in addscore.php on line 16

Notice: Undefined index: score in addscore.php on line 16

Notice: Undefined variable: hash inaddscore.php on line 17

this is my pdo script

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image prateek1234 · May 02, 2017 at 07:04 PM 0
Share
     // Configuration
     $hostname = 'localhost';
     $username = 'idprateek';
     $password = '12345';
     $database = 'high';
 
     $secret$$anonymous$$ey = "123546789"; // Change this value to match the value stored in the client javascript below 
 
     try {
         $dbh = new PDO('mysql:host='. $hostname .';dbname='. $database, $username, $password);
     } catch(PDOException $e) {
         echo '<h1>An error has ocurred.</h1><pre>', $e->get$$anonymous$$essage() ,'</pre>';
     }
 
     $realHash = md5($_GET['name'] . $_GET['score'] . $secret$$anonymous$$ey); 
     if($realHash == $hash) { 
         $sth = $dbh->prepare('INSERT INTO scores VALUES (null, :name, :score)');
         try {
             $sth->execute($_GET);
         } catch(Exception $e) {
             echo '<h1>An error has ocurred.</h1><pre>', $e->get$$anonymous$$essage() ,'</pre>';
         }
     } 

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Jawchewa · May 03, 2017 at 01:19 AM

It looks like the error is that you are never defining the variable $hash, and that the indexes for name and score are never set.

Looking at the tutorial, I noticed a line that says, "Please! This code need to be tested. Tested, confirmed not working. Use snippet above. " I would probably recommend trying the first code snippet example, instead of the second one, and seeing where that takes you.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by CurtisGM · Feb 28, 2018 at 11:58 PM

Although this response is quite late, this is for those of you who come to this particular question also looking for an answer.

As Jawchewa mentioned, $hash was never defined as well as the indexes when executing the command. Here is an updated version that I have modified and tested.

 <?php
         // Configuration
         $hostname = 'INSERT_HOSTNAME_HERE';
         $username = 'INSERT_USERNAME_HERE';
         $password = 'INSERT_PASSWORD_HERE';
         $database = 'INSERT_DATABASE_HERE';
  
         $secretKey = "INSERT_SECRET_KEY_HERE"; // Change this value to match the value stored in the client javascript below 
  
         try {
             $dbh = new PDO('mysql:host='. $hostname .';dbname='. $database, $username, $password);
         } catch(PDOException $e) {
             echo '<h1>An error has ocurred.</h1><pre>', $e->getMessage() ,'</pre>';
         }
 
         $username = $_GET['name'];
         $userscore = $_GET['score'];
 
         $realHash = md5($_GET['name'] . $_GET['score'] . $secretKey);
         $hash = $_GET['hash'];
  
         if($realHash == $hash) { 
             $sth = $dbh->prepare('INSERT INTO scores VALUES (null, :username, :userscore)');
             try {
                 $sth->execute(['username' => $username, 'userscore' => $userscore]);
             } catch(Exception $e) {
                 echo '<h1>An error has ocurred.</h1><pre>', $e->getMessage() ,'</pre>';
             }
         } 
 ?>

Hopefully someone finds this useful :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

101 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity Web view error. make a transaction using unity web view payment details and payment page open but response page not open. how to solve this ? 0 Answers

Get Internet Year PHP 0 Answers

error in posting highscore to server 0 Answers

Where can I download Android Build Support 5.3.1f1? 1 Answer

html line break doesn't work in unity? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges