Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. try <?php function rd_bld_array($db, $tbl){ // $db = database name, $tbl = table name, $rda = recdata array // init variables // flag to indicate that the loop has past the index indicator $gdata = false; $ctr = 1; $li = 'login'; $pw = 'password'; $dbloc = 'xxx.xxx.x.xxx'; $out = array(); $dbc = mysql_connect($dbloc, $li, $pw); mysql_select_db($db,$dbc); $q = 'SELECT * FROM ' . $tbl; $result = mysql_query($q, $dbc) or die('Error' . mysql_error($dbc)); $fields = mysql_num_fields($result); $rd = array('index', 'fldname','fldtype','flag','length','inval','outval'); for ($ctr = 1; $ctr < $fields; $ctr++){ //if ($gdata == true) { $rd['index'] = $ctr; $rd['fldname'] = mysql_field_name($result, $ctr); $rd['fldtype'] = mysql_field_type($result, $ctr); $rd['flag'] = mysql_field_flags($result, $ctr); $rd['length'] = mysql_field_len($result, $ctr); $rd['inval'] = ''; $rd['outval'] = ''; //} //if (mysql_field_name($result, $ctr) == 'rk') { //$gdata = true; // } echo $ctr . ' ' . $rd['index'] . ' ' . $rd['fldname'] . ' ' . $rd['fldtype'] . ' ' . $rd['flag'] . ' ' . $rd['length'] . '<br>'; $out[] = $rd; } mysql_free_result($result); mysql_close($dbc); //$rd = serialize($rd); $out = serialize($out); return $out; }
  2. <?php function my_old($dob, $now = false){ if (!$now) $now = date('d-m-Y'); $dob = explode('-', $dob); $now = explode('-', $now); $mnt = array(1 => 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); if (($now[2]%400 == 0) or ($now[2]%4==0 and $now[2]%100!=0)) $mnt[2]=29; if($now[0] < $dob[0]){ $now[0] += $mnt[$now[1]-1]; $now[1]--; } if($now[1] < $dob[1]){ $now[1] += 12; $now[2]--; } if($now[2] < $dob[2]) return false; return array('year' => $now[2] - $dob[2], 'mnt' => $now[1] - $dob[1], 'day' => $now[0] - $dob[0]); } $x = my_old('29-4-2008', '28-5-2009'); print_r($x); ?>
  3. this code <?php $year = array(0 => 21, 1 => 28); $ydata = array(0 => 16, 1 => 21); // $ydata2 = array(0 => 5, 1 => 6); // prints an element function myPrint($value) { print "$value "; } //add every element of 1 array with matching element of different array $product_array = array_product_values($year, $ydata); array_walk($product_array, "myPrint"); function array_product_values() { $return = array(); $arrArgs = func_get_args(); foreach($arrArgs as $arrItem) { foreach($arrItem as $k => $v) { if(!isset($return[$k])) { $return[$k] = 1; } $return[$k] *= $v; // it appears '$return[$k] *= $v;' doesn't work } } return $return; } ?> return 336 588 is it ok?
  4. <?php $test = array( Array ('usrPK' => 22, 'usrName' =>'Bob', 'usrDate'=>'08/12/09', 'usrQty'=>'2'), Array ('usrPK' => 22, 'usrName' =>'Bob', 'usrDate'=>'08/12/09', 'usrQty'=>'0.25'), Array ('usrPK' => 10, 'usrName' =>'Billy', 'usrDate'=>'08/12/09', 'usrQty'=>'1') ); $out = array(); foreach ($test as $v){ if (isset($out[$v['usrPK']])) $out[$v['usrPK']]['usrQty']+=$v['usrQty']; else $out[$v['usrPK']]=$v; } print_r($out); ?>
  5. change line $return[$k] = 0; to $return[$k] = 1;
  6. for ($X = $StartX;$StartX<=$EndX;$X++) { for ($Y = $StartY;$StartY<=$EndY;$Y++) { $RandomChoice = $ThePool[array_rand($ThePool)]; if (is_numeric($RandomChoice)) { $MapType = $RandomChoice; $OasisType = '0'; } else { $MapType = '0'; $OasisType = ExtractOasisType($RandomChoice); } $StartID += 1; print("StartID: ".$StartID." X: ".$X." Y: ".$Y." MapType: ".$MapType." OasisType: ".$OasisType."<br />"); } } change variable name in loop
  7. you can use mysql function RAND() with seed in ORDER BY part
  8. change while($row = mysqli_fetch_array($result)){ if (settype(date('F Y',$row['post_date']),"string") == settype($dateformatted,"string")){#is the problem how I formatted this? array_push($days,date('j',$row['post_date'])); } to while($row = mysqli_fetch_array($result)){ $xxx = date('F Y',$row['post_date']); if (settype($xxx,"string") == settype($dateformatted,"string")){#is the problem how I formatted this? array_push($days,date('j',$row['post_date'])); }
  9. 1st read file in string 2nd explode string on <!--ARTICLE--> 3rd do with array elements what you want
  10. try SELECT * FROM `websiteadmin_radio` WHERE find_in_set('$data', replace(call_letters,', ',','))
  11. change line 20 to $SQLOrder = "INSERT into tblOrder (OrID, OrDate, OrCuShipFName,OrCuShipLName,OrCuShipAddress,OrCuShipCity,OrCuShipState,OrCuShipZip,OrCuShipEmail,OrCuShipPhone,OrCuBillFName,OrCuBillLName,OrCuBillAddress,OrCuBillCity,OrCuBillState,OrCuBillZip,OrCuBillEmail,OrItemTotal,OrShippingTotal,OrAuthorization,OrStatus) values('',now(),'$CuInfo[CuShipFName],$CuInfo[CuShipLName]','$CuInfo[CuShipAddress]','$CuInfo[CuShipCity]','$CuInfo[CuShipState]','$CuInfo[OrCuShipZip]','$CuInfo[OrCuShipEmail]','$CuInfo[CuShipPhone]','$CuInfo[OrCuBillFName]','$CuInfo[OrCuBillLName]','$CuInfo[OrCuBillAddress]','$CuInfo[OrCuBillCity]','$CuInfo[OrCuBillState]','$CuInfo[OrCuBillZip]','$CuInfo[OrCuBillEmail]','$_SESSION[total]','','','')";
  12. <?php $var1 = "car1"; $var = "car4"; $cars=array("car1","car2","car3","car4","car5"); $out = array_diff($cars, array($var, $var1)); print_r($out); ?>
  13. try to insert $xcondition = html_entity_decode($xcondition); before eval it
  14. try foreach ($subcontainers as $item) $my_arr[$item['parent_container_name']][] = $item; // add all $item to my_array //print_r($my_arr); function my_div($array, $start,$ident=0){ echo str_repeat("\t",$ident),"<div id=\"$start\">"; if (isset($array[$start])) { echo "\n"; foreach ($array[$start] as $i)my_div($array,$i['attribute_value'],$ident+1);//add what part of $i (item) i want } if (isset($array[$start])) echo str_repeat("\t",$ident); echo "</div>\n"; } my_div($my_arr,'siteContainer');
  15. try <?php $subcontainers =array( Array ( 'parent_container_name' => 'siteContainer', 'attribute_value' => 'header' ), Array ( 'parent_container_name' => 'header', 'attribute_value' => 'logoContainer' ), Array ( 'parent_container_name' => 'header', 'attribute_value' => 'logo' ), Array ( 'parent_container_name' => 'contactInfo', 'attribute_value' => 'logoText' ), Array ( 'parent_container_name' => 'header', 'attribute_value' => 'links' ) , Array ( 'parent_container_name' => 'header', 'attribute_value' => 'contactInfo' ) , Array ( 'parent_container_name' => 'siteContainer', 'attribute_value' => 'body' ) , Array ( 'parent_container_name' => 'body', 'attribute_value' => 'longDiv' ) , Array ( 'parent_container_name' => 'logoText', 'attribute_value' => 'shortDiv' ) , Array ( 'parent_container_name' => 'shortDiv', 'attribute_value' => 'headerText' ) , Array ( 'parent_container_name' => 'body', 'attribute_value' => 'greetings' ) ); foreach ($subcontainers as $item) $my_arr[$item['parent_container_name']][] = $item['attribute_value']; //print_r($my_arr); function my_div($array, $start,$ident=0){ echo str_repeat("\t",$ident),"<div id=\"$start\">"; if (isset($array[$start])) { echo "\n"; foreach ($array[$start] as $i)my_div($array,$i,$ident+1); } if (isset($array[$start])) echo str_repeat("\t",$ident); echo "</div>\n"; } my_div($my_arr,'siteContainer'); ?>
  16. i do some test and it works for me <?php $vcondition = '$row_dsee[\'field1\']>0 and $row_dsee[\'field2\']==0'; $row_dsee['field1']=420; $row_dsee['field2']=0; eval('$xxx = ('.$vcondition. ');'); echo 'condition=',$vcondition,"<br />\n"; echo 'f1=',$row_dsee['field1'],' f2=',$row_dsee['field2'],' $xxx=', var_dump($xxx); echo "<hr />\n"; $vcondition = '$row_dsee[\'field1\']>0 and $row_dsee[\'field2\']==0'; $row_dsee['field1']=1481; $row_dsee['field2']=2459; eval('$xxx = ('.$vcondition. ');'); echo 'condition=',$vcondition,"<br />\n"; echo 'f1=',$row_dsee['field1'],' f2=',$row_dsee['field2'],' $xxx=', var_dump($xxx); echo "<hr />\n"; $vcondition = '$row_dsee[\'field1\']>0 and $row_dsee[\'field2\']>0'; $row_dsee['field1']=420; $row_dsee['field2']=0; eval('$xxx = ('.$vcondition. ');'); echo 'condition=',$vcondition,"<br />\n"; echo 'f1=',$row_dsee['field1'],' f2=',$row_dsee['field2'],' $xxx=', var_dump($xxx); echo "<hr />\n"; $vcondition = '$row_dsee[\'field1\']>0 and $row_dsee[\'field2\']>0'; $row_dsee['field1']=1481; $row_dsee['field2']=2459; eval('$xxx = ('.$vcondition. ');'); echo 'condition=',$vcondition,"<br />\n"; echo 'f1=',$row_dsee['field1'],' f2=',$row_dsee['field2'],' $xxx=', var_dump($xxx); echo "<hr />\n"; ?> output condition=$row_dsee['field1']>0 and $row_dsee['field2']==0 f1=420 f2=0 $xxx=bool(true) -------------------------------------------------------------------------------- condition=$row_dsee['field1']>0 and $row_dsee['field2']==0 f1=1481 f2=2459 $xxx=bool(false) -------------------------------------------------------------------------------- condition=$row_dsee['field1']>0 and $row_dsee['field2']>0 f1=420 f2=0 $xxx=bool(false) -------------------------------------------------------------------------------- condition=$row_dsee['field1']>0 and $row_dsee['field2']>0 f1=1481 f2=2459 $xxx=bool(true) --------------------------------------------------------------------------------
  17. try eval('$xxx = ('.$vcondition. ');');
  18. while($row_cond=mysql_fetch_array($cond)) { $vcondition = $row_cond["condition"]; eval('$xxx = '.$vcondition. ';'); if ($xxx)) { $passed++; } }
  19. <?php $data = file_get_contents('http://sportscapping.com/new/export/?AF28_36/export/all_cappers'); $pat = '#<div id="service_promo">\s*<table cellpadding="%%CELLPADDING%%" cellspacing="%%CELLSPACING%%" border="0">\s*<tr class="promo_header">\s*<th>\s*<b><a [^>]*>([^<]*)</a></b><br>\s*</th>\s*</tr>\s*<tr>\s*<td class="description" valign="top">\s*([^<]*)\s*</td>#'; preg_match_all($pat,$data,$ma); $out = array_combine($ma[1],$ma[2]); print_r($out); ?>
  20. try $pat = '#<div id="service_promo">\s*<table cellpadding="%%CELLPADDING%%" cellspacing="%%CELLSPACING%%" border="0">\s*<tr class="promo_header">\s*<th>\s*<b><a [^>]*>([^<]*)</a></b><br>\s*</th>\s*</tr>\s*<tr>\s*<td class="description" valign="top">\s*([^<]*)\s*</td>#'; preg_match_all($pat,$data,$ma); $out = array_combine($ma[1],$ma[2]); print_r($out);
  21. try $text = preg_replace('#</?div[^>]*>#','',$text);
  22. 1. change echo $passed; to return $passed; in the end of your 1st function. 2. change calls of your functions to $passed=stuff(hq,$dbc); levelup($dbc,$cost,$passed);
  23. look <?php $test = '$testvariable=="Some Text"'; $testvariable="Some Text"; eval('$xxx = '.$test.';'); if ($xxx) echo 'pass'; else echo 'no'; echo "<hr />\n"; $testvariable="Other Text"; eval('$xxx = '.$test.';'); if ($xxx) echo 'pass'; else echo 'no'; ?>
  24. SELECT * FROM `dates` WHERE DATEDIFF('2009-07-01', start_date) BETWEEN 0 AND frequency
  25. or $users_online = User::find_by_sql("SELECT * FROM members WHERE UNIX_TIMESTAMP(last_action) >= '".(time()-600)."' ORDER BY last_action DESC"); echo "There are <b>".count($users_online)."</b> user(s) online within the last 10 minutes:<br />"; $comma = ''; foreach($users_online as $user) { echo $comma, "<a href=\"index.php?profile=$user->username\">$user->username</a>"; $comma = ', '; }
×
×
  • 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.