Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. try <?php function permutations($letters,$num){ $last = str_repeat($letters{0},$num); $result = array(); while($last != str_repeat(lastchar($letters),$num)){ $result[] = $last; $last = char_add($letters,$last,$num-1); } $result[] = $last; return $result; } function char_add($digits,$string,$char){ if($string{$char} <> lastchar($digits)){ $string{$char} = $digits{strpos($digits,$string{$char})+1}; return $string; }else{ $string = changeall($string,$digits{0},$char); return char_add($digits,$string,$char-1); } } function lastchar($string){ return $string{strlen($string)-1}; } function changeall($string,$char,$start = 0,$end = 0){ if($end == 0) $end = strlen($string)-1; for($i=$start;$i<=$end;$i++){ $string{$i} = $char; } return $string; } function my_remove($array){ foreach ($array as $k => $v){ $c = str_split($v); sort($c); $c = implode('',$c); if ($v != $c) unset($array[$k]); } return array_values($array); } $number = '1234'; $digit = 2; $Array=permutations($number,$digit); $Array = my_remove($Array); for($i=0 ; $i < count($Array) ; $i++) { echo $Array[$i] . "<BR>\n"; } ?>
  2. escape ' in It's change It's to It\'s
  3. remove <'php from line 38 in line 152 you have else with no if before
  4. if ($crank <= 4) { ?> Player 1: <Select name='player1'> <?php $result = mysql_query("SELECT * FROM users order by rank"); while($row = mysql_fetch_assoc($result)){ $name = $row['username']; echo "<option value='$name'>$name</option>"; } ?> </select> <?php } else { echo('Sorry, only Corporals or above may Recruit at this time'); echo('<br><a href="console.php">Back To Console</a>'); } include("footer.php");
  5. add ; to the end of 48th line
  6. you don't close while block and if block before else
  7. in your function change 'echo' to 'return'
  8. try <?php function get_prev_and_last_items($id){ $arr['prev'] = 0; $arr['next'] = 0; $id = (int) $id; if($id == 0) return $arr; $cond = ""; if(isset($_GET['category_id'])){ $cat = (int) $_GET['category_id']; if($cat != 0){ $cond = " WHERE category_id = '$cat' "; } } $select = $this->db->query("SELECT * FROM item $cond ORDER BY item_id"); $items_in_cat = array(); while($row = mysql_fetch_assoc($select)){ array_push($items_in_cat,$row['item_id']); } /* foreach($items_in_cat as $i){ if($i < $id){ $arr['prev'] = $i; } if($i > $id){ $arr['next'] = $i; break; } } */ $key = array_search($id, $items_in_cat); if ($key > 0) $arr['prev'] = $items_in_cat[$key - 1]; if ($key < count($items_in_cat) - 1) $arr['next'] = $items_in_cat[$key + 1]; return $arr; } ?>
  9. $request = db_query("SELECT * FROM (SELECT att.ID_ATTACH, att.ID_MSG, att.filename, mem.ID_MEMBER, m.ID_TOPIC, m.subject, t.ID_BOARD FROM smf_attachments AS att INNER JOIN smf_messages AS m ON (m.ID_MSG = att.ID_MSG) INNER JOIN smf_topics AS t ON (t.ID_TOPIC = m.ID_TOPIC) LEFT JOIN smf_members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER) LEFT JOIN smf_boards AS b ON (b.ID_BOARD = t.ID_BOARD) WHERE att.attachmentType = 0 AND t.ID_BOARD IN (65,66) ORDER BY att.ID_ATTACH DESC LIMIT 10) ORDER BY RAND() LIMIT 1");
  10. add " to the end of your SQL command ... `location` LIKE '%$keyword%'"));
  11. try function changeGameState($GameId) { $res = mysql_query("UPDATE challenges SET status=status+1 WHERE id='$GameId'"); return mysql_affected_rows($res); } if (changeGameState($someId)) { //was successful }
  12. try to add else part of your if statement if (file_exists("$dirpath$headshot/$posername.jpg")) { if ($iframe == "yes") { print "<a href=$folder/roster.php?username=$username target=_top><img src=$folder$headshot/$posername.jpg border=0 align=left width=".$bioheadwidth." height=".$bioheadheight." hspace=5 vspace=5></img></a>\n"; } else { print "<a href=$folder/bio.php?username=$username target=_top><img src=$folder$headshot/$posername.jpg border=0 align=left width=".$bioheadwidth." height=".$bioheadheight." hspace=5 vspace=0></img></a>\n"; } } else echo "<br />can't find file: $dirpath$headshot/$posername.jpg\<br />\n";
  13. $xml=file_get_contents('http://twitter.com/users/show.xml?screen_name='.$my_twitter_username);
  14. add 'ORDER BY States, Cities, Gyms' after WHERE part of your SQL
  15. <?php // echo table header echo "<table>\n<tr><td>Picture</td><td>Details</td><td> </td><td>Picture</td><td>Details</td></tr>\n"; $count = 0; while ($row = mysql_fetch_array($result)){ if ($count == 0) echo "<tr>\n"; $count++; // echo your data echo "<td>$row[picture]</td><td>$row[details]</td>\n"; if ($count < 2) echo "<td> </td>\n"; else { echo "</tr>\n"; $count = 0; } } if ($count) { for ($i = 0; $i < 2; $i++) echo "<td> </td>"; echo "</tr>\n"; } echo "</table>\n"; ?>
  16. change line if($empty($name)){ to if(empty($name)){ rremove 1st $
  17. sorry i'm in hospital with broken arm and read laffin's post that my code don't work well and analgetic is go out and ...
  18. what is median ? isn't it 62.5?
  19. script chose number from 0 to 10000 and for number 0 to 424 script chose 4th option (its 424 numbers) 4.24% for number 425 to 2126 script chose 3rd option (its 1701 numbers) 17.01% for number 2127 to 3191 script chose 2nd option (its 1063 numbers) 10.63% for number 3191 to 10000 script chose 1st option (its 6809 numbers) 68.09%
  20. i try<?php $items = array( 'lint' => 40, 'copper coin' => 30, 'silver coin' => 15, 'gold coin' => 5, 'bank note' => 5 ); $total = array( 'lint' => 0, 'copper coin' => 0, 'silver coin' => 0, 'gold coin' => 0, 'bank note' => 0 ); for ($i=0;$i<2000;$i++) { $c = rand(1, array_sum($items)); foreach ($items as $item => $v){ if ($c > $v) $c -=$v; else break; } $total[$item]++; //echo $item, "\n"; } print_r($total); ?> and it outputs[/code]X-Powered-By: PHP/5.2.0 Content-type: text/html Array ( [lint] => 835 [copper coin] => 615 [silver coin] => 342 [gold coin] => 103 [bank note] => 105 )[/code]
  21. <?php $items = array( 'lint' => 40, 'copper coin' => 30, 'silver coin' => 20, 'gold coin' => 10 ); echo $c = rand(1, array_sum($items)); foreach ($items as $item => $v){ if ($c > $v) $c -=$v; else break; } echo $item; ?>
  22. try <?php $con = mysql_connect('localhost','root',''); mysql_select_db('test'); $sql = "SELECT `CITY`, GROUP_CONCAT(name SEPARATOR '</li><li>') AS list FROM `data_table` GROUP BY CITY"; $result = mysql_query($sql); echo "<ul>\n"; while ($row = mysql_fetch_assoc($result)){ echo "<li>$row[CITY]</li>\n"; echo "<ul><li>$row[list]</li></ul>\n"; } echo "</ul>"; ?>
  23. try <?php $test = '#username1#usrname2'; $out = explode('#', $test); array_shift($out); array_pop($out); print_r($out); ?>
×
×
  • 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.