Jump to content

Jeremysr

Members
  • Posts

    199
  • Joined

  • Last visited

    Never

Everything posted by Jeremysr

  1. Use str_replace() to replace text: $txt = str_replace(' [center]', '<center>', $txt); $txt = str_replace('[/center] ', '</center>', $txt); The reason that code you pasted doesn't assign anything to $txt is because it's a function. If you don't know about functions you should go learn about them.
  2. Use explode() to change the name into an array: $name = explode(' ', $searched_name); This splits the variable $searched_name into an array of strings, seperated by a space (or whatever you put as the first argument). Then use this query: $sql = "SELECT * FROM table WHERE firstname = '" . $name[0] . "' AND lastname = '" . $name[1] . "'";
  3. Does anyone have any ideas of how to "memorize" which topics the users have read and which ones they haven't read? Or have any links to information about this? It was hard searching Google for it, I just got mostly forums as my search result, instead of information on how to make a forum (the tutorials I got didn't say how to do what I'm asking about here.)
  4. A couple of weeks ago I searched for something on Google about storing a webpage into a variable and it said to use file_get_contents(). I tried and it worked. I remember it said sometimes websites would block it though, and it showed some code for a workaround. But I ignored that part because just file_get_contents() worked for me. But NOW, I need to use this function again (my program will get the URLs of a bunch of webcomics I want to download.) And now it says "permission denied" for the site I'm accessing. I tried searching Google and couldn't get the site I was at before or anything else that worked. :-\ So, can someone here help me with this please?
  5. Ok thanks. I couldn't use nl2br() because it changes all of the newlines to br tags but I only want to change double newlines, not all of them. I'll try "\r\n\r\n".
  6. I'm making a program where someone enters text into a textbox and then in the next page I need to change all the double newlines ("\n\n") into two linebreak tags. For some reason this works: [code]str_replace("\n", "<br />", $input);[/code] But this doesn't work: [code]str_replace("\n\n", "<br /><br />", $input);[/code] I want the single newlines to be ignored though. Can someone tell me what the problem is?
  7. I think you need a semi-colon right at the end of the line above the one you said the error was on. The date='$date' line.
  8. Just use: str_replace( ":grin:", "<img src='grin.png' />", $message_content ) That will replace :grin: with an image (a smilie) everytime it finds it in the $message_content. You could use an array or something to store the smilie information and go through a for loop to replace them with image smilies.
  9. You didn't say what the problem was. But I did notice you put <php? instead of <?php when you were echoing out the $title.
  10. I think you can use $_SERVER['HTTP_REFERER'] to get the URL they came from.
  11. Yes, they expire after either closing the browser or if you use session_destroy().
  12. I don't know how to do that.. but there's some information about it here: http://ca3.php.net/manual/en/ref.mail.php Just press Ctrl+F and search for "attach" on that page.
  13. No, don't take it off. Just do what Orio said: Take off the semi-colon.
  14. Ok I was kind of thinking of when you use a for loop to loop through an array printing out each value in the array or something...but I guess he doesn't want to do that.
  15. A better way is to do it in a for loop: [code=php:0] for ($x = 0; $x <= 10; $x++) {     $arrayname[$x] = $x; } [/code] What this would do is store all the numbers from 0 to 10 in the array, but I'm sure you'll figure it out for whatever you're trying to do.
  16. Well which line is line 43? BTW you don't put quotes when your assigning a variable to another variable like that. $to = $_SESSION[username];
  17. You're missing a semi-colon on the first line in your code that you showed above.
  18. Use [url=http://ca3.php.net/manual/en/function.msql-num-rows.php]mysql_num_rows[/url]() to find out how many new messages they have. If they have more than 0 new messages, display the New Messages link.
  19. Maybe it has something to do with case-sensivity. Or maybe you should post your code?
  20. intval() will convert a variable to an integer, I think that's what you want. $string = intval($string); Edit: Also, floatval() will return a floating-point value. [code=php:0] $string = "45.9"; $int_string = intval($string); $float_string = floatval($string); echo ($int_string); // Will echo 45 echo ($float_string); // Will echo 45.9 [/code]
  21. I don't think forward slashes have to be escaped, I think it's just the backslash (\) that has to be escaped...
  22. I think you have too many }'s. Try removing each one right before the else or elseif statements (except for the first else statement). Because it looks like you have 2 }'s before each one.
  23. Hmmm..here's a list of stuff you'll probably need to know, so just try searching for them on Google or something. Databases (MySQL) Sessions and Cookies (for letting users log in) Uploading (pictures) Files (Save their page in a file that they can edit (but don't let them edit the actual file especially if php is allowed)) And basic PHP stuff like if statements and variables and forms just incase you don't know PHP very well. Because this could be kind of difficult, especially if you don't know many of the things in the above list.
  24. You could replace all ". "'s with ".&nbsp;&nbsp;" [code=php:0]$info = str_replace(". ", ".&nbsp;&nbsp;", $info);[/code]
  25. You only need to echo once: echo "<td>" . $row['FirstName'] . "</td>"; echo "<td>" . $row['LastName'] . "</td>";
×
×
  • 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.