Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New Coder
    Join Date
    Jan 2012
    Posts
    19
    Thanks
    3
    Thanked 0 Times in 0 Posts

    hey guys i keep getting an error Fatal error: Can't use function return value in writ

    i dont know what im doing wrong ill post code now hopefully i can get this sorted

    error code is Fatal error: Can't use function return value in write context in E:\xampp\htdocs\login.php on line 23


    <?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('login');

    $get =mysql_query("SELECT count (id) FROM login WHERE user='$username' and pass='$password'");

    $resault = mysql_result($get,0);

    if($result!=1) {
    echo "Invalid login.";
    } else {
    echo "login Successful. Welcome back" .$_COOKIE('username') . "sir/madam.";
    $_SESSION('username') = $username;
    }

    }

    ?>
    Last edited by Henning12342; 01-30-2012 at 10:58 AM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    $username = $_post('username');
    $password = $_post('password');
    $login = $_get ('login');
    What's that? I think you mean
    Code:
    $username = $_POST['username'];
    $password = $_POST['password'];
    $login = $_GET ['login'];
    Last edited by abduraooft; 01-30-2012 at 11:25 AM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Jan 2012
    Posts
    19
    Thanks
    3
    Thanked 0 Times in 0 Posts
    nope still same error i have changed the() to [] thanks for that

  • #4
    New Coder
    Join Date
    Jan 2012
    Posts
    19
    Thanks
    3
    Thanked 0 Times in 0 Posts
    his is the line it is saying i have the error

    $_SESSION('username') = $username;

  • #5
    New Coder
    Join Date
    Jan 2012
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post
    its same change () to [] and $_COOKIE('username') this one too:]
    Last edited by CompletelyGREEN; 01-30-2012 at 11:20 AM.

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Array indexing is done by [ ] and not by ( )
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #7
    New Coder
    Join Date
    Jan 2012
    Posts
    19
    Thanks
    3
    Thanked 0 Times in 0 Posts
    dont that now i get this message


    Notice: Undefined variable: _post in E:\xampp\htdocs\login.php on line 3

    Notice: Undefined variable: _post in E:\xampp\htdocs\login.php on line 4

    Notice: Undefined variable: _get in E:\xampp\htdocs\login.php on line 5

    new code is this

    <?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('login');

    $get =mysql_query("SELECT count (id) FROM login WHERE user='$username' and pass='$password'");

    $resault = mysql_result($get,0);

    if($result!=1) {
    echo "Invalid login.";
    } else {
    echo "login Successful. Welcome back" .$_COOKIE['username'] . "sir/madam.";
    $_SESSION ['username'] = $username;
    }

    }

    ?>

  • #8
    New Coder
    Join Date
    Jan 2012
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post
    <?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('login');

    $get =mysql_query("SELECT count (id) FROM login WHERE user='$username' and pass='$password'");

    $resault = mysql_result($get,0);

    if($result!=1) {
    echo "Invalid login.";
    } else {
    echo "login Successful. Welcome back" .$_COOKIE['username'] . "sir/madam.";
    $_SESSION['username'] = $username;
    }

    }

    ?>

  • #9
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Read the friendly manual to get the syntax!
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    Henning12342 (01-30-2012)

  • #10
    New Coder
    Join Date
    Jan 2012
    Posts
    19
    Thanks
    3
    Thanked 0 Times in 0 Posts
    now im getting another error and i dont know what to do ive checked google and the error is


    Warning: mysql_result() expects at least 2 parameters, 1 given in E:\xampp\htdocs\login.php on line 17

    Notice: Undefined variable: result in E:\xampp\htdocs\login.php on line 19
    Invalid login.

    usinghis code

    <?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('login');

    $get =mysql_query("SELECT count (id) FROM login WHERE user='$username' and pass='$password'");

    $resault = mysql_result($get,0);

    if($result!=1) {
    echo "Invalid login.";
    } else {
    echo "login Successful. Welcome back" .$_COOKIE['username'] . "sir/madam.";
    $_SESSION['username'] = $username;
    }

    }

    ?>

  • #11
    New Coder
    Join Date
    Jan 2012
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Henning12342 View Post
    now im getting another error and i dont know what to do ive checked google and the error is


    Warning: mysql_result() expects at least 2 parameters, 1 given in E:\xampp\htdocs\login.php on line 17

    Notice: Undefined variable: result in E:\xampp\htdocs\login.php on line 19
    Invalid login.

    usinghis code

    <?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('login');

    $get =mysql_query("SELECT count (id) FROM login WHERE user='$username' and pass='$password'");

    $resault = mysql_result($get,0);

    if($result!=1) {
    echo "Invalid login.";
    } else {
    echo "login Successful. Welcome back" .$_COOKIE['username'] . "sir/madam.";
    $_SESSION['username'] = $username;
    }

    }

    ?>
    1)
    count (id)??
    --
    what do you select?


    2)
    $resault = mysql_result($get,0);

    if($result!=1) {



    open your eyes
    Last edited by CompletelyGREEN; 01-30-2012 at 12:04 PM.

  • Users who have thanked CompletelyGREEN for this post:

    Henning12342 (01-30-2012)

  • #12
    New Coder
    Join Date
    Jan 2012
    Posts
    19
    Thanks
    3
    Thanked 0 Times in 0 Posts
    got it sorted now thanks my code was wrong thanks again


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •