Jump to content

AbraCadaver

Staff Alumni
  • Posts

    1,893
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by AbraCadaver

  1. Not accurate at all. It doesn't measure anything other than how long it takes the server to execute that loop.
  2. Yes, so check the time in a session var etc. but also check if $_SERVER['HTTP_REFERER'] is set. Not foolproof but nothing is.
  3. Except that MySQL stores CURRENT_TIME and all timestamps as YYYY-MM-DD HH:MM:SS, not a UNIX timestamp.
  4. Many tutorials on connecting to MySQL and running a query. Then: DELETE FROM `table_name` WHERE (UNIX_TIMESTAMP(`Time`) + 3600) > UNIX_TIMESTAMP()
  5. Change .75 to 75 and change asort() to arsort() and it will work as you expect.
  6. For fun: $non_us = (count(array_unique($country)) > 1);
  7. OK, and what is not working??? Give an input, expected result and actual result.
  8. Did you try your inputs on what I posted?
  9. Depends upon the rules and what can be in between the /* and */ and other things but this is a simple one: echo preg_replace('#/\*(.*)?\*/#s', '', $file);
  10. I agree to do it in the query, but if your array is already sorted, then here's one way: foreach(array_reverse($array) as $row) { $new[$row['name']] = $row; } $array = array_reverse(array_values($new));
  11. There's got to be a more elegant way to do it, but I'll have to test something later. Here is the obvious: foreach($array1 as $a1) { $add = true; foreach($array2 as $a2) { if(in_array($a1['dt'], $a2)) { $add = false; break; } } if($add) { $array2[] = $a1; } }
  12. I wouldn't. I would have a redirect after the file save that redirected them back to a certain page.
  13. Assuming MySQL: $conn = mysql_connect('localhost', 'username', 'password'); $result = mysql_query("SELECT `FirstName` from table_name WHERE `UserName` = '" . $_GET['username'] . "' LIMIT 1"; $row = mysql_fetch_assoc($result); echo $row['FirstName'];
  14. If using apache use mod_rewrite, but it would need to be written like this: www.mysite.com/programname - becomes www.mysite.com/programs.php?programID=programname And then in PHP you would need to map the programname to the programID number (normally from a database). Or you could use this: www.mysite.com/programname/15 - becomes www.mysite.com/programs.php?programID=15
  15. What I posted works if the file is structured the way that it needs to for your original code to work. Post what Pikachu2000 suggested with print_r().
  16. No, same issue. You have loaded control_panel.php, so every include from there on is relative to control_panel.php: include("functions/Security.class.php");
  17. Yes, that was Nightslyr's point: class something { function somefunc() { $db = Database::getInstance(); // do stuff with $db } }
  18. O.K, and I gave you the answer.
  19. Paths are relative to the original file that was loaded, in this case index.php. So given that you include Security.class.php in index.php, its includes will still be relative to index.php. include("data/config.php");
  20. function http_post_lite($url, $data, $headers=null) { $data = http_build_query($data); $opts = array('http' => array('method' => 'POST', 'content' => $data)); if($headers) { $opts['http']['header'] = $headers; } $st = stream_context_create($opts); $fp = fopen($url, 'rb', false, $st); if(!$fp) { return false; } return stream_get_contents($fp); }
  21. Well you're going to need to put a form with a submit button around that text area, with method="post' and action="save.php". Then in save.php, something like: file_put_contents('announce.txt', $_POST['text1']);
  22. If I understand correctly, this should work: $xx = 100; $contents = file($file); $lastxx = array_slice($contents, -$xx); file_put_contents($file, implode(PHP_EOL, $lastxx)); echo implode($lastxx);
  23. Did you read the manual for str_replace? It may accept arrays for search and replace parameters. So might str_ireplace() which is case-insensitive.
  24. I would recommend file_put_contents() for writing.
×
×
  • 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.