PHP Question

C++, C#, Java, PHP, ect...
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: PHP Question

Post by Torniquet »

Code: Select all

$SQL="INSERT INTO players (lastlogin)VALUES('$datetime') WHERE name='$player'";
are you accually setting the $_POST variable?
New Site Coming Soon! Stay tuned :D
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: PHP Question

Post by hallsofvallhalla »

Code: Select all

 $player=$_SESSION('player');
notice the '
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: PHP Question

Post by SpiritWebb »

hallsofvallhalla wrote:

Code: Select all

 $player=$_SESSION('player');
notice the '
I placed the ' in (player), and I still get: Fatal error: Function name must be a string in C:\wamp\www\Mythuto\logout.php on line 4. See code below:

Code: Select all

<?php
include_once 'connect.php';
  session_start();
  $player=$_SESSION('player');

  $lastlogin=$_POST['lastlogin'];
  $datetime=date("d/m/y");

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

  session_destroy();

?>
Image

Image
Falken
Posts: 438
Joined: Fri May 08, 2009 8:03 pm

Re: PHP Question

Post by Falken »

hallsofvallhalla wrote:

Code: Select all

 $player=$_SESSION('player');
notice the '
Should be:

Code: Select all

$player=$_SESSION['player'];
If you use ( instead of [ it thinks "$_SESSION" is a function, and functions can't start with $, thats why you get the function name is not a string error.
--- Game Database ---
For all your game information needs!
Visit us at: http://www.gamedatabase.eu today!
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: PHP Question

Post by SpiritWebb »

Nice, thanks Falken, granted I have moved on...decided to go with programming the game in flash, and using PHP in the background!! But thanks for that, i will keep that in mind!!
Image

Image
Post Reply

Return to “Coding”