PHP Question
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: PHP Question
ah you are missing your where.....insert into players.......where id=$id ect
Re: PHP Question
feel free to call me spasticated.... but i cannot see it lolSpiritWebb wrote:i did place the include_once, its in the above code, and it still doesnt work.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
New Site Coming Soon! Stay tuned
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: PHP Question
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)hallsofvallhalla wrote:ah you are missing your where.....insert into players.......where id=$id ect
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();
?>
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: PHP Question
see:Torniquet wrote:feel free to call me spasticated.... but i cannot see it lolSpiritWebb wrote:i did place the include_once, its in the above code, and it still doesnt work.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
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
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: PHP Question
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");
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: PHP Question
Ok, I put what you had, and it wouldn't work, so I put this:hallsofvallhalla wrote:no you are missing a player session, but it would look likeCode: Select all
$sql="INSERT INTO players (lastlogin)VALUES('$datetime') where name='$session(player)'"; $result=mysql_query($sql) or die("MySql Error");
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");
Re: PHP Question
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
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
New Site Coming Soon! Stay tuned
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: PHP Question
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();
?>
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: PHP Question
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
or make a variable $player = $_SESSION(player);
there is not 17 lines in your code
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: PHP Question
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();
?>