Yesterday I started working on my custom FlyFF website, which is still totally under work. I've got the skin 100% ready, but I am still missing the scripts.
So, I would like to know what is wrong in my registeration script.
So this is how it looks at the moment.Code:<?php include("ylaosa.php") ?> <h1>Register</h1> <?php if(isset($_POST['reg_user']) && isset($_POST['reg_password']) && isset($_POST['reg_check'])){ $text = ""; $tunnus = get_magic_quotes_gpc() ? $_POST['reg_user'] : mysql_real_escape_string($_POST['reg_user']); $salasana = get_magic_quotes_gpc() ? $_POST['reg_password'] : mysql_real_escape_string($_POST ['reg_password']); $varmistus = get_magic_quotes_gpc() ? $_POST['reg_check'] : mysql_real_escape_string($_POST ['reg_check']); $sql = mysql_query("SELECT COUNT(*) AS yht FROM {$tbl_accounts} WHERE username = '".$username."'",$lnk); $sql = mysql_fetch_assoc($sql); $yht = $sql['yht']; if($yht != 0) $text .= "This username is in use.<br />\n"; if(strlen($username) < 3) $text .= "Username is too short. Minimum leght is 3 characters.<br />\n"; if(strlen($password) < 3) $text .= "Password is too short. Minimum leght is 3 characters.<br />\n"; if($password != $check) $text .= "Passwords did not match.<br />\n"; if($text == ""){ $sql = mysql_query("INSERT INTO {$tbl_accounts} (username,password) VALUES ('".$username."','".md5 ($password)."')",$lnk); if(!$sql || mysql_affected_rows($lnk) < 1) $text = "SQL-lauseessa virhe.<br />\n"; else $text = "Registeration succesful!<br />"; } echo $text; } ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <table width="0%" border="0"> <tr> <td>Username:</td> <td><input name="reg_user" type="text" size="15" maxlength="20" value="<?php echo isset($_POST['reg_user']) ? $_POST['reg_user'] : ""; ?>" /></td> </tr> <tr> <td>Password:</td> <td><input name="reg_password" type="password" size="15" maxlength="20" /></td> </tr> <tr> <td>Password:</td> <td><input name="reg_check" type="password" size="15" maxlength="20" /></td> </tr> <tr> <td colspan="2"><input type="submit" value="Register" /></td> </tr> </table> </form> <a href="index.php">Home</a> <?php include("alaosa.php") ?>
When I try to use it, I get warning message:
"Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in register.php on line 13"
I dont know why it gives warning about line 13, when the line 13 is empty.
Anyone know how can I fix this and get it ready to be in use?




