Jump to content

waynew

Members
  • Posts

    2,405
  • Joined

  • Last visited

Everything posted by waynew

  1. Using die() blindly is bad practise. Use <?php mysql_query("INSERT INTO questions (question, answer, asker, by, date) VALUES ('$question', '$answer', '$asker', '$by', '$date')") or trigger_error("Cannot execute".mysql_error()); ?> You should really be checking to see if a query was successful. How is killing the entire script user friendly?
  2. I just wrote out all of that when there's already a function that does exactly the same thing. Does array_rand() make sure that no two values are given twice?
  3. I made this: <?php //my example array $my_array = ("Orange","Apple","Berry"); //count how many items are in the array $size_of_array = sizeof($my_array); //-1 because the index of an array starts at 0. $size_of_array = $size_of_array - 1; //number of words you want from the array $num_words = 3; if($size_of_array > ($num_words - 1)){ $num_words = $size_of_array + 1; } //an array that will note down what words we have already got $words_used = array(); //setup loop $counter = 0; while($counter < $num_words){ $rand_index = rand(0,$size_of_array); //get a random index while(in_array($rand_index,$words_used)){ //make sure word not already used $rand_index = rand(0,$size_of_array); //get a random index } echo $my_array[$rand_index]; array_push($words_used,$rand_index); $counter++; } ?>
  4. The time you're seeing is the time where your server is located. To set the time according to your timezone, you can use http://php.net/manual/en/function.date-default-timezone-set.php.
  5. Do you have errors and notices set to on?
  6. Then <?php $limit = 6; $query = "SELECT * FROM wp_posts ORDER BY post_date DESC LIMIT $limit"; $result = mysql_query($query) or trigger_error(mysql_error()); while($row = mysql_fetch_assoc($result)){ //etc } ?>
  7. At the end of the day, there is nothing you can do from stopping the end-user from reading your XHTML/HTML. That's the truth.
  8. You have.... AFTER output. Put session_start() at the very start of the page. Not after you output HTML etc.
  9. And what kind of columns are these? Text, varchar, datetime?
  10. isset() returns true if the value you're giving it actually exists. If the value doesn't exist, it returns false.
  11. If you're seeing actual PHP source code, it's because either your server doesn't support PHP or because you've used the wrong tags to denote PHP code. Example: short tags.
  12. waynew

    Login

    That's probably because you didn't use md5() on the password when the user was registering. You should never store clear-text passwords in your database. Always hash them using md5() or sha1() beforehand and then insert them.
  13. You can convert a datetime into a timestamp by doing this: $timestamp = strtotime($datetime);
  14. What is the Wordpress table that contains these blog posts and what kind of columns does this table have?
  15. You must include the function session_start(); at the top of your pages in order for sessions to work properly.
  16. Your PHP source code gets executed on the servers side, and thus is never seen by the user on the client side (browser), unless a server error occurs. Basically, use a strong FTP login.
  17. The solved function will be offline for a while until the admins port the old mod to the new version.
  18. waynew

    Login

    Where is the form attribute "action" ? <form action="pagename.php"> etc
  19. To get a datetime from PHP, use this: $datetime = date("Y-m-d H:i:s"); You can also use the mktime() function to specific a date in the future.
  20. Well, firstly you'll have to make sure that said domain is on the server as your Wordpress database. Otherwise, you'll have to make sure that the database on your other server allows external connections. Have you looked into the schema/structure of the Wordpress blog table?
  21. waynew

    Login

    1: Is your submit button actually called 'submit'? 2: Why are you using addslashes() instead of mysql_real_escape_string()? 3: You are stripping tags from the password? Why? When you could just hash the password using md5() or sha1()? What if a user has a < in their password? 4: Your code will cause some notices to pop up. When making sure that a POST variable exists, use this: if(isset($_POST['submit'])){ //etc } instead of if($_POST['submit'])
  22. I'm guessing that Wordpress already takes notice of the current datetime. What are you trying to do with Wordpress that is causing you problems?
  23. I don't get it. If error reporting and notices are turned on, you should be getting some kind of notice/error if thing aren't going right.
  24. You should be using the proper MySQL column types. Datetime is available to you. If you use the function mktime() properly, this will be pretty easy to accomplish. Also, your column Banlength is a bit redundant, seeing as you could get the ban length from the BanDate and ExpireDate columns, unless I'm mistaken otheriwse.
×
×
  • 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.