-
Posts
178 -
Joined
-
Last visited
Everything posted by Pain
-
1. Say time is 13.40. 2. Say we have a variable $i++; 3. When time is 14.00, increment $i. Get it?:]
-
Oh one more thing. I am trying to increment a variable by using timestamps. <?php $submit = $_POST['submit']; include("connect.php"); echo $date = date("Y-m-d H:i:s"); echo "\n <br />"; if ($submit) { $i++; echo $date2 = date('Y-m-d H:i:s', strtotime("+20 seconds")); mysql_query("UPDATE users2 SET date2 = '$date2'"); $query = mysql_query("SELECT date2 FROM users2"); $numrows = mysql_num_rows($query); if ($numrows != 0) { while ($row = mysql_fetch_array($query)) { $date_final = $row['date2']; } } } if ($date > $date_final) { mysql_query("UPDATE users2 SET slaves = '$i'"); } ?> However it doesn't increment at all. Is it possible to do this with php mysql at all? Or should i try using javascript, something like a countdown timer etc.
-
Jesus Christ now that was kinda retarded of me. Thank you for spotting this error.
-
I get this line: Fatal error: Function name must be a string in /srv/disk4/866075/www/kingstonuni.atspace.co.uk/RPG/muziejus.php on line 18 That's probbably because it is a timestamp, not a string.
-
Hi. I have this code which input data to the database. <?php include("connect.php"); echo $date = date("Y-m-d H:i:s"); echo "\n <br />"; echo $date2 = date('Y-m-d H:i:s', strtotime("+20 seconds")); mysql_query("UPDATE users2 SET date2 = '$date2'"); $query = mysql_query("SELECT date2 FROM users2"); $numrows = mysql_num_rows($query); if ($numrows != 0) { while ($row = $mysql_fetch_array($query)) { $date_final = $row['date2']; } } echo $date_final; ?> Variable date2 is stored as timestamp. Now i want to display this two variable on the web, but this code doesn't work. Why? Thank you.
-
how can i retrieve timestamp from the db?:/
-
Yes i have stored them as timestamps, but now im having some difficulties trying to display them. I guess it's not the same as retrieving INT or VARCHAR?
-
I think you're performing too many steps, something like this should suffice: echo date('Y-m-d h:i:s', strtotime("+20 seconds")); This is what i was searching for! Thank you!
-
Yes i want to put two records into the database. Not sure how to do this. Sorry im really bad at this date and time thing.
-
Looks like that works, but the output is still in this format 1324670946. I need it to be like this: 2011-12-23 20:08:46.
-
Sorry, please ignore this peace of code. <?php ... $hr = 0; $min = 0; $sec = 11; ... ?>
-
Hi guys. I want to make two records. 1)Current time and date. 2)Time and date after 20 seconds. Now i have this piece of code: <?php $hr = 0; $min = 0; $sec = 11; echo $date = date("Y-m-d H:i:s");echo "\n"; echo $modified = time() + (0 * 0 * 0 * 20); ?> I think there is something wrong with this line: <?php echo $modified = time() + (0 * 0 * 0 * 20);1 ?> I get something like this: 1324668576. You can check this http://kingstonuni.atspace.co.uk/RPG/muziejus.php link to get a better view. Any help would be appreciated. Thank you.
-
For some reason doctype removes my css effects (only on IE)
-
Hello again:] I am wondering where should i put valid doctype <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> and meta tags <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> in a php file like this. <?php session_start(); // Session starts here if(!isset($_SESSION['username'])) // If there is no session then... { die ("<div align='center'><img src='images/LOGINKITTEN.jpg'/><br /><a href='index.php'><img src='images/Login.jpg'/></a></div>"); // ...Die! } $id = $_GET['id']; ?> <html> <head> <link rel="stylesheet" type="text/css" href="jamcss.css" /> </head> <body> <img src="images/jamspace.jpg" /> <div id="jamcontainer"> <b><a href="main.php">Home</a> || <a href="members.php">Members</a> || <a href="jams.php">Jams</a> || <a href="uploadjamform.php">Upload Jam</a> || <a href="myprofile.php">My profile</a> || <a href="about.php">About</a> || <a href="adminindex.php">Moderators</a> || <a href="logout.php">Logout</a></b> You are logged in as <?php echo $_SESSION['username']; ?> <br /><br /> <?php $connection = mysql_connect("lol.com", "loldb", "lol00") or die ("Could not connect"); mysql_select_db("loldb", $connection) or die("Could not connect"); // mysql query to get the username $query = mysql_query("SELECT * FROM news ORDER BY id DESC"); $numrows = mysql_num_rows($query); if ($numrows!=0) { // fetching data from the database to variable while ($row = mysql_fetch_assoc($query)) { $title = $row['title']; $post_owner = $row['post_owner']; $post = $row['post']; echo "<b>" . $title . "</b><br />"; echo "Posted by <b>" . $post_owner . "</b><br /><br />"; echo $post . "<hr></hr><br /><br />"; } } ?> </div> </body> </html>
-
Than you! That helped.
-
Hello. I am trying to display info from two tables with this code. <?php $query = mysql_query("SELECT users.username, users2.username FROM users INNER JOIN users2 ON users.id = users2.id"); $numrows = mysql_num_rows($query); if ($numrows != 0) { while ($row = mysql_fetch_assoc($query)) { $username = $row['username']; echo $username . "<br />"; } } ?> However it displays info only from one db (users). I suppose there's something wrong with <?php ... while ($row = mysql_fetch_assoc($query)) { $username = $row['username']; echo $username . "<br />"; } ... ?> Any help will be appreciated. Thank you.
-
Hello. I want to position <div> in the center of the screen and then position left what's inside the div. How can i do that with css? Thank you!
-
i figured this out by myself
-
<?php session_start(); // Session starts here if(!isset($_SESSION['username'])) // If there is no session then... { die ("<div align='center'><img src='images/LOGINKITTEN.jpg'/><br /><a href='index.php'><img src='images/Login.jpg'/></a></div>"); // ...Die! } $usr = $_SESSION['username']; $uniqueid = $_GET['id']; $connection = mysql_connect("localhost", "866075_db", "dbbbb") or die ("Could not connect"); mysql_select_db("866075_db", $connection) or die("Could not connect"); $query = mysql_query("SELECT * FROM users2 WHERE username = '$usr'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { while ($row = mysql_fetch_assoc($query)) { $view_power = $row['power']; $view_speed = $row['speed']; $view_money = $row['money']; $view_user = $row['username']; $usr = $_SESSION['username']; $id2 = $row['id']; $i++; $victories = $row['victorycount']; echo "<br /><br /><b>Personal information</b><br />"; echo $view_user . "<br /><br />"; echo "<b>In Game Stats</b><br />"; echo "Money: " . $view_money . "<br />"; echo "Strength: " . $view_power . "<br />"; echo "Speed: " . $view_speed . "<br />"; echo "Victories: " . $victories . "<br />"; } } ?> Whenever i click on any user, it still displays the info of the user that is logged in
-
Ok so the unique link is set for each user. For instance profile.php?id=3 But how do i display info from DB in the web. There's something wrong with my profile page i suppose.
-
Done that. Still have no idea how to set up this unique link to users profile.
-
<?php session_start(); // Session starts here if(!isset($_SESSION['username'])) // If there is no session then... { die ("<div align='center'><img src='images/LOGINKITTEN.jpg'/><br /><a href='index.php'><img src='images/Login.jpg'/></a></div>"); // ...Die! } $usr = $_SESSION['username']; $view_money = $_SESSION['money']; $id2 = $_SESSION['id']; ?> <html> <head> <link rel="stylesheet" type="text/css" href="css.css" /> </head> <?php $connection = mysql_connect("localhost", "abcdef_db", "abcdef") or die ("Could not connect"); mysql_select_db("abcdef", $connection) or die("Could not connect"); $query = mysql_query("SELECT * FROM users2 WHERE username = '$usr'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { while ($row = mysql_fetch_assoc($query)) { $view_money = $row['money']; $view_speedmain = $row['speed']; $view_powermain = $row['power']; } } echo "<br /><br /><a href='main.php?id=fighters'>Fighters</a> || "; echo "<a href='main.php?id=training'>Training</a> || "; echo "<a href='main.php?id=robform'>Rob Money</a> || "; echo "<a href='main.php?id=buyweapons'>Buy Weapons</a> || "; echo "<a href='main.php?id=profile'>Profile</a> || "; echo "<a href='main.php?id=logout'>Logout</a><br />"; $id = $_GET['id']; if ($id == training) { include("training.php"); } if ($id == fighters) { include("fighters.php"); } if ($id == fight) { include("fight.php"); } if ($id == topstrength) { include("topstrength.php"); } if ($id == topspeed) { include("topspeed.php"); } if ($id == logout) { include("logout.php"); } if ($id == addmoney) { include("addmoney.php"); } if ($id == buyweapons) { include("buyweapons.php"); } if ($id == robform) { include("robform.php"); } if ($id == topmoney) { include("topmoney.php"); } if ($id == topmoney) { include("topmoney.php"); } if ($id == profile) { include("profile.php"); } echo "You are logged in as " . $usr; echo " || Your Balance " . $view_money . "$"; echo " || Strength " . $view_powermain; echo " || Speed " . $view_speedmain; ?> </body> </html>
-
To clarify this: i need to create a unique link for every user, so that other can view the profile.
-
the problem is that there is nothing in on the page when i redirect to id=$id. I suppose i should implement something like automatic page creation for $id?
-
I have this code on my main page $id = $_GET['id']; if ($id == profile) { include("profile.php"); } this allows me to hold everything in my main page, thats why going to main.php?id=profile is generally working, but it doesn't show any user info. main.php?id=$id2 displays the correct ID in the address bar, but when i click the link it says that the page does not exist