justinba1010 Posted August 1, 2011 Share Posted August 1, 2011 Have been confused for a while on this one. I am doing a little mini game as I want to make a game for me and my friends. So what I did was make a login and register. <?php if (isset($_POST['faction'])) { $faction = $_POST['faction']; if ($_POST['username']&&$_POST['password']&&$_POST['email']) { $username = $_POST['username']; $username = stripslashes($username); $username = mysql_escape_string($username); $password = $_POST['password']; $password = stripslashes($password); $password = mysql_escape_string($password); $password = md5($password); $email = $_POST['email']; $email = stripslashes($email); $email = mysql_escape_string($email); mysql_connect("localhost","root",""); mysql_select_db("game"); $query = mysql_query("SELECT * FROM login WHERE username = '$username'"); $num = mysql_num_rows($query); if( $num == 0) { $query = mysql_query("INSERT INTO login(username,password,faction,email) VALUES('$username','$password','$faction','$email')"); } else { echo "That username is already taken."; exit(); } } else { echo "You are missing a required field."; exit(); } } else { echo "You haven't selected a faction."; exit(); } $query = mysql_query("SELECT * FROM map WHERE uid='0' AND type='0' ORDER BY vid ASC LIMIT 0,1"); while($row = mysql_fetch_assoc($query)); { $dbx = $row['x']; $dby = $row['y']; echo $dbx.$dby; } ?> It happens that the error is on line Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /opt/lampp/htdocs/game/registrationbackbone.php on line 45 Have been stumped on why. Quote Link to comment https://forums.phpfreaks.com/topic/243432-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource-boolean-given-i/ Share on other sites More sharing options...
Pikachu2000 Posted August 1, 2011 Share Posted August 1, 2011 Your query is failing and returning a boolean FALSE to mysql_fetch_assoc(). What happens if you paste the query string into phpMyAdmin? You should also incorporate logic to make sure the query executed without error. Quote Link to comment https://forums.phpfreaks.com/topic/243432-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource-boolean-given-i/#findComment-1250034 Share on other sites More sharing options...
justinba1010 Posted August 1, 2011 Author Share Posted August 1, 2011 Your query is failing and returning a boolean FALSE to mysql_fetch_assoc(). What happens if you paste the query string into phpMyAdmin? You should also incorporate logic to make sure the query executed without error. So if I run that query through phpmyadmin it should give me what was wrong or what? As I don't know MySQL greatly as its new to me. I'll try that and keep you informed. Quote Link to comment https://forums.phpfreaks.com/topic/243432-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource-boolean-given-i/#findComment-1250043 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.