big-dog1965 Posted March 7, 2009 Share Posted March 7, 2009 Can someone show me what is wrong here line 15 is $result = mysql_query("Select * From login_table where user_name='$username'; Parse error: syntax error, unexpected ')' in /home/public_html/App/Admin/login.php on line 15 if (isset($_POST['Submit'])) { $username = $_POST['username']; $password = md5($_POST[password]); mysql_connect($dbServer, $dbUsername, $dbPassword)){ $result = mysql_query("Select * From login_table where user_name='$username'; if(mysql_num_rows($result)>0) { $row = mysql_fetch_array($result, MYSQL_BOTH); if($password == $row["user_pass"]) { $_SESSION['loginok'] = "ok"; $_SESSION['username'] = "username"; $_SESSION['password'] = "password"; $_SESSION['level'] = $row["user_level"]; Quote Link to comment https://forums.phpfreaks.com/topic/148329-sql-connection-and-select-error/ Share on other sites More sharing options...
corbin Posted March 7, 2009 Share Posted March 7, 2009 mysql_query("Select * From login_table where user_name='$username'; Should be mysql_query("Select * From login_table where user_name='$username'"); And mysql_connect($dbServer, $dbUsername, $dbPassword)){ That's not valid syntax. Quote Link to comment https://forums.phpfreaks.com/topic/148329-sql-connection-and-select-error/#findComment-778736 Share on other sites More sharing options...
big-dog1965 Posted March 7, 2009 Author Share Posted March 7, 2009 What should it be mysql_connect($dbServer, $dbUsername, $dbPassword)){ Quote Link to comment https://forums.phpfreaks.com/topic/148329-sql-connection-and-select-error/#findComment-778749 Share on other sites More sharing options...
Philip Posted March 7, 2009 Share Posted March 7, 2009 $link = mysql_connect($host, $user, '$password); no { needed, just a ; Quote Link to comment https://forums.phpfreaks.com/topic/148329-sql-connection-and-select-error/#findComment-778754 Share on other sites More sharing options...
big-dog1965 Posted March 7, 2009 Author Share Posted March 7, 2009 seems thats fix but now I get this Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/public_html/App/Admin/login.php on line 18 ***if(mysql_num_rows($result)>0) if (isset($_POST['Submit'])) { $username = $_POST['username']; $password = md5($_POST[password]); mysql_connect($dbServer, $dbUsername, $dbPassword); $result = mysql_query("Select * From login_table where user_name='$username'"); if(mysql_num_rows($result)>0) { $row = mysql_fetch_array($result, MYSQL_BOTH); if($password == $row["user_pass"]) { $_SESSION['loginok'] = "ok"; $_SESSION['username'] = "username"; $_SESSION['password'] = "password"; $_SESSION['level'] = $row["user_level"]; Quote Link to comment https://forums.phpfreaks.com/topic/148329-sql-connection-and-select-error/#findComment-778773 Share on other sites More sharing options...
Luodeni Posted March 7, 2009 Share Posted March 7, 2009 seems thats fix but now I get this Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/public_html/App/Admin/login.php on line 18 ***if(mysql_num_rows($result)>0) if (isset($_POST['Submit'])) { $username = $_POST['username']; $password = md5($_POST[password]); mysql_connect($dbServer, $dbUsername, $dbPassword); $result = mysql_query("Select * From login_table where user_name='$username'"); if(mysql_num_rows($result)>0) { $row = mysql_fetch_array($result, MYSQL_BOTH); if($password == $row["user_pass"]) { $_SESSION['loginok'] = "ok"; $_SESSION['username'] = "username"; $_SESSION['password'] = "password"; $_SESSION['level'] = $row["user_level"]; if(mysql_num_rows($result)>0) since it's for a user try this: if ( mysql_num_rows ($result) == 1 ) OR if ( mysql_num_rows ($result) != 0 ) Quote Link to comment https://forums.phpfreaks.com/topic/148329-sql-connection-and-select-error/#findComment-778788 Share on other sites More sharing options...
sasa Posted March 7, 2009 Share Posted March 7, 2009 change $result = mysql_query("Select * From login_table where user_name='$username'"); to $result = mysql_query("Select * From login_table where user_name='$username'") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/148329-sql-connection-and-select-error/#findComment-778796 Share on other sites More sharing options...
alphanumetrix Posted March 7, 2009 Share Posted March 7, 2009 The problem is simple. You forgot to close it. This will work: $result = mysql_query("Select * From login_table where user_name='$username'"); You forgot to finish the statement with "); instead, you just inded it with '; Quote Link to comment https://forums.phpfreaks.com/topic/148329-sql-connection-and-select-error/#findComment-778843 Share on other sites More sharing options...
big-dog1965 Posted March 7, 2009 Author Share Posted March 7, 2009 change $result = mysql_query("Select * From login_table where user_name='$username'"); to $result = mysql_query("Select * From login_table where user_name='$username'") or die(mysql_error()); I get error could not select database. so from the above code I added mysql_connect($dbServer, $dbUsername, $dbPassword, $dbDatabase); but still didnt work Quote Link to comment https://forums.phpfreaks.com/topic/148329-sql-connection-and-select-error/#findComment-778938 Share on other sites More sharing options...
redarrow Posted March 7, 2009 Share Posted March 7, 2009 try a diffrent database connection code as your's is all flash. <?php $db=mysql_connect("localhost","username","password"); $res=mysql_select_db("database_name",$db)or die('database connection error'.mysql_error()); ?> You was crawling before walking when you grow up, i guess. Never go above your head, unless you no what your doing. Quote Link to comment https://forums.phpfreaks.com/topic/148329-sql-connection-and-select-error/#findComment-778956 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.