Page 4 of 5

Re: PHP Question

Posted: Fri Aug 14, 2009 7:52 pm
by hallsofvallhalla
ah you are missing your where.....insert into players.......where id=$id ect

Re: PHP Question

Posted: Fri Aug 14, 2009 8:22 pm
by Torniquet
SpiritWebb wrote:
Torniquet wrote:im pretty sure you need to have the include in there lol. as its trying to access a DB. in halls tut as far as i can remember he is not accessing any DBs.

stick the include in and see if it works :p
i did place the include_once, its in the above code, and it still doesnt work.
feel free to call me spasticated.... but i cannot see it lol

Re: PHP Question

Posted: Fri Aug 14, 2009 9:40 pm
by SpiritWebb
hallsofvallhalla wrote:ah you are missing your where.....insert into players.......where id=$id ect
Ok, so it should look like: (Im at work, so wont be able to test this until tonight, but to make sure I get this right)

Code: Select all

<?php
include_once 'connect.php';
session_start();

$lastlogin=$_POST['lastlogin']

$datetime=date("d/m/y h:i:s");

$SQL="INSERT into players where lastlogin=$lastlogin (lastlogin) VALUE('$datetime');  ///or should i leave this (lastlogin) VALUE('$datetime'); out?///
$result=mysql_query($SQL) or die ("MySql Error");

session_destroy();
?>

Re: PHP Question

Posted: Fri Aug 14, 2009 9:42 pm
by SpiritWebb
Torniquet wrote:
SpiritWebb wrote:
Torniquet wrote:im pretty sure you need to have the include in there lol. as its trying to access a DB. in halls tut as far as i can remember he is not accessing any DBs.

stick the include in and see if it works :p
i did place the include_once, its in the above code, and it still doesnt work.
feel free to call me spasticated.... but i cannot see it lol
see: :P
SpiritWebb wrote:Here is the entire code:

I didnt change nothing with the code that halls provided with the tutorial. Except add the code in between session_start() and session_destroy(). I added the include_once 'connect.php'; command, and now I just get MySql Error

Re: PHP Question

Posted: Fri Aug 14, 2009 11:28 pm
by hallsofvallhalla
no you are missing a player session, but it would look like

Code: Select all

$sql="INSERT INTO players (lastlogin)VALUES('$datetime') where name='$session(player)'";
$result=mysql_query($sql) or die("MySql Error");

Re: PHP Question

Posted: Sat Aug 15, 2009 12:27 am
by SpiritWebb
hallsofvallhalla wrote:no you are missing a player session, but it would look like

Code: Select all

$sql="INSERT INTO players (lastlogin)VALUES('$datetime') where name='$session(player)'";
$result=mysql_query($sql) or die("MySql Error");
Ok, I put what you had, and it wouldn't work, so I put this:

Code: Select all

$SQL="INSERT INTO players (lastlogin)VALUES('$datetime') where name='$lastlogin(player)'";  ///$session had an undefined index in $session///
$result=mysql_query($SQL) or die("MySql Error");
I changed $session to $lastlogin, and now it says undefined index, $lastlogin on line 17. Line 17 is: $lastlogin=$_POST['lastlogin']; Why is it telling me undefined, when it is defined?

Re: PHP Question

Posted: Sat Aug 15, 2009 12:55 am
by Torniquet
im not sure about this... but i think where halls has put $session(player)

its ment to be $_SESSION(player)

repost all your code n we can have a look. because frankly all your different posting as editing without posting a new complete script is confusing :p

Re: PHP Question

Posted: Sat Aug 15, 2009 1:07 am
by SpiritWebb
Torniquet wrote:im not sure about this... but i think where halls has put $session(player)

its ment to be $_SESSION(player)

repost all your code n we can have a look. because frankly all your different posting as editing without posting a new complete script is confusing :p

Code: Select all

<?php
include_once 'connect.php';
  session_start();
  $lastlogin=$_POST['lastlogin'];
  $datetime=date("d/m/y h:i:s");

  $SQL="INSERT INTO players (lastlogin)VALUES('$datetime') where name='$_SESSION(player)'";
  $result=mysql_query($SQL) or die("MySql Error");

  session_destroy();
 
?>
Notice: Undefined index: lastlogin in C:\wamp\www\Mythuto\logout.php on line 17 MySql Error. Line 17 is $lastlogin=$_POST['lastlogin'];

Re: PHP Question

Posted: Sat Aug 15, 2009 1:28 am
by hallsofvallhalla
activate the player session before calling it. My original code will work but you must either make it like $_SESSION(as t suggested)

or make a variable $player = $_SESSION(player);

there is not 17 lines in your code

Re: PHP Question

Posted: Sat Aug 15, 2009 1:49 am
by SpiritWebb
hallsofvallhalla wrote:activate the player session before calling it. My original code will work but you must either make it like $_SESSION(as t suggested)

or make a variable $player = $_SESSION(player);

there is not 17 lines in your code

Code: Select all

<?php
include_once 'connect.php';
  session_start();
  $player=$_SESSION(player);
  $lastlogin=$_POST['lastlogin'];
  $datetime=date("d/m/y h:i:s");

  $SQL="INSERT INTO players (lastlogin)VALUES('$datetime') where name='$_SESSION(player)'";
  $result=mysql_query($SQL) or die("MySql Error");

  session_destroy();

?>
Fatal error: Function name must be a string on line 4