...

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



Henning12342
01-30-2012, 11:55 AM
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;
}

}

?>

abduraooft
01-30-2012, 12:00 PM
$username = $_post('username');
$password = $_post('password');
$login = $_get ('login');

What's that? I think you mean

$username = $_POST['username'];
$password = $_POST['password'];
$login = $_GET ['login'];

Henning12342
01-30-2012, 12:09 PM
nope still same error i have changed the() to [] thanks for that

Henning12342
01-30-2012, 12:11 PM
his is the line it is saying i have the error

$_SESSION('username') = $username;

CompletelyGREEN
01-30-2012, 12:17 PM
its same change () to [] and $_COOKIE('username') this one too:]

abduraooft
01-30-2012, 12:17 PM
Array indexing is done by [ ] and not by ( )

Henning12342
01-30-2012, 12:21 PM
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;
}

}

?>

CompletelyGREEN
01-30-2012, 12:24 PM
<?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;
}

}

?>

abduraooft
01-30-2012, 12:24 PM
Read the friendly manual (http://www.php.net/manual/en/language.variables.superglobals.php) to get the syntax!

Henning12342
01-30-2012, 12:48 PM
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;
}

}

?>

CompletelyGREEN
01-30-2012, 01:01 PM
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:thumbsup:

Henning12342
01-30-2012, 03:21 PM
got it sorted now thanks my code was wrong thanks again



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum