Jump to content

pea_1

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Everything posted by pea_1

  1. pea_1

    Variables

    Ofcourse i will, but i've coded that way for quite a lot of my work so i can only correct some of it.
  2. pea_1

    Variables

    I guessed that.. and most scripts i download don't use isset, so maybe it isn't a common setting to have. The response i would rather have would be what the setting is to see if i can get my hosts to turn it off. I've only learned php from other scripts, so blame them for my poor coding
  3. I uploaded some of my scripts onto my friends website and i got errors. I could only correct the errors by using functions like isset. I was wondering why these errors appear when on my friends server and not mine? Is it a setting in the phpini? It's quite annoying as the scripts work fine even with the errors. An example of a complaint is: if($var) which had to be changed to if(isset($var)) and if($var){ $word = "word"; } echo $word; had to be changed to if(isset($var)){ $word = "word"; } else { $word = ""; } Which i think is pointless.
  4. Is it possible to detect page errors such as 404 (page not found)? I've searched good but can't find anything, or i'm not looking in the right places. If so, would you be able to detect it even if a htaccess redirects it to an error page? Thanks, Peter
  5. pea_1

    How to use SQL

    I've got the host and i've tried my ftp username and pass.
  6. Hello. I'm new to SQL databases. I should probably ask in the PHPBB forum but this is also a general question. I'm trying to set up the forum and it's asking for database name, database username and database password. Are these the same as my ftp username and pass or should my host give me a separate one? Thanks. Peter
  7. Yeh it does. I also managed to get the top 5: $excludes = array(); $i = 1; while($i <= 5){ $i++; $output = mode($array); foreach($array as $lnum => $line){ array_push($excludes, trim($output)); foreach($excludes as $exclude){ if(trim($line) == $exclude){ unset($array[$lnum]); } } } echo "$output<br>";
  8. Ah thanks, i was completely lost on this one, but this seems to do the trick.
  9. The array doesn't contain numbers though, they're words
  10. Umm.. this is *extremely* simple maths. Maybe this will help you http://www.manatee.k12.fl.us/sites/elementary/palmasola/mathlabtutstat1.htm
  11. no the mathematical mode. the mode is the most often value. For example, for 1,2,2,2,3 2 would be the mode
  12. Can't figure out how to find the mode of a file (string occurring most often). Has anyone else managed to do it? Peter
  13. Hello, i'm trying to figure out how to put the characters of a string into an array, but i can't. Any ideas? Peter
  14. I found the problem, for some reason it didn't like including the whole address (http://www.example.com/etc). Used ./ect/header.php instead and it works. No idea why though
  15. But that'd be exactly the same as: <title>title</title> --- I've just done a test and it's work ok, so i must be doing something stupid.
  16. Hello, I want to use headers and footers for my website but i'm having trouble with the title tags. What i'm trying to do is put the page title into a variable on the contents page and then have the header echo it in the title tags. The structure's like this: contents page: <?php $title = "title"; include("header.php"); ?> content <?php include("footer.php"); ?> header.php: <html> <head> <title><?php echo $title; ?></title> </head> </html> But for some reason '$title' isn't echoing. Is there something i should be doing? Thanks, Peter
  17. After asking someone, i now have $pw as the hashed password. I'm not using a database because i don't have one.
  18. Hello, i need an admin area for one of my scripts and i've had some trouble with security in the past with this type of thing. So i just want to check if this is secure: <form action="" method="post"><input name="password" type="text" /><input name="" type="submit" /></form> <?php if($_POST['password']){ include("settings.php"); //with $pw if(md5($pw) == md5($_POST['password'])){ echo "in"; } else { echo "out"; } } ?> Thanks, Peter
  19. I use that javascript method, headers won't work if you have the head tag in a website.
  20. Now i can't find anything on sorting by date.. You might be able to make your own sorter, not that i know how, but even then it must be a huge script. Is there any other way?
  21. Ah thanks. I think i can use the script from this comment:
  22. Hello, i'm trying to find the last modified file in a set of directories but i can't figure out how to compare the file date, pick the newest date and then displaying the file name. I have this, but i'm not sure where to go or if it's even the way to do it. Thanks, Peter. <?php //put each dir into an array $dir = "../forum/"; $filearray = array(); if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if(preg_match("/forumposts_/", $file)){ array_push($filearray, "$file"); } } closedir($dh); } } //echo each file and it's last modify date foreach($filearray as $filer){ $filer = "../forum/$filer"; if ($handle = opendir($filer)) { while (false !== ($file = readdir($handle))) { if (preg_match("/.php/", $file)) { $file = "$filer/$file"; echo "$file".date ("F d Y H:i:s.", filemtime($file))."<br>"; } } closedir($handle); } } ?>
×
×
  • 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.