Jump to content

zeroblitzt

Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

zeroblitzt's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. function fixtime($oldtime) { $tz = $u['timezone']; if ($tz || isset($tz)) { $tz2 = ($tz * 60 * 60); $newtime = $oldtime + $tz2; return $newtime; } else { return $oldtime; } } I have that function above, and my intent is to wrap that function around anything that comes out of the database of my website (messages, user sign up date, etc.). But I'm wondering if there is an easier way, or if this wont work.
  2. Hello friends, I do not consider myself a thief. That is why I wouldnt outright steal this code. But I am trying to at least understand it, for you see, I am very, very new to Javascript. I hope that I could then write my own function of a similar nature. Anyway, the code in question: function toggle_spoiler(obj) { while (!/spoiler_(?:open|close)/.test(obj.className)) obj=obj.parentNode; obj.className=obj.className.indexOf('closed') != -1 ? obj.className.replace('closed', 'opened') : obj.className.replace('opened', 'closed'); return false; } This is what it does: 1. On a page, there would be 4 <span> tags, which call the following CSS classes: .spoiler_on_close .spoiler_close .spoiler_open .spoiler_on_open Oddly enough, they all do the same thing: display: none; 2. Inside the spans, there are two hyperlinks that call the "toggle_spoiler" function listed above. Basically, the function hides text, hence the name "spoiler" -- it can be used to hide sensitive parts of movies, video games, etc. that shouldn't be revealed without ruining the whole thing for someone else. To activate this spoiler, a user would type "<spoiler>" and to close it would be "</spoiler>" -- sort of a pseudo HTML tag. this sandwiches any text in between, which becomes hidden. 3. So when someone clicks the first hyperlink (accurately marked "spoiler"), it unhides the text on the inside by calling the toggle_spoiler function. Then, a user could click either the original <spoiler> tag, or the </spoiler> tag (which was unhidden with the rest of the text), and that would end up closing/rehiding the text. Hope that wasn't too confusing. Anyway, the Javascript aspect of it is the only part I cant figure out, and rightly so, because its basically the entire operation. If anyone could help me break this down bit by bit I'd greatly appreciate it.
  3. Yep, I did and I found the problem: Seems you were right about the mysql_query not returning FALSE everywhere, because in another query I do the same thing (check to see if its false) and it wasnt coming up. I got it sorted now, everything seems to be working too :D Thanks for the help.
  4. Well I just changed it to [quote] $checkusrx = mysql_query("SELECT * FROM reports WHERE marker = ".$u['userid']." && msgid = ".$msgid."") or die(mysql_error()); $checkusr = mysql_fetch_assoc($checkusrx); if (!$checkusr) {[/quote] But still nothing (as in its not giving me an Mysql error message or one of my own error messages).
  5. I get really good vibe when I come to these forums for help. I havent posted much, but for the times I've asked for help, nobody was really negative towards me, always helpful. The main section of PHP Freaks contains tons of useful tutorials (they basically taught me a lot of what I know). Viva la PHP Freaks.
  6. Just to clarify, do you mean I should take: [quote]  $checkusrx = mysql_query("SELECT * FROM reports WHERE marker = ".$u['userid']." AND msgid = ".$msgid."");[/quote] And make it into: [quote]   $checkusrx = mysql_query('SELECT * FROM reports WHERE marker = '.$u['userid'].' AND msgid = '.$msgid.''); [/quote] OR do you mean I should do this: [quote]   $checkusrx = mysql_query("SELECT * FROM reports WHERE marker = $u['userid'] AND msgid = $msgid"); [/quote]
  7. Hey all, I have this block of code used to mark inappropriate messages on my message board. Thing is, I need to check if a user has already marked a message once, so I do that with this line: [quote] $checkusrx = mysql_query("SELECT * FROM reports WHERE marker = ".$u['userid']." AND msgid = ".$msgid."");[/quote] Unfortunately this does not work. I always either get either nothing (the page stays exactly the same and doesn't seem to update, even though it should be) or the error message I crafted, that says "You may not mark a message more than once". Thing is, the marked message  queue is currently empty so there is no way I could have marked something already. Here is the code below. The problem (I think) is in between lines 4 and 10. Any help would really be appreciated, I just spent an hour trying different ways to do this but none have worked so far. [quote] if ($action == "r") { $msgid = $_GET['msg']; $checkusrx = mysql_query("SELECT * FROM reports WHERE marker = ".$u['userid']." AND msgid = ".$msgid.""); if ($checkusrx == FALSE) { $checkmsgx = mysql_query("SELECT * FROM reports WHERE msgid = ".$msgid.""); if ($checkmsgx == FALSE) { $reportx = mysql_query("INSERT INTO reports (`msgid`, `marker`) VALUES ('$msgid', '".$u['userid']."')"); if ($reportx) { echo "<span class='boardbar2'>Thank you, this message has been marked for moderation.</span>"; } else { echo "<span class='error'>Error: Could not complete moderation - ".mysql_error()."</span>"; } } else { $marknumx = mysql_query("SELECT marks FROM reports WHERE msgid = ".$msgid.""); $marknum = mysql_fetch_assoc($marknumx); $uprepx = mysql_query("UPDATE reports SET marks = '". $marknum['marks']+1 ."' WHERE msgid = ".$msgid.""); if ($uprepx) { echo "<span class='boardbar2'>This message has already been reported, so your report has been merged. Thank you.</span>"; } } } else { echo "<span class='error'>ERROR: You may only mark a message once.</span>"; } } [/quote]
  8. Wow thanks for the help! I'll put you both in the credits of my source code  :D
  9. Hey all, i'm a total regex beginner (never used it), but someone recommended that I use it. What I need to do with it is remove excess spaces from a string (for my message boards). So if I were to have, say: [pre]Hello    Everyone[/pre] it would shorten it down to [pre]Hello Everyone[/pre] I'm not sure how to go about doing it though. Any tips?
×
×
  • 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.