Jump to content

markspec87

Members
  • Posts

    63
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

markspec87's Achievements

Member

Member (2/5)

0

Reputation

  1. Im trying to implement a script that will check if a member is online and then display "members online: 3" When they login it updates their "online" field to 1, and my index just outputs how many rows have their online set to 1. My question is when a user logs out (by closing the browser, how can i detect this and set online to 0?) If they use my logout script it sets it to 0, but other than that i dont know how i can account for a user closing the browser? Maybe im going about this the wrong way? Hopefully you can help me :)
  2. Im looking for a piece of code that can put the filenames from a specific directory as options in a form drop down box. is this possible?
  3. yeh sorry ive missed bits out. Both files have session start, as i said, the username passes perfectly, but the ID just doesnt work.
  4. 2 of my variables will work but the third just doesnt want to work and im stumped why. index page code: [code] if (isset($_SESSION['username'])) {     echo "Welcome back " . $_SESSION['username'];     echo "click <a href='logout.php'>here</a> to logout<BR>";     echo "click <a href='editprofile.php?id=" .$_SESSION['userid']. "'>here</a> to edit your profile<BR>";     echo $_SESSION['userid']; } else {     echo "your not signed up, <a href='signup.php'>signup</a> now or <a href='login.php'>login!</a>"; }[/code] the 4th echo for userid was just for debugging, but its still not working. The username works fine. Login code: (relevant) [code]if(mysql_num_rows($result) == 1) {     // retrieve the access level     $row = mysql_fetch_assoc($result);         // set the session vars:     $_SESSION['username'] = $_POST['username'];     $_SESSION['accesslevel'] = $row['accesslevel'];     $_SESSION['userid'] = $row['id']; }[/code] The row definitely exists and has values in the records, yet on the main page the variable is always null. Any ideas guys?
  5. I have a piece of a code to count the active number of guests that looks like [code]$minutes = 5; $seconds = $minutes*60; $past = time()-$seconds; $now = time(); if ( @mysql_num_rows(mysql_query("SELECT * FROM visitors WHERE ip=$_SERVER[REMOTE_ADDR]")) != 0 ) { mysql_query("UPDATE visitors SET date="$now" WHERE ip=$_SERVER[REMOTE_ADDR]") or die ("Error - Unable to update visit"); } else { mysql_query("INSERT INTO visitors VALUES ($_SERVER[REMOTE_ADDR],"$now")") or die ("Error - Unable to insert records"); } mysql_query("DELETE FROM visitors WHERE date < $past") or die ("Error - Unable to delete old visits"); $visitors = mysql_result(mysql_query("SELECT COUNT(*) FROM visitors"),0); */[/code] However i get a parse error [quote]Parse error: syntax error, unexpected T_VARIABLE in myfile on line 136[/quote] Line 136 is the [code]mysql_query("UPDATE visitors SET date="$now" WHERE ip=$_SERVER[REMOTE_ADDR]") or die ("Error - Unable to update visit");[/code] any ideas guys?
  6. Ive had a go at that but its not working [code]if (is_dir('downloads/$id')) { } else { mkdir("downloads/$id", 0700); } [/code] will still try make the directory even if it exists.
  7. I have a small file upload script where users can upload files for their articles. However it doesnt work unless i manually create the numbered directories. i.e files/uploads/1 files/uploads/2 (each article has a unique ID) so i was wonder if there was a way at the start of my script to check if the directory exists, and if it doesnt create it using the name from my variable $id variable. thanks guys.
  8. no errors but it doesnt work still. Ive tried echoing $hash however it doesnt show, so obviously the problem is around that variable. Ive checked the code and i dont know why its not able to get the hash value from the url.
  9. you guys have been so helpful with my previous problems so i might aswell ask this here :) ive finally got a semi working email activation, the email is sent however when they click the link, the database isnt updated. For simplicty im simply using the timestamp to validate. My signup looks like: [code] $t= time(); $url='http://mywebsite.com/activate.php?hash='.$t; [/code] The activation link, when sent, looks like: [quote]mysite.com/activate.php?hash=1164562953[/quote] Which is how it looks in the database too. Activate.php: [code]<? include("config.php"); $hash = $_GET[’hash’]; @mysql_select_db($dbname) or die( "Unable to select database"); $query = "UPDATE users SET status = 1 WHERE hash = $hash"; mysql_query($query); echo "Your account has been activated<BR>"; ?>[/code] Any ideas why it isnt updating?
  10. I doubt this will work but your missing " " after your = assignment anyway. [quote]<? $id = "1" ; $title = "Main Page" ; $restricted = "0 " ; $keywords = "home page main " ; $type = "1" ; $pagecode = " ?> <lots of HTML> <? "; ?>[/quote]
  11. no, its on the web server. i just uploaded it. tried changing filename and link to db1.php but still it doesnt work. confused :(
  12. I have a peice of code in my config.php which reads an ini style file to get the database details The code starts with [code]$config = parse_ini_file('db.php');[/code] Now the db.php file is in the same folder as this file yet everytime i get the error: [quote]Warning: parse_ini_file() [function.parse-ini-file]: Cannot open 'db.php' for reading in /home/sites/mysite/public_html/includes/config.php on line 3[/quote] But i know for a FACT the file is definitely there. ive chmodded it to allow read write aswell and still it says it cant open it. has anyone got a clue whats going on?
  13. I made a post about my signup script which looks like: [code]<?php include("config.php"); mysql_select_db($dbname) or die ("Could not select database because ".mysql_error()); // check if the username is taken $check = "select id from users where username = '".$_POST['username']."';"; $qry = mysql_query($check) or die ("Could not match data because ".mysql_error()); $num_rows = mysql_num_rows($qry); if ($num_rows != 0) { echo "Sorry, that username $username is already taken.<br>"; echo "<a href=/signup.php>Try again</a>"; exit; } else { $t= time(); // insert the data $insert = mysql_query("insert into users values ('".$_POST['username']."', '".$_POST['password']."','','1', '".$_POST['avatar']."', '".$_POST['email']."', '0','$t', '".$_POST['age']."', '".$_POST['location']."', '".$_POST['clan']."', '".$_POST['website']."', '".$_POST['about']."')") or die("Could not insert data because ".mysql_error()); $to = $_POST['email']; $url='http://www.mysite.com/activate.php?hash='.md5($_POST['password']).'&s tamp='.base64_encode($t); $subject = "Account Activation"; $message = "Hello! This is a simple email message."; $from = "webmaster@clan.com"; $headers = "From: $from"; mail($to,$subject,$message,$headers); echo "Your user account has been created!<br>"; echo "An activation email has been sent to " .$_POST['email']. "<BR>"; } ?>[/code] However when i submit it, i get the error: [quote]Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.[/quote] ive tried commenting out areas and it works fine if i dont call the mail() function. I looked in my server logs and ive found: [quote][Sat Nov 25 17:29:58 2006] [error] [client 82.153.230.227] malformed header from script. Bad header=/home/sites/mysite.com/dea: processsignup.php, referer: http://www.mysite.com/signup.php[/quote] Does anyone know whats wrong? I cant find anything thats wrong with my current script. The onlyu thought i have is that the email string isnt being passed properly (if im correct the mail() function requires a valid user@domain.com address) Any thoughts?
  14. Ive seen on CMS' like PHPnuke when you access certain files that simply process data or just arent meant to be accessed, it says "you cannot access this file directly". How do you go about doing that? I want to protect some of my admin files that add database information but would prefer not to go through making them admin only. Id rather have nobody be able to use them unless theyve been referred from one of the CMS forms etc. any ideas?
  15. Thanks :) however when i complete the form now and it loads this page it always says: [quote] Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.[/quote] is this related? or just bad timing?
×
×
  • 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.