Jump to content

Padgoi

Members
  • Posts

    174
  • Joined

  • Last visited

Everything posted by Padgoi

  1. Hi everyone. So I'm using this javascript slide down effect and it works fine and it's updating every 0.2 seconds (as the duration indicates) but it's updating constantly, not just when the last post is made. I only want it to slide-down when the last post is actually made, right now it's sliding down every 0.2 seconds regardless of whether a new post is made or not. I know it's the if statement I have wrong. Can someone help me out with this? Thanks in advance. Here's the code: var c=0 var t function ajaxLastPost() { var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser does not support XMLHTTP!"); } xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4) { document.getElementById('DivLastPost').innerHTML=xmlhttp.responseText; Effect.SlideDown( 'DivLastPost', {duration: 0.1} ); } } xmlhttp.open("GET","sources/action_public/lastpost.php",true); xmlhttp.send(null); c=c+1; t = setTimeout("ajaxLastPost()",5000); }
  2. Sorry guys, my PHP is kinda weak. I'm trying this but it's not working. $total = $field / $get_topics[0]; round($total, 2); $this->output .= "\t<td><font face=arial size=1/>$total</font></td>\n"; Where exactly do I put the round() function?
  3. Hi, I have this function but it's displaying a VERY long number. I want to limit the number to 2 decimal places. How would I go about doing this? Any help is appreciated. $total = $field / $get_topics[0]; $this->output .= "\t<td><font face=arial size=1/>$total</font></td>\n"; Thanks!
  4. Getting a bunch of resource id's.
  5. Thanks Batosi, but it's still null.
  6. Which one? I replaced the last one, that didn't work, still null.
  7. Yeah, that is working fine, the first part of the query works fine, it's the second part, the $q and $poop parts that are displaying null. Please help?
  8. Hi everyone, So I have this code and the first part of it works fine, but the $q part of it is just displaying null. Can anyone help me with this: function eatbox() { $pop = mysql_query( "select starter_name, count(*) as replies from ibf_posts join ibf_topics on tid=topic_id where new_topic=0 group by starter_name order by replies desc LIMIT 25" ) or die("SELECT Error: ".mysql_error()); $num_rows = mysql_num_rows($pop); $this->output .= "<table border=1>\n"; while ($get_info = mysql_fetch_row($pop)){ $this->output .= "<tr>\n"; foreach ($get_info as $field) {$this->output .= "\t<td><font face=arial size=1/>$field</font></td>\n";} $q = "select count(*) as topics from ibf_topics where starter_name = '".$get_info['starter_name']."'"; $poop = mysql_query( $q) or die("SELECT Error: ".mysql_error()); $get_topics = mysql_fetch_row($poop)); $this->output .= "\t<td><font face=arial size=1/>$get_topics['topics']</font></td>\n"; $this->output .= "</tr>\n"; }
  9. I'm sorry, my php isn't great, what do you mean is int rateid under rating from above array?
  10. What do you mean echo out the update? All I did to get the top part working was change the VERY TOP of the snipped to this: $fields = array( '1' => 'field_14', '2' => 'field_19', '3' => 'field_15', '4' => 'field_23', '5' => 'field_24', '6' => 'field_22', '7' => 'field_17', '8' => 'field_13', '9' => 'field_16', '10' => 'field_28', '11' => 'field_25', '12' => 'field_29', '13' => 'field_18', '14' => 'field_31', '15' => 'field_26', '16' => 'field_30', '17' => 'field_27', '18' => 'field_32', ); So now the top part that changes ratings works but the adding the +1 on a new rating still doesn't work. Any ideas? And if that condition isn't matching the database, then why does the top part that changes the rating now work? Wouldn't that not work as well? Only the add part doesn't work now.
  11. arrow, you're right, I got the top part working now where it changed the rating. But the bottom part, the part you pointed out, is not adding the rating to the custom field, it's not adding the +1. Do you know what's wrong with it?
  12. I have a ratings modification that allows users to rate posts on my forums. I'm trying to make it so that when a user rates a post, it will update 2 fields, the first one will add the rating to a field, the other will simply add +1 to the count of a custom field. The first part of it to update the ratings field works fine. But the second insert to update the count of the custom field isn't working at all, it's not adding the +1 to the count. Here's the snippet: } $MySQL = new MySQL( ); $postid = $_GET['p']; $userid = $_GET['u']; $rateid = $_GET['r']; $fields = array( '1' => '14', '2' => '19', '3' => '15', '4' => '23', '5' => '24', '6' => '22', '7' => '17', '8' => '13', '9' => '16', '10' => '28', '11' => '25', '12' => '29', '13' => '18', '14' => '31', '15' => '26', '16' => '30', '17' => '27', '18' => '32', ); $ratingCheck = $MySQL->customQuery( "SELECT r.rating,r.uid,p.* FROM ibf_ratings r LEFT JOIN ibf_posts p ON(r.pid=p.pid) WHERE r.pid = '{$postid}' AND r.uid = '{$userid}'"); // Yup, we've already rated this post so UPDATE the rating IF the rating is differant from the current one. if( $MySQL->rowsReturned( $ratingCheck ) ) { $row = $MySQL->fetchResults( $ratingCheck ); // If the current rating is equal to new rating, don't do anyhing... if( $_GET['r'] == $row['rating'] ) { echo "Rated!"; } else { [b]$MySQL->customQuery( "UPDATE `ibf_ratings` SET `rating` = '{$rateid}' WHERE `pid` = '{$postid}' AND `uid` = '{$userid}'"); $MySQL->customQuery( "UPDATE `ibf_pfields_content` SET ".$fields[$row['rating']]."=".$fields[$row['rating']]."-1,".$fields[$rateid]."=".$fields[$rateid]."+1 WHERE member_id='".$row['author_id']."'" );[/b] if( $MySQL->affectedRows( ) ) { echo "Rating changed!"; } } } else { $MySQL->insertQuery ( "ibf_ratings" , Array( 'pid' => $postid , 'uid' => $userid , 'rating' => $rateid ) ); [b]$MySQL->customQuery( "UPDATE `ibf_pfields_content` SET ".$fields[$rateid]."=".$fields[$rateid]."+1 WHERE member_id='".$row['author_id']."'" );[/b] echo "Rated!"; } } The part that I bolded is the part that is supposed to add the +1 to the custom field, but it's not adding. The top part with the fields array is simply associating each rating with a field, so rating 1 = field_14 and so on. The fields that are NOT updating are called field_14, field_15 and so on. Thanks in advance.
  13. Figured it out myself. Thanks anyway.
  14. Something's wrong with the comma after Field_30 in this snippet. Can anyone help? I'm trying to get the 6th root of everything after the pow function. $member['member_ovr'] = $this->ipsclass->compiled_templates['skin_topic']->member_ovr( sprintf( '%.2f', ( sqrt ( $member['posts'] ) / 100 ) + ( pow ( $member['field_13'] * 2 ) + ( $member['field_30'] ), 1/6) - ( $member['warn _level'] ) ) );
  15. A few more snippets from the other file: $upload_directory = "files/"; $upload_uri = $folder_directory."/files/"; And later in the file: $open = opendir($upload_directory); $uploaded_files = ""; while($file = readdir($open)) { if(!is_dir($file) && !is_link($file)) { $uploaded_files .= " <tr> <td style=\"background: #fff; color: #000; text-align: left; width: 70%\"><a href=\"$upload_directory$file\" title=\"$file (".filesize($upload_directory.$file)." bytes)\">".$file."</a> (".filesize($upload_directory.$file)." bytes)</td>"; if($allow_file_deletion) $uploaded_files .= " <td style=\"background: #fff; color: #000; text-align: right; width: 30%\"><a href=\"?delete=$upload_directory".urlencode($file)."\" title=\"Delete File\">Delete File</a></td>"; else $uploaded_files .= " <td style=\"background: #fff; color: #000; text-align: right; width: 30%\"></td>"; $uploaded_files .= " </tr> <tr> <td colspan=\"2\" style=\"background: #eee; color: #000; text-align: left; text-indent: 20px\">Uploaded <strong>".date("F d, Y / h:ia", filemtime($upload_directory.$file))."</strong></td>"; $uploaded_files .=" </tr> "; } } function upload_file($upload_directory, $upload_uri) { $file_name = $_FILES["userfile"]["name"]; $file_name = str_replace(" ","_",$file_name); $file_path = $upload_directory.$file_name; $temporary = $_FILES["userfile"]["tmp_name"]; $result = move_uploaded_file($temporary, $file_path); if(!chmod($file_path,0777)) $message = "ERROR: A folder to place the files was not found, or the files need to be CHMODed to 777."; else $message = ($result)?"File has been uploaded." : "An error has occurred."; return $message; }
  16. Hi, I have this very short php query that is simply calling up all uploaded files in a folder. Here is the snippet: <? if($uploaded_files == "") echo " <tr> <td colspan=\"2\" style=\"background: #fff; color: #000; text-align: center\"><br /><strong>There are no uploaded files.</strong><br /><br /></td> </tr> "; else echo $uploaded_files ?> The problem is, when it is echoing the $uploaded files, it is displaying ALL of the files from the folder. I only want to show the very latest upload in that folder, only one (1), not all of them. How would I go about doing this? I appreciate any help. Thanks in advance!
  17. Thank you for the help. I'll make an attempt next time, though it won't be pretty.
  18. Hi, I have a forum ID 397 and I want to change the state of all topics in that forum from Closed to Open. What SQL query would I have to run to do this? If anyone could help, I'd really appreciate it. Thanks in advance. The table is ibf_topics State field is state forum field is forum_id
  19. Ok, now the web page is blank with this code: $rating = mysql_query( "SELECT m.name, p.ovr FROM ibf_members m, ibf_pfields_content p WHERE m.id = p.member_id ORDER BY p.ovr DESC LIMIT 20" ) or die("SELECT Error: ".mysql_error()); $num_rows = mysql_num_rows($rating); $output = "<table border=1> "; while ($get_info = mysql_fetch_row($rating)){ $output .= "<tr> "; foreach ($get_info as $field) $output .= " <td><font face=arial size=1/>$field</font></td> "; $output .= "</tr> "; } return $output; Any help please?
×
×
  • 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.