Jump to content

gibigbig

Members
  • Posts

    125
  • Joined

  • Last visited

Everything posted by gibigbig

  1. ok nevermind, I found my error, thank you so much, your code works great.
  2. not working with my code Warning: array_count_values() [function.array-count-values]: Can only count STRING and INTEGER values! in [path]/downloads2.php on line 270 Let me explain a bit more, I have a table in the database named posts. A field in the posts is named "added_by_userid" and I would like to get the "added_by_userid" with the most records in that table. Maybe this can be done with SQL?
  3. I have an array and I'd like to find the most popular value in the array. example. $arr = array(1,1,1,1,2,2,3,4,5,5,5,5,5,5,5,3,4,198,10293,1,2); I would like only display 5 please.
  4. never mind, solved here http://www.webdeveloper.com/forum/showpost.php?s=86e3796b8262f011819e4dfe353cd371&p=860802&postcount=4 many thanks for the quick feedback though
  5. I have an array and i'd like to make a query that gets all the records if the id is in this array WITHOUT using more than 1 query. basically this SELECT * FROM table_name WHERE episode_id IS IN_ARRAY('$array') i know the above code is wrong but its the best way i can explain it
  6. lol i just checked its working now, turns out i had spelt receipt wrong i had reciept thanks alot bro it really means alot moving this project forward /solved
  7. still no luck Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in [path]/rpg.php on line 211
  8. not working Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in [path]/rpg.php on line 211 my table name is rpg_receipt and the field i want the sum of is "amount_remaining" i edited the query to fit mine and its not working. SELECT item_id, SUM(amount_remaining) AS 'total' FROM rpg_reciept GROUP BY item_id ORDER BY item_id WHERE userid = '".$userid."' AND amount_remaining <> 'none'
  9. Here is my database: receipt_id | item_id | something_here 21 1 2 29 1 10 30 1 3 31 2 9 What i would like to do is display the above data from my database in a table looking like this: receipt_id | item_id | total_something_here 21 1 15 31 2 9 in short, i want to show only different item_id with the sum of something_here field for all records where item_id is the same ie 10 + 3 + 2 = 15 in the above example please help me
  10. The bulk code i have looks like this: function setembedcode(cwidth,cheight) { document.getElementById('embedcode').value = '<object width="' + cwidth + '" height="' + cheight + '"><param name="movie" value="http://www.megavideo.com/v/ZDWFCCMEf5a91463ba9f5539ffffde18eaa9acbf"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.megavideo.com/v/ZDWFCCMEf5a91463ba9f5539ffffde18eaa9acbf" type="application/x-shockwave-flash" allowfullscreen="true" width="' + cwidth + '" height="' + cheight + '"></embed></object>'; } and I need a regular expression to match ONLY the http://www.megavideo.com/v/ZDWFCCMEf5a91463ba9f5539ffffde18eaa9acbf Can anyone help me? My current code is : $embed = file_get_contents($stream_link); preg_match_all( '/http\:\/\/www\.megavideo\.com\/v\/(.*)\"\>/i', $embed, $matches, PREG_SET_ORDER); foreach($matches as $txt){ echo $txt[0].'<br />'; }
  11. Thank you very much sasa worked perfectly *hugs*
  12. $search = $_POST['search']; $replace = $_POST['replace']; $zero = 0; $gibs = mysql_query("SELECT * FROM anime"); while ($gib = mysql_fetch_assoc($gibs)) { $new_description[] = str_replace($search,$replace,$gib['description']); $new_history[] = str_replace($search,$replace,$gib['history']); $anime_id[] = $gib['anime_id']; $numberlinks = ++$zero; } for($i=0; $i<$numberlinks; $i++) { $thequery[] = mysql_query("UPDATE anime SET description = '".mysql_real_escape_string($new_description[$i])."', history='".mysql_real_escape_string($new_history[$i])."' WHERE anime_id='".$anime_id[$i]."'"); } foreach ($thequery as $query){ mysql_query($query) or die (mysql_error()); echo "<span style='color:green'>Edited sucessfully <b>Anime ".++$one."</b> </span><br/>"; } echo "<meta http-equiv='refresh' content='2;url=http://www.website.com/forums/downloads-manager.php?task=fix-descriptions'>"; output: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1 Inputs: $search: ’ $replace: "
  13. I need help arranging a text blob into a table of where each cell is a letter, and the contents of the text blob must be arranged in the table according to what letter it starts with. This is the query I used: $gibs33 = mysql_query("SELECT name,anime_id,sort FROM anime WHERE popular='1' ORDER BY name ASC"); while ($gib33 = mysql_fetch_assoc($gibs33)) { echo '<a href="http://www.website.com/index.php?anime_id='.$gib33['anime_id'].'">'.$gib33['name'].'</a> | '; } The text blob looks like this: I want to arrange this blob into a table like this: #-9 A B C D E .Hack AppleSeed Bleach Blood+ Basilisk Claymore D Gray Man Eureka 7 Elfen Lied F G H I J K Fairy Tail Gundam Seed [/td] [td]K-ON Season 2 etc.... In the Query, anime_id = number example: (189) sort = First letter of the word, example (N) name = Name of the anime, example (Bleach)
  14. http://img194.imageshack.us/img194/6889/86504462.png This is my exact database structure for that table. i simply want all matches with the host "fileserve.com" to be displayed first, then all the other matches.
  15. this seems like what (the primary sort thing) I want, can you please comment on this code line by line so I can follow what it means. it would help greatly
  16. This is my code: $episodes = mysql_query("SELECT * FROM episode_links WHERE episode_id = '".$episode_id."' AND moderated='1' ORDER BY host ASC"); while ($episode = mysql_fetch_assoc($episodes)) { // code here } and in my host table, I have values like this: Fileserve.com MegaUpload.com Rapidshare.com Torrent And I would like a way to sort this so that only the Fileserve links appear on the top ( the first few results), then all the others. can anyone help me?
  17. Ok my input is an array. $episode_number = array('2','99'...'004'); where "..." is any amount of values. My aim is to take these values and format them so that they ALWAYS have 3 characters in them by adding Zero's to the beginning. So 2 will become 002 and 99 will become 099 and 004 will remain 004. I have attempted my code here: for($i=0; $i<$numberlinks; $i++) { $thecount = strlen($episode_number[i]); if($thecount == '1'){ $episode_number[i] == '00'.$episode_number[i].''; } elseif($thecount == '2'){ $episode_number[i] == '0'.$episode_number[i].''; } else { $episode_number[i] == $episode_number[i]; } echo $episode_number[i].'<br />'; } The above output is 2 <br /> tags. But when i add on osme code to it: for($i=0; $i<$numberlinks; $i++) { $thecount = strlen($episode_number[i]); if($thecount == '1'){ $episode_number[i] == '00'.$episode_number[i].''; } elseif($thecount == '2'){ $episode_number[i] == '0'.$episode_number[i].''; } else { $episode_number[i] == $episode_number[i]; } echo $episode_number[i].'<br />'; } $query2[] = ("INSERT INTO episodes (anime_id,anime, username, userid, episode_name, episode_number, manga_chapter_link, moderated) VALUES ('".$anime_id[$i]."', '".$anime[$i]."', '".$username."', '".$userid."', '".clean($episode_name[$i])."', '".clean($episode_number[$i])."', '".clean($manga_chapter_link[$i])."','1')"); } foreach ($query2 as $query){ mysql_query($query) or die (mysql_error()); echo "<span style='color:green'>Added sucessfully <b>Episode ".++$one."</b> </span><br/>"; } the output is the input, ie, 02 remains 02 and not 002. can anyone help me or give me a method that works?
  18. i see, thank you. that should be enough security for my site for now
  19. I have recently downloaded FCK editor, but thats just a clientside editor (a fancy Textarea). I wish to prevent html and sql injections from it. Is there a function that can clean the input before storing it in the database? I have disabled the following abilities from the editor: adding links and anchors viewing html source adding plugin (flash) adding forms and form elements also i have these functions: function Valid_Input($data){ list($data) = preg_split('/\r|\n|%0A|%0D|0x0A|0x0D/i',ltrim($data)); return $data; } and function clean($text) { $text = htmlspecialchars($text, ENT_QUOTES); return ($text); //output clean text } will this be enough? If not, can you give me a function that will.
  20. I have the following code that works fine: <?php error_reporting(0); $change=""; $abc=""; define ("MAX_SIZE","400"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if($_SERVER["REQUEST_METHOD"] == "POST") { $image =$_FILES["file"]["name"]; $uploadedfile = $_FILES['file']['tmp_name']; if ($image) { $filename = stripslashes($_FILES['file']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $change='<div class="msgdiv">Unknown Image extension </div> '; $errors=1; } else { $size=filesize($_FILES['file']['tmp_name']); if ($size > MAX_SIZE*1024) { $change='<div class="msgdiv">You have exceeded the size limit!</div> '; $errors=1; } if($extension=="jpg" || $extension=="jpeg" ) { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); } else if($extension=="png") { $uploadedfile = $_FILES['file']['tmp_name']; $src = imagecreatefrompng($uploadedfile); } else { $src = imagecreatefromgif($uploadedfile); } echo $scr; list($width,$height)=getimagesize($uploadedfile); $newwidth=150; $newheight=($height/$width)*$newwidth; $tmp=imagecreatetruecolor($newwidth,$newheight); $newwidth1=75; $newheight1=($height/$width)*$newwidth1; $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); srand ((double) microtime( )*1000000); $random_number = rand( ); $filename = "rpg-avatar/".$random_number."_". $_FILES['file']['name']; $filename1 = "rpg-avatar/small_".$random_number."_". $_FILES['file']['name']; imagejpeg($tmp,$filename,100); imagejpeg($tmp1,$filename1,100); imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1); }} } //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { // mysql_query("update {$prefix}users set img='$big',img_small='$small' where user_id='$user'"); $change=' <div class="msgdiv">Image Uploaded Successfully!</div>'; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en"><head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> <meta content="en-us" http-equiv="Content-Language"> <title>picture demo</title> <style type="text/css"> .help { font-size:11px; color:#006600; } body { color: #000000; background-color:#999999 ; background:#999999 url(<?php echo $user_row['img_src']; ?>) fixed repeat top left; font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif; } .msgdiv{ width:759px; padding-top:8px; padding-bottom:8px; background-color: #fff; font-weight:bold; font-size:18px;-moz-border-radius: 6px;-webkit-border-radius: 6px; } #container{width:763px;margin:0 auto;padding:3px 0;text-align:left;position:relative; -moz-border-radius: 6px;-webkit-border-radius: 6px; background-color:#FFFFFF } </style> </head><body> <div align="center" id="err"> <?php echo $change; ?> </div> <div id="space"></div> <div id="container" > <div id="con"> <table width="502" cellpadding="0" cellspacing="0" id="main"> <tbody> <tr> <td width="500" height="238" valign="top" id="main_right"> <div id="posts"> <img src="<?php echo $filename; ?>" /> <img src="<?php echo $filename1; ?>" /> <form method="post" action="" enctype="multipart/form-data" name="form1"> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0"> <tr><Td style="height:25px"> </Td></tr> <tr> <td width="150"><div align="right" class="titles">Picture : </div></td> <td width="350" align="left"> <div align="left"> <input size="25" name="file" type="file" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10pt" class="box"/> <input size="25" name="file2" type="file" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10pt" class="box"/> </div></td> </tr> <tr><Td></Td> <Td valign="top" height="35px" class="help">Image maximum size <b>400 </b>kb</span></Td> </tr> <tr><Td></Td><Td valign="top" height="35px"><input type="submit" id="mybut" value=" Upload " name="Submit"/></Td></tr> <tr> <td width="200"> </td> <td width="200"><table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="200" align="center"><div align="left"></div></td> <td width="100"> </td> </tr> </table></td> </tr> </table> </form> </div> </td> </tr> </tbody> </table> </div> </div> </body></html> But i would like to tweak it so that it there are two image upload forms and these two images are both resized and stored. example: what the script does now is: form 1 => (processing) => resized image + thumb what i want it to do is form1 + 2 => (processing) => (resized image 1 + thumb 1) + (resized image2 + thumb2)
  21. its ok guys i fixed it myself seems this mystery number was the "avatar revision" number which is stored in the database in the user table. thanks for your quick responses. <3 phpfreaks.com
  22. Parse error: syntax error, unexpected '*' in /filexxxx on line 97 i replaced my real file name and its dir with filexxxx for security
×
×
  • 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.