Jump to content

Uncaught ReferenceError loading from mysql database


rauldv
 Share

Recommended Posts

 I'm trying to make a game for a fixed number of people. In the beginning i would get there names out of a mysql database. Then they can select there name and play. So there score is saved by there name.

 

So i have a php file where i generate a combobox with the list of people in. But when i change the selected name, i will catch that name in my javascript file. but everytime i get this error: Uncaught ReferenceError: showUser is not defined

 
Does somebody know what i am doing wrong here?
game.module(    'game.main').body(function() {game.addAsset('logo.png');SceneGame = game.Scene.extend({    backgroundColor: 0xb9bec7,    init: function() {    	var div = document.createElement("div");		div.style.width = "500px";		div.style.height = "500px";		div.style.background = "red";		div.style.color = "blue";		document.body.appendChild(div);    	if (window.XMLHttpRequest) {		    // code for IE7+, Firefox, Chrome, Opera, Safari			xmlhttp=new XMLHttpRequest();		} 		else {  // code for IE6, IE5		  	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");		}		xmlhttp.onreadystatechange=function() {		   	if (xmlhttp.readyState==4 && xmlhttp.status==200) {		   		div.innerHTML=xmlhttp.responseText;		   	}		}		xmlhttp.open("GET","/test/src/php/test.php",true)		xmlhttp.send();    },    showUser: function(stre){    	console.log(stre);    }});game.start();});
<?php$con=mysqli_connect("myhost","myuser","mypassw","mybd");if (mysqli_connect_errno()) {  echo "Failed to connect to MySQL: " . mysqli_connect_error();}$result = mysqli_query($con,"SELECT * FROM highscore");   echo '<select name="drop_2" id="drop_2" onchange="showUser()">           <option value=" " selected="selected">Choose one</option>';while($row = mysqli_fetch_array($result)) {   echo '<option value="'.$row['groupId'].'">'.$row['group'].'</option>'; } echo '</select>'; mysqli_close($con);?>
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...