jamesyrawr Posted September 28, 2010 Share Posted September 28, 2010 Hi I get the following error when running this file. Fatal error: Call to undefined function mysqql_query() in C:\wamp\www\Isis\login.php on line 14] I'm not sure if i have missed something or typed something wrong but a second opinion is always better <?php $username = $_POST['username']; $password = $_POST['password']; $login = $_GET['login']; setcookie("username", "$username", time()+86400); if ($login=='yes') { $con = mysql_connect("localhost","root",""); mysql_select_db("obsosuser"); $get = mysqql_query("SELECT count(id) FROM obsosuser WHERE username='$username' and password='$password'"); if ($result!=1){ echo "Invalid Login!"; } else echo "Login Successful! Welcome back ".$_COOKIE['username']." Sir/Maddam." ; $_SESSION ['username'] = $username; } ?> Thanks Quote Link to comment https://forums.phpfreaks.com/topic/214578-student-help-needed-please/ Share on other sites More sharing options...
gizmola Posted September 28, 2010 Share Posted September 28, 2010 yeah well the function is named mysql_query() not mysqql_query. Quote Link to comment https://forums.phpfreaks.com/topic/214578-student-help-needed-please/#findComment-1116552 Share on other sites More sharing options...
jamesyrawr Posted September 28, 2010 Author Share Posted September 28, 2010 Thanks knew i had missed something although i'm getting another error message Warning: mysql_result() expects parameter 1 to be resource, boolean given in C:\wamp\www\Isis\login.php on line 16 <?php $username = $_POST['username']; $password = $_POST['password']; $login = $_GET['login']; setcookie("username", "$username", time()+86400); if ($login=='yes') { $con = mysql_connect("localhost","root",""); mysql_select_db("obsosuser"); $get = mysql_query("SELECT count(id) FROM obsosuser WHERE username='$username' and password='$password'"); $result = mysql_result($get, 0); if ($result!=1){ echo "Invalid Login!"; } else echo "Login Successful! Welcome back ".$_COOKIE['username']." Sir/Maddam." ; $_SESSION ['username'] = $username; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/214578-student-help-needed-please/#findComment-1116554 Share on other sites More sharing options...
pengu Posted September 28, 2010 Share Posted September 28, 2010 Change. $result = mysql_result($get, 0); To. $result = mysql_result($get, $con); Quote Link to comment https://forums.phpfreaks.com/topic/214578-student-help-needed-please/#findComment-1116555 Share on other sites More sharing options...
jamesyrawr Posted September 28, 2010 Author Share Posted September 28, 2010 Thanks Pengu, but i tried your change and i still got the same result: Warning: mysql_result() expects parameter 1 to be resource, boolean given in C:\wamp\www\Isis\login.php on line 16 Quote Link to comment https://forums.phpfreaks.com/topic/214578-student-help-needed-please/#findComment-1116556 Share on other sites More sharing options...
PFMaBiSmAd Posted September 28, 2010 Share Posted September 28, 2010 The defintion of mysql_result() - string mysql_result ( resource $result , int $row [, mixed $field = 0 ] ) Assuming that the code you posted is the code producing the error, it means that your query failed due to an error and returned a FALSE value. For debugging purposes, echo mysql_error(); on the next line after the line with your mysql_query() statement, it will tell you why the query failed. Quote Link to comment https://forums.phpfreaks.com/topic/214578-student-help-needed-please/#findComment-1116558 Share on other sites More sharing options...
jamesyrawr Posted September 28, 2010 Author Share Posted September 28, 2010 Was database issues :-\ its all sorted now but i changed $result = mysql_result($get, $con); back too $result = mysql_result($get, 0); and it seems to be working again Thanks Quote Link to comment https://forums.phpfreaks.com/topic/214578-student-help-needed-please/#findComment-1116562 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.