Jump to content

redgunner2

New Members
  • Posts

    7
  • Joined

  • Last visited

redgunner2's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Already have that session_start - I posted a snippet not my full code... I'm sure you are quite helpful and knowledgeable but from a new member on the forum it seems difficult to see...
  2. You can't judge that I haven't learnt anything based on me asking for help? I wanted feedback on how others would achieve this so i can compare as I am writing a script to counter XSS for a project, please do not post sarcastic comments to people looking help - After all this is a help forum and not a look down your nose forum.
  3. I got this working on my own and would be too complex to explain when I only posted a snippet... Again thanks for your positive comment.
  4. Hello, I am learning PHP and have been trying to work out what I need to do to display information on a members page. // Create connection $mysqli = new mysqli('localhost', 'db', 'db', 'db'); // Check connection if ($mysqli->connect_error) { die("Connection failed: " . $mysqli->connect_error); } $getID = $_SESSION['user_id']; $sql = "SELECT * from users WHERE id = ($getID)"; // What needs to go here? So for example I have a column with firstname which I would like to print back to the user Any help would be appreciative...
  5. Thanks to all - i got this working now
  6. Hello, I would appreciative of any help so I can fix my logout script - I have been spent hours trying work out different things and I need help of possible!! logout.php $mysqli = new mysqli('localhost', 'db', 'db', 'db'); # check connection if ($mysqli->connect_errno) { echo "<p>MySQL error no {$mysqli->connect_errno} : {$mysqli->connect_error}</p>"; exit(); } // update status to offline $sql = "SELECT status from users WHERE id={$_SESSION['username']}"; $result = $mysqli->query($sql); $user = $result->fetch_array(); $timestamp = $user['status'] - 300; $sql = "UPDATE users SET status={$timestamp} WHERE id={$_SESSION['username']}"; $result = $mysqli->query($sql); ## finally destroying the session // unset all session variables $_SESSION = array(); // destroy the session cookie if(isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time()-50000, '/'); } // destroy the session session_destroy(); redirect_to("login.php"); ?> I get the following error - Fatal error: Call to a member function fetch_array() on a non-object in /home/www/site/logout.php on line 17 I think what is happening is $user = $result->fetch_array(); returning no information but I am able to display the value of my username in any page which has the session, many thanks for your help in advance!!
×
×
  • 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.