Jump to content

Chaori

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Chaori's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sorry, I just like second opinions on things before I try them... Sorry.
  2. Just did a bit of reading, wouldn't happen to be: $date=date("d/m/y"); $time=date("H:i:s"); Would it?
  3. I know date can be done like: echo date(H) . ":" . (j) . ":" . (s); but how do I assign the current time and date to variables? I know the following code doesn't work, I'm just using it as an example for what I want to do.. $time='(H) . ":" . (i) . ":" . (s)'; $date='(j) . "/" . (m) . "/" . (y)'; If anyone understands what I mean can you tell me how I assign $time and $date? Thanks.
  4. I'm making an online text based game, as many replyers to my topics already know, and I'm having the same problem over and over with my scripts. They do not error, they do exactly what I tell them to do, BUT they do not enter anything into MySQL. I mean if I tell it to update a field it doesn't error, yet the variable isn't put into MySQL. Just wondering if anyone else has encountered this problem and how they managed to resolve it. Thanks.
  5. Unfortunately, it isn't my server so I don't have access to those files. However, I'm sticking session_cache_expire(10); at the start of every page, so that it refreshes when you do something. Now I need to know how to make it set $online to 0 once the session expires.
  6. I'm making a text based MMO, just wondering if there's any way to have a player's session expire after 10 minutes of inactivity? Because my login script sets $online to 1, and my logout sets $online to 0, and i want to make it so if they are inactive for 10 minutes, it sets $online to 0 and it ends their session so the next time they try and move it redirects them to the login screen. Can anyone help me do this?
  7. <html><head><meta http-equiv="Refresh" content="0; URL=http://neverbeast.com/valdellaknights/main.php"></head><body <?php include 'functions.php'; connect(); $latitude = GETWHERE("characters","latitude","account_id","$accid","0"); $longitude = GETWHERE("characters","longitude","account_id","$accid","0"); if($_POST['north']){ $accid = GETWHERE("account","account_id","character_name",$user,"0"); $longitude +=1; mysql_query ("UPDATE characters SET longitude='$longitude' WHERE account_id='$accid'"); } else if($_POST['west']){ $accid = GETWHERE("account","account_id","character_name",$user,"0"); $latitude -=1; mysql_query ("UPDATE characters SET latitude='$latitude' WHERE account_id='$accid'"); } else if($_POST['east']){ $accid = GETWHERE("account","account_id","character_name",$user,"0"); $latitude +=1; mysql_query ("UPDATE characters SET latitude='$latitude' WHERE account_id='$accid'"); } else if($_POST['south']){ $accid = GETWHERE("account","account_id","character_name",$user,"0"); $longitude -=1; mysql_query ("UPDATE characters SET longitude='$longitude' WHERE account_id='$accid'"); } ?> </body> </html> Can you tell me exactly what to change in that? Get's the following error:
  8. One more thing! <?php require 'functions.php'; connect(); $latitude = GETWHERE("characters","latitude","account_id","$accid","0"); $longitude = GETWHERE("characters","longitude","account_id","$accid","0"); if($POST['north']){ $accid = GETWHERE("account","account_id","character_name",$user,"0"); $longitude +=1; mysql_query ("UPDATE characters SET longitude='$longitude' WHERE account_id='$accid'"); } else if($post['west']){ $accid = GETWHERE("account","account_id","character_name",$user,"0"); $latitude -=1; mysql_query ("UPDATE characters SET latitude='$latitude' WHERE account_id='$accid'"); } else if($post['east']){ $accid = GETWHERE("account","account_id","character_name",$user,"0"); $latitude +=1; mysql_query ("UPDATE characters SET latitude='$latitude' WHERE account_id='$accid'"); } else if($post['south']){ $accid = GETWHERE("account","account_id","character_name",$user,"0"); $longitude -=1; mysql_query ("UPDATE characters SET longitude='$longitude' WHERE account_id='$accid'"); } mysql_close($con); header("location: main.php"); ?> Gets the following errors: And functions.php is below: <?php require_once 'config.php'; function Connect(){ global $CONFIG; $con = mysql_connect($CONFIG['server_ip'],$CONFIG['database_user'],$CONFIG['database_password']) or die("Could not connect to MySQL."); $db = mysql_select_db($CONFIG['database']) or die("Could not select database."); } function ADD($table,$field,$value){ mysql_query("INSERT INTO $table ($field) VALUES ('$value')"); } function UPDATE($table,$field,$value){ mysql_query("UPDATE $table SET $field = '$value'"); } function UPDATEWHERE($table,$field,$value,$where,$whereequals){ mysql_query("UPDATE $table SET $field = '$value' WHERE $where = '$whereequals'"); } function GET($table,$field,$row){ $query = mysql_query("SELECT $field FROM $table"); $data = mysql_fetch_row($query); $return = $data[$row]; return $return; } function GETWHERE($table,$field,$where,$whereequals,$row) { $query = mysql_query("SELECT $field FROM $table WHERE $where ='$whereequals'"); $data = mysql_fetch_row($query); $return = $data[$row]; return $return; } ?>
  9. I also have a 'functions.php' which has the following: <?php require_once 'config.php'; function Connect(){ global $CONFIG; $con = mysql_connect($CONFIG['server_ip'],$CONFIG['database_user'],$CONFIG['database_password']) or die("Could not connect to MySQL."); $db = mysql_select_db($CONFIG['database']) or die("Could not select database."); } function ADD($table,$field,$value){ mysql_query("INSERT INTO $table ($field) VALUES ('$value')"); } function UPDATE($table,$field,$value){ mysql_query("UPDATE $table SET $field = '$value'"); } function UPDATEWHERE($table,$field,$value,$where,$whereequals){ mysql_query("UPDATE $table SET $field = '$value' WHERE $where = '$whereequals'"); } function GET($table,$field,$row){ $query = mysql_query("SELECT $field FROM $table"); $data = mysql_fetch_row($query); $return = $data[$row]; return $return; } function GETWHERE($table,$field,$where,$whereequals,$row) { $query = mysql_query("SELECT $field FROM $table WHERE $where ='$whereequals'"); $data = mysql_fetch_row($query); $return = $data[$row]; return $return; } ?>
  10. Okay I've re-done the whole script. Instead of having four different scripts for North, South, East and West, I've simply made a 'travel.php' in which each button redirects to. <?php $con = mysql_connect("beanonym.dot5hostingmysql.com","*****","******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("steve", $con); if($POST['north']){ $accid = GETWHERE("account","account_id","account_name",$user,"0"); mysql_query ("UPDATE characters SET longitude=longitude+1 WHERE account_id='$accid'"); } else if($post['west']){ $accid = GETWHERE("account","account_id","account_name",$user,"0"); mysql_query ("UPDATE characters SET latitude=latitude+1 WHERE account_id='$accid'"); } else if($post['east']){ $accid = GETWHERE("account","account_id","account_name",$user,"0"); mysql_query ("UPDATE characters SET latitude=latitude-1 WHERE account_id='$accid'"); } else if($post['south']){ $accid = GETWHERE("account","account_id","account_name",$user,"0"); mysql_query ("UPDATE characters SET longitude=longitude-1 WHERE account_id='$accid'"); } mysql_close($con); header("location: main.php"); ?> And I'm getting the following error:
  11. My friend has been fiddling around with functions, I'll just ask him when he gets back.
  12. Okay, the final code is below: <?php //Will display all errors ini_set("display_errors",1); error_reporting(E_ALL); //!!!---!!! $con = mysql_connect("beanonym.dot5hostingmysql.com","****","****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($CONFIG['database'], $con); $accid = GETWHERE("account","account_id","account_name",$user,"0"); mysql query ("UPDATE characters SET longitude=longitude+1 WHERE account_id='$accid'"); mysql_close($con); ?> <meta http-equiv="Refresh"; URL=http://neverbeast.com/valdellaknights/main.php"> And the error message is below: edited: Don't post your username / passowrd combinations.
  13. Ahhh I think I know! I need to select the table first don't I?
  14. Okay thanks, I'll set them anyway and test it.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.