sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
Warning: Missing argument 3 when I only need to pass 2 parameters
sasa replied to leefentress's topic in PHP Coding Help
function AddCart($cd, $frompage, $off='deafult value') -
try <?php function is_cube($n) { $root = round(pow($n,1/3)); $root = (int) ($root * $root * $root); return $root == $n; } echo is_cube(343); ?>
-
or array_sum(array_map(create_function('$a','return $a["price"];'), $test));
-
try <?php $parents = array("Nick"=>2,"Kristin"=>2,"Mark"=>1,"Missy"=>1); $children = array("Peyton"=>2,"Greddy"=>2,"Abby"=>1,"Will"=>1); if (isset($_POST['submit'])){ $parent = $_POST['parent']; $child = $_POST['child']; echo "Question : Is $parent the parent of $child?<br />\n"; echo "Your ansver : $_POST[ansver]<br />\n"; $ansver = $parents[$_POST['parent']]==$children[$_POST['child']] ? 'yes' : 'no'; if ($_POST['ansver'] == $ansver) echo 'That is correct'; else echo 'You are wrong'; echo '<br /><a href="">Try again</a>'; } else { $parent = array_rand($parents); $child = array_rand($children); echo "Is $parent the parent of $child?"; echo '<form method="post" action=""> <input type="hidden" name="parent" value="', $parent, '" <input type="hidden" name="child" value="', $child, '" <input type="radio" name="ansver" value="yes">Yes <br> <input type="radio" name="ansver" value="no">No <br> <input type="submit" name="submit" value="submit"> </form>'; } ?>
-
try <? require_once '../../functions.php'; $searchbrand = ''; if (isset($_POST['txtSearchBrand'])) $searchbrand = $_POST['txtSearchBrand']; elseif (isset($_GET['s'])) $searchbrand = $_GET['s']; $sql = "SELECT * FROM cstockitems WHERE Category LIKE '%$searchbrand%' OR Brand LIKE '%$searchbrand%' "; $rowsPerPage = 10; $result = dbQuery(getPagingQuery($sql, $rowsPerPage)); $pagingLink = getPagingLink($sql, $rowsPerPage, "s=$searchbrand"); ?> etc.
-
try <?php function echo_menu($menu_array, $labels, $ident = 0, $start = 0){ $ide = '--'; foreach ($menu_array[$start] as $label ){ echo str_repeat('--', $ident), $labels[$label], "<br />\n"; if (isset($menu_array[$label])) echo_menu($menu_array, $labels, $ident + 1, $label); } } mysql_connect('localhost', 'root'); mysql_select_db('test'); $sql = 'SELECT * FROM menus'; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)){ $labels[$row['id_mnu']] = $row['label_mnu']; $cat = $row['idmnu_mnu'] ? $row['idmnu_mnu'] : 0; $menu[$cat][] = $row['id_mnu']; } echo_menu($menu, $labels); ?>
-
try SELECT SUM( bud ) AS bud, SUM( fruit ) AS fruit, SUM( color ) AS color, SUM( ripe ) AS ripe FROM `fruits` WHERE fruit_id = 'apple' OR fruit_id = 'orange'
-
changr line echo $list['id'] . " : " . $list['name'] . "<br />"; to echo $list['id'] . " : <a href='http://www.maza4fun.com/joke/?id=$list[id]'" . $list['name'] . "</a><br />";
-
[SOLVED] Getting information from outside sources?
sasa replied to al3x8730's topic in PHP Coding Help
in 1st subarray (index0) is all data in 2nd is name then title ,lvl, experience, gardner foreach ($out[0] as $k => $v){ echo 'name: ', $out[1][$k], ', title: ', $out[2][$k], ', lvl ', $out[3][$k], ', experience: ', $out[4][$k], ', gardner: ',$out[5][$k], "<br />\n"; } -
where is variable $category is setup?
-
[SOLVED] Getting information from outside sources?
sasa replied to al3x8730's topic in PHP Coding Help
try <?php $test = file_get_contents('http://game.endless-online.com/playerlist.html'); //echo $test; preg_match_all('|<td width="155"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="155"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="50"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="100"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="70"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td>|is',$test, $out); print_r($out); ?> -
try SELECT t.team_id, t.level, t.name, t.initials, t.owner, l.user_id, SUM(l.2playerpts) AS vr2playerpts, SUM(l.4playerpts) AS vr4playerpts,SUM(l.6playerpts) AS vr6playerpts, SUM(l.8playerpts) AS vr8playerpts, l.wins, l.losses, u.user_id, u.team_id FROM teams t INNER JOIN users u ON u.team_id = t.team_id INNER JOIN leaderboard l ON l.user_id = u.user_id GROUP BY t.team_id ORDER BY SUM(2playerpts + 4playerpts + 6playerpts + 8playerpts) DESC
-
try <?php $page = '<font style="font-size: 20px;"><a href="http://www.domain.com/search.php?query=keyword">keyword</a></font></br> <font style="font-size: 17px;"><a href="http://www.domain.com/search.php?query="></a></font></br> <font style="font-size: 17px;"><a href="http://www.domain.com/search.php?query=keyword">keyword</a></font></br> <font style="font-size: 20px;"><a href="http://www.domain.com/search.php?query="></a></font></br> <font style="font-size: 16px;"><a href="http://www.domain.com/search.php?query=keyword">keyword</a></font></br> <font style="font-size: 30px;"><a href="http://www.domain.com/search.php?query=keyword">keyword</a></font></br> <font style="font-size: 14px;"><a href="http://www.domain.com/search.php?query="></a></font></br> <font style="font-size: 10px;"><a href="http://www.domain.com/search.php?query=keyword">keyword</a></font></br> <font style="font-size: 28px;"><a href="http://www.domain.com/search.php?query="></a></font></br> '; $nodups = array_unique (explode ("\n", preg_replace("/\d\dpx/", "20px", $page))); echo implode("\n",array_slice($nodups,-101,100)); ?>
-
try to change alias name from 2playerpts to something diferent etc.
-
look <?php $count = 0; echo ""; //The path to the style directory $dirpath = "pdf/"; $dl = opendir($dirpath); while ($file = readdir($dl) and $count < 3) { //admit sub directories if (!is_dir("$dirpath/$file")) { if (strlen($file) < 7){ echo "$file"; $count++; } } } closedir($dl); //Close Select ?>
-
look <?php $text = 'a,b,cde,fgh'; $word = 'cde'; $text = explode(',', $text); if (in_array($word, $text)) echo 'found'; else echo 'not found'; ?>
-
remove last , (one before WHERE)
-
try <?php $text = 'Hello<br />My name<br />is<br />Swamp<br />I need help<br />with this script'; $text = explode('<br />',$text); $text =array_chunk($text, 3); foreach ($text As $k => $v) $text[$k] = implode('<br />', $v); print_r($text); ?>
-
try <?php $dir = '/home/webzcart/public_html/resource/images/'; foreach(glob($dir . '*.jpg') as $file) $filenames[] = basename($file); $result = mysql_query("SELECT DISTINCT product_image_path, product_image FROM products WHERE product_vendor != 'DropShipDirect' AND product_image_path != ''"); while ($row = mysql_fetch_assoc($result)) { if (!in_array($row['product_image'], $filenames)) { copyFile($row['product_image_path'], $row['product_image'], "images/"); } } ?>
-
try <?php function comb($a){ $out = array(); if (count($a) == 1) { $x = array_shift($a); foreach ($x as $v) $out[] = array($v); return $out; } foreach ($a as $k => $v){ $b = $a; unset($b[$k]); $x = comb($b); foreach ($v as $v1){ foreach ($x As $v2) $out[] = array_merge(array($v1), $v2); } } return $out; } $test = array(array('red', 'blue', 'green'),array('small', 'med', 'large'),array('car', 'truck', 'van')); $x = comb($test); print_r($x); ?>
-
... ORDER BY FIELD(id, 38, 223, 222) DESC, name
-
... ORDER BY FIELD(id, 38, 223, 222) DESC
-
look http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in-set
-
How do I call and execute a php script that is in another file
sasa replied to emehrkay's topic in PHP Coding Help
try <?php echo "File:<br/>\n"; echo file_get_contents('hello.php'). "\n<br/>\nOutput:<br/>\n"; echo file_get_contents('http://localhost/test/hello.php'); ?> -
try <?php function add_return($a,$b) { $total = $a + $b; return $total; } function add_echo($a,$b) { $total = $a + $b; echo $total; } $a = 3; $b = 5; echo "$a + $b = ". add_return($a, $b). "<hr />\n"; echo "$a + $b = ". add_echo($a, $b). "<hr />\n"; ?>