Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. Just to shorten that, to make it look a little nicer: $selected = ($_GET['value'] == $option_value) ? 'selected="selected" : NULL;
  2. Yes, and that's exactly how you do it.
  3. If there's an 8-hour difference and you want it to display your time you can use: date('whatever format', time()+3600*;
  4. Something like.. $trans = imagecolorallocate($img, 255, 255, 255); imagecolortransparent($img, $trans); ?
  5. $variable = $_POST['xy']; Or request if it's coming from the URL.. $variable = $_REQUEST['xy'];
  6. Ahh, I never knew that Use this then: function changeTitle($title) { $parts = explode(' ', $title, 2); return $parts[1] . ', ' . $parts[0]; } $title = 'The Matrix'; $new_title = (strtolower(substr($title, 0, 3)) == 'the') ? changeTitle($title) : $title; echo $new_title; If the title was 'The Matrix' it would output Matrix, The . If it was 'The Matrix Reloaded' it would output Matrix Reloaded, The. Edit: The third parameter in explode() doesn't work like that.. So it had to actually be 2.
  7. function changeTitle($title) { $parts = explode(' ', $title); return $parts[1] . ', ' . $parts[0]; } $title = 'The Matrix'; $new_title = (strtolower(substr($title, 0, 3)) == 'the') ? changeTitle($title) : $title; echo $new_title; Output: Matrix, The However, that won't work for titles that contain more than 3 words and the word 'the'. How would you want want the title to change if it was like 'The something something'? I can change the function for you if necessary.
  8. It says 'if it doesn't equal on or it doesn't equal off'. So it will always run.
  9. $sql=mysql_query('SELECT * FROM member_messages WHERE status = "NEW" and user_id ="' . $userid . '"');
  10. What do you mean check-again? The results aren't going to change within the execution of the script...
  11. strpos(). $myVariable = 'may the force be with you'; if(strpos($myVariable, 'the force') === false) { //the string was not found } else { //It was found.. }
  12. Well I don't know what you're talking about.. I used 000webhost before I had my own hosting, it was great.
  13. Depending on your situation it's sometimes useful just to make a function like user_exists(), you could input a username and it would return true or false, the core of that function could look like: $result = create_query('some query..'); if(!mysql_num_rows($result)) { return false; } return true;
  14. Also a problem with your second query.. mysql_query(' UPDATE stats SET `visit`="' . $stats . '" WHERE id = "1"') or die(mysql_error());
  15. $stats = ++$data['visit']; You could use the ++ before or after the variable. It's suggested you use it before because it won't alter the value of $data['visit'], but unless you're using that again and want the original value it doesn't matter.
  16. I believe I read something about the paths for things on CRON files have to be different because of the way they're ran. So try making them in terms of the root, eg. instead of fork.php try ../whatever/fork.php (or however yours is setup). However, if that fails I also encountered a similar problem with CRON and a php script utilizing MySQL, which I wasn't even including anything on.. and I still couldn't get it to work. It was strange.
  17. The reason I didn't do it like that is because then you manually have to append the closing paragraph tag. I guess it's not to bad since you also have to append the link.
  18. If every paragraph ends with '</p>' you can use something like this: $row = mysql_fetch_assoc($result); //From the query you made.. $output = str_replace('</p>', '</p>{END_PARAGRAPH}', $row['entry']); // Or whatever row you have the article in.. $output = explode('{END_PARAGRAPH}', $output); echo $output[0];
  19. But i want the opposite,..that a .php would be read as a .png Because i am having 5 png images and 1 php files.. at every refresh the image changes here is my actual code: <?php Header ("Content-type: image/png"); $a=array( '1.png', '2.png', '3.png', '4.png', '5.png' ); $b=$a[array_rand($a)]; $img_handle = imageCreateFrompng("$b"); Imagepng ($img_handle); ImageDestroy ($img_handle); ?> No. That is what you want.. You can save that code as a .png file.. And when visiting you'll be visiting like image.png ..
  20. You can use a .htaccess file to make it so that a .png would be read as a .php. eg. <Files "index.png"> AddType application/x-httpd-php .png </Files> You could then have a file named 'index.png' with your source it in, and you could view it as index.png but the server would still process it like .php
  21. Not.. if (!$_POST['update']) { Use: if (isset($_POST['update'])) {
  22. Use: if(isset($_POST['something']) && isset($_POST['somethingelse'])).. Instead of: if($_POST['post']).. Also, why would you have the date as a text field? They could put whatever they want. You should use date as a unix time stamp. You can use time(), and when fetching the blog posts use date()
  23. That's what he was doing originally, just forgetting the 'echo'. That's what I thought he meant.
  24. It's not a hack. It's the 'correct' way. 'echo' just means that it's outputting it to the browser.
×
×
  • 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.