koopz Posted July 9, 2007 Share Posted July 9, 2007 I was just wondering if these scripts were right? LOGIN SCRIPT <?php mysql_connect("localhost","username","password") or die(); mysql_select_db("koopz_orthlint") or die(); $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(); $check2 = mysql_num_rows($check); if ($check2 == 0) { print "words=User doesn't exist.&checklog=3"; die(); } while($info = mysql_fetch_array( $check )) { if ($_POST['pass'] != $info['password']) { print "words=Incorrect Password.&checklog=4"; die(); }else { print "words=You are logged in.&checklog=5"; die(); } } ?> REGISTER SCRIPT <?php mysql_connect("localhost","username","password") or die(); mysql_select_db("koopz_orthlint") or die(); $usercheck = $_POST['username']; $check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") or die(); $check2 = mysql_num_rows($check); if ($check2 != 0) { print "words=Username already exists.&checklog=1"; die(); } $insert = "INSERT INTO users (username, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')"; $add_member = mysql_query($insert); print "words=You are registered.&checklog=2"; die(); ?> any help would be appreciated Link to comment https://forums.phpfreaks.com/topic/59075-can-someone-please-help-php-script-inside/ Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 First, surround code with [code] and [/code] tags to make it easier to read. Are you getting any error messages? If you are, show that line and the line before it. Link to comment https://forums.phpfreaks.com/topic/59075-can-someone-please-help-php-script-inside/#findComment-293267 Share on other sites More sharing options...
koopz Posted July 9, 2007 Author Share Posted July 9, 2007 theres is no errors i think. (php isnt on my comp but im learning basics) and i was trying to make a login system with flash http://koopz.quotaless.com/66.swf thats all i get. it has worked before just i changed some stuff to get bugs out and now it wont work. Link to comment https://forums.phpfreaks.com/topic/59075-can-someone-please-help-php-script-inside/#findComment-293270 Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 I'm sorry I have no idea when it comes to using flash as I've never used it - maybe someone else can help? If you want to learn PHP on your computer you can download WAMP and install that. It'll turn your computer into a local server where you can test PHP scripts without having to uploaded them to a remote server. Link to comment https://forums.phpfreaks.com/topic/59075-can-someone-please-help-php-script-inside/#findComment-293273 Share on other sites More sharing options...
koopz Posted July 10, 2007 Author Share Posted July 10, 2007 ive fixed a bit of the code and i now know where the error lies $check2 = mysql_num_rows($check) or die("error4"); can anyone tell me whats wrong with that? Link to comment https://forums.phpfreaks.com/topic/59075-can-someone-please-help-php-script-inside/#findComment-294034 Share on other sites More sharing options...
trq Posted July 10, 2007 Share Posted July 10, 2007 can anyone tell me whats wrong with that? Nothing. But $check may not hold a valid resource if your query failed. Post more code. Link to comment https://forums.phpfreaks.com/topic/59075-can-someone-please-help-php-script-inside/#findComment-294036 Share on other sites More sharing options...
koopz Posted July 10, 2007 Author Share Posted July 10, 2007 heres the whole code <?php mysql_connect("localhost","username","password") or die("error1"); mysql_select_db("dbname") or die("error2"); $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die("error3"); $check2 = mysql_num_rows($check) or die("error4"); if ($check2 == 0) { print "words=User doesn't exist.&checklog=3"; die("error5"); } while($info = mysql_fetch_array( $check ) or die("error6")) { if ($_POST['pass'] != $info['password']) { print "words=Incorrect Password.&checklog=4"; die("error7"); }else { print "words=You are logged in.&checklog=5"; die("error8"); } } ?> Link to comment https://forums.phpfreaks.com/topic/59075-can-someone-please-help-php-script-inside/#findComment-294047 Share on other sites More sharing options...
AndyB Posted July 10, 2007 Share Posted July 10, 2007 $check2 = mysql_num_rows($check) or die("error4"); $check is a RESOURCE not a query string (which is what the num_rows function requires) Link to comment https://forums.phpfreaks.com/topic/59075-can-someone-please-help-php-script-inside/#findComment-294052 Share on other sites More sharing options...
trq Posted July 10, 2007 Share Posted July 10, 2007 $check is a RESOURCE not a query string (which is what the num_rows function requires) Sorry Andy, but (as I'm sure your aware) mysql_num_rows() expects a resource. I see nothing wrong with the above code (besides poor formatting). What are you expecting and what are you actually getting? Link to comment https://forums.phpfreaks.com/topic/59075-can-someone-please-help-php-script-inside/#findComment-294053 Share on other sites More sharing options...
koopz Posted July 10, 2007 Author Share Posted July 10, 2007 i am expecting to log me into a flash system Link to comment https://forums.phpfreaks.com/topic/59075-can-someone-please-help-php-script-inside/#findComment-294118 Share on other sites More sharing options...
AndyB Posted July 10, 2007 Share Posted July 10, 2007 Sorry Andy, but (as I'm sure your aware) mysql_num_rows() expects a resource. um, I'm old, I'm tired, I'm caffeine-deficient, I'm sorry. Link to comment https://forums.phpfreaks.com/topic/59075-can-someone-please-help-php-script-inside/#findComment-294189 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.