Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. If you're monitering registered and logged in users, a usual way would be to add a 'last active' field to your users table, to store a timestamp of the last time they browsed a page - you'll need to have a php file that does this updating, and include it in your other files. Your online list can then be generated by selecting those users who's last active timestamp is less than 5 (or whatever you want) minutes ago. To track guests online, you'll need to store session IDs with a similar method.
  2. The wonders of google eh: http://drewd.com/2007/01/25/reading-from-a-word-document-with-com-in-php That wasn't hard, was it?
  3. So you want to find rows where the 20 columns (all but the primary key) are duplicates? <?php $fields = array('field1','field2','field3');//list your fields $sql = "SELECT * FROM users WHERE (`".implode('`,`',$fields)."`) IN(SELECT ".implode('`,`',$fields)." FROM users GROUP BY first,last)"; $result = mysql_query($sql) or die(mysql_error()); //show results ?> If you dont also want to return the primary key, just use the inner query.
  4. Basically what your saying is that you want to get data from the database without running a query. So no, thats not possible. You'll have to use two separate queries
  5. Do you not think that if someone has ended up with the hashed password (which is stored in your database) it is entirely likely they may also find the salt (if it is stored in the same database)?
  6. What happens when you run the script? Any error messages?
  7. I think cgm was mostly referring to the hopelessly vague title of your topic. PHP HELP!! surely not? I wasn't aware this was a PHP forum... Anyways, your question was a bit unclear. Is the code you included something you tried? In the form you showed, im not entirely sure why you've specified an enctype - you dont need it. You've called your drop down 'select' and are using the POST method. But in the PHP, you appear to be trying to select this from a variable, id, in the GET array. Or perhaps i missed the point. You might need to try and explain more carefully.
  8. What are you struggling with? What exactly is the problem? That query looks fine to me.
  9. You might find it helpful for your understanding to print out the array created by the explode function: <?php $location = $_SERVER["SCRIPT_NAME"]; $parts = explode('/',$location); echo '<pre>'.print_r($parts,1).'</pre>'; if(count($parts) == 2){ $n_id = 'home'; }else{ $n_id = $parts[1]; } echo $n_id; ?> You'll then see you weren't quite correct - the forward slashes themselves are not elements of the array. Its every thing inbetween that is.
  10. The explode function splits the location string by forward slashes. If there's only one slash, that corresponds to the web root. Therefore, there are two pieces to the array (one either side of the slash - though the first is empty, since the slash is the first character). Therefore, with two pieces, the file we are viewing is in the root directory and we want 'home' If there are more than one forward slashes, there are more than two pieces. The piece we want is the 2nd piece (since indexing starts at 0, this is the element with key 1). Hopefully that makes more sense than I think it does!
  11. Certainly reasonable - though all numeric (and potentially short) salts wouldn't be the best choice. Also, if a hacker had access to your files, you'd be in a whole big heap of trouble.
  12. I've not fully read this, but i do notice one thing. In your PHP you have this line; if($_POST["submit"]=='Upload File') However, your submit button has the name 'Submit' - with a capital S. Array keys are case sensitive, so you need to change that. Also, you appear not to have given your submit button a value, in which case the above will never be true. You might want to replace the above line with: if(isset($_POST["submit"]))
  13. Not quite - print returns a value(1), echo does not. Echo can take multiple parameters, print can not. I know im splitting hairs, but i only found this out today
  14. My mistake - i read the question and not the code. Didn't notice you were using mssql. I would expect the required WHERE clause to be something along the lines of: WHERE M2.[EMPNO] = '".$_POST['empcode']."' AND substr(M2.[MSSNO,-4) = '".$_POST['password']."' However, I've never worked with mssql and cant seem to find any documentation on the web for string functions in mssql, so it is almost certainly different from the above.
  15. Well i wasn't going to answer, given the annoying title. But see substr() here: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html
  16. Separating out your functions and adding or die statements would be a good idea: <?php $devcount = mysql_fetch_array(mysql_query("select * from dev where id=$mytribe[devcount]+1[tribe]")); //becomes: $sql = "select * from dev where id=$mytribe[devcount]+1[tribe]"; $result = mysql_query($sql) or die(mysql_error().'<br />On the query:'.$sql); $devcount = mysql_fetch_array($result); ?> You'll then get told what the error is. Though i can see it - '+1[tribe]' doesn't make a lot of sense. What are you trying to do?
  17. Do you get anything displayed? A box with a red cross in it?
  18. So you just want the highest level folder? e.g. If someone was on page3.php, you would want $n_id to be equal to products? The following would assume the files are stored in the web root. If they're not, increase the values of 2 and 1 by the number of folders deep they are stored. <?php $location = $_SERVER["SCRIPT_NAME"]; $parts = explode('/',$location); if(count($parts) == 2){ $n_id = 'home'; }else{ $n_id = $parts[1]; } echo $n_id; ?>
  19. I can't see anything obviously wrong with the javascript - perhaps there's something odd in wrapper.js? Im no expert with javascript, but if this is live somewhere i'll take a quick look.
  20. So the problem is that when you click on a form element, the page just refreshes? We're not talking about submit buttons here? If so, I guess it must be the javascript- PHP can't be doing anything.
  21. Indeed - if blackcell is correct in what you wanted to do and and if you're using apache, find this line in your http.conf: AddType application/x-httpd-php .php And add this line below: AddType application/x-httpd-php .html
  22. Dont need the two queries. Just order by the year, then keep track of the year that the last iteration of the loop had. If it's different, then show the year: <?php $sql = "SELECT id, title, date_format(date,'%M %d, %Y') as date, date_format(date, '%Y') as year FROM pr WHERE del='N' and post='Y' ORDER BY year,id DESC"; $result = mysql_query($sql) or die(mysql_error().'<br />Query was:'.$sql); $last_year = ''; while(list($id,$title,$date,$year) = mysql_fetch_row($result)){ if($last_year != $year){ echo $year.'<br />'; $last_year = $year; } echo $title.'<br />'; } ?> Ill leave you to format.
×
×
  • 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.