sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
report error to administrator
-
try $result = mysql_query("SELECT * FROM table WHERE user = '".$member."' AND fileStatus IN('".implode("', '", $file_stat)."')") or die(mysql_error()); swap single and double quotes
-
[SOLVED] inflation, savings and payback calculation
sasa replied to adambeazley's topic in PHP Coding Help
let a = mouhth_bill * 12 (year bill) and q = 1 + inflate_rate (inflate factor) then product_cost = a*saving_factor + a*q*saving_factor + a*q^2*saving_factor + ... + a*q^(n-1)*saving_factor (after n years) product_cost = a*saving_factor*(1 + q + q^2 + ... + q^(n-1)) product_cost = a*saving_factor* (q^n - 1)/(q - 1) (look http://en.wikipedia.org/wiki/Geometric_series#Formula) => q^n = product_cost*(q - 1) / (a*saving_factor) + 1 log(q^n) = log(product_cost*(q - 1) / (a*saving_factor) + 1) n* log(q) = log(product_cost*(q - 1) / (a*saving_factor) + 1) n = log(product_cost*(q - 1) / (a*saving_factor) + 1) / log(q) round up n btw q - 1 = inflate_rate (look line 1) -
print "<a href='$page_name?start=$next&column_name=$column_name&searchterm=$searchtm&searchtype=$searchty'><font face='Verdana' size='2'>NEXT</font></a>"; add searchtype too
-
SELECT a.title, IF(COUNT(b.client_id)>0, 'In use', 'Not in use') AS in_use FROM variables AS a LEFT JOIN clients AS b ON a.title=b.level GROUP BY a.title
-
change $result = mysql_query("Select * From login_table where user_name='$username'"); to $result = mysql_query("Select * From login_table where user_name='$username'") or die(mysql_error());
-
[SOLVED] inflation, savings and payback calculation
sasa replied to adambeazley's topic in PHP Coding Help
<?php $saving_factor = .17;// 17% $inflate_rate = .1;// 10% $product_cost = 428.40; $month_bill = 100; if ($month_bill <= 0 or $saving_factor <= 0) die('never'); if ($inflate_rate != 0) $years = log(($product_cost / $saving_factor / ($month_bill * 12) * $inflate_rate) + 1) / log($inflate_rate + 1); else $years = $product_cost / $saving_factor / ($month_bill * 12); echo 'Your will pay for this product in energy savings in under ', ceil($years), ' year', $years > 1 ? 's' : '', '.'; ?> -
just do while($row = mysql_fetch_array($qry_result)) { $similar_names[] = $row['seat1']; $similar_names[] = $row['seat2']; $similar_names[] = $row['seat3']; }
-
btw 2^30 = 1 073 741 824 min = 17 895 697 h = 745 564 d > 2000 years. Are you shure to want this?
-
try <?php $arrayofwords = array (); $arrayofwords[0] = "This"; $arrayofwords[1] = "text"; $arrayofwords[2] = "need"; $arrayofwords[3] = "words"; $str = 'This is my <img src="" title="This image text"> long text <a href="#">words</a> where I need to highlight words in the HTML text.'; $str = preg_replace ( "/(?!(?:[^<]+>))\b(" . implode ( '|', $arrayofwords ) . ")\b/is", "<strong>\\1</strong>", $str ); echo $str; ?>f/code]
-
are you try this <?php $digits = array(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F'); $hex_arr = array(1,12,5,13,15); foreach ($hex_arr as $d) echo $digits[$d]; ?>
-
ltrim(number_format($number,1),'0');
-
what is error now?
-
change $sql="INSERT INTO name (firstname, lastname,) VALUES ('$_POST[firstname]','$_POST[lastname]',)"; to $sql="INSERT INTO name (firstname, lastname) VALUES ('$_POST[firstname]','$_POST[lastname]')"; you have extra commas
-
try <?php $test = array( 12 => array ( "title" => "My Blog", "parentId" => "0", "url" => "my-blog" ), 13 => array ( "title" => "Job Stuff", "parentId" => "12", "url" => "job-stuff" ), 14 => array ( "title" => "More Job Stuff", "parentId" => "13", "url" => "" ), 15 => array ( "title" => "Another Child", "parentId" => "12", "url" => "" ) ); //rearange array foreach ($test as $k => $v){ $a[$v['parentId']][$k] = $v; } function my_child($a, $id = 0){ $out = array(); foreach ($a[$id] as $k =>$v){ if (isset($a[$k])) $v['children'] = my_child($a, $k); $out[$k] = $v; } return $out; } $x = my_child($a); print_r($x); ?>
-
DELETE FROM table_name WHERE 1 ORDER BY fiel_name LIMIT10
-
try <?php $test = '<embed width="563" height="266" type="application/x-shockwave-flash" flashvars="channelId=67365&brandId=1&channel=#Lipari-TV&server=chat1.ustream.tv" pluginspage="http://www.adobe.com/go/getflashplayer" src="http://www.ustream.tv/IrcClient.swf" allowfullscreen="true" />'; $start = strpos($test, 'channel=#')+9; $end = strpos($test, '&server='); echo substr($test, $start, $end - $start); ?>
-
[SOLVED] Cannot update mysql field : Pulling my hair out
sasa replied to likeaaron's topic in PHP Coding Help
change <? if ($_POST["$submit"]) { $head = $_POST["head"]; $body = $_POST["body"]; $sql = "UPDATE heading SET head='$head',body='$body' WHERE id=$id"; $result = mysql_query($sql) or die (mysql_error()); echo "Ok"; } } ?> to <?php if ($_POST["$submit"]) { $ip = $POST['id']; $head = $_POST["head"]; $body = $_POST["body"]; $sql = "UPDATE heading SET head='$head',body='$body' WHERE id=$id"; $result = mysql_query($sql) or die (mysql_error()); echo "Ok"; } } ?> -
are this code <?php $getthreads="SELECT * FROM forumtutorial_posts WHERE postid = '$page'"; $findamount = mysql_query($getthreads) or die (mysql_error()); //grab all the content while($r=mysql_fetch_array($findamount)) { //the format is $variable = $r["nameofmysqlcolumn"]; - makes it easier to call later CAUSE IM LAZY!! $answer=$r["answered"]; $title=$r['title']; $post=$r['post']; } ?> before this one <td><div align="center"><strong><?=$title?></strong></div></td> </tr> <tr bgcolor="#E6E6E6"> <td height="138"><div align="center" class="style1"><?=$message?></div></td>
-
try <?php $connect = mysql_pconnect("localhost","user","pass") or Die("connect failed"); $selectdb = mysql_select_db("dbase") or Die("select failed"); $query = "SELECT dstchannel,sum(duration) from cdr where calldate like '2009-03-03%' group by substring(dstchannel,3,6)"; $res = mysql_query($query,$connect) or die("failed"); while($qry = mysql_fetch_array($res)) { $dstchannel=$qry["dstchannel"]; $duration = $qry['sum(duration)']; print "$dstchannel"; print "<br>"; print "$duration"; print "<hr>"; }; ?>
-
[SOLVED] Can you help me with inserting and retrieving arrays?
sasa replied to JPark's topic in PHP Coding Help
you must serialize array before insert it in database and unserialize after select it from database -
in 1st file use foreach ($_SESSION["basket"] as $k => $item) { print ("<tr>"); print ("<td>$item</td>"); print ("<td><a href='add.php?delete=$k'>Remove</a></td>"); print ("<tr>"); } and in add.php add if (isset($_GET["delete"])) { if(isset($_SESSION["basket"][$_GET["delete"]])) {unset($_SESSION["basket"][$_GET["delete"]]); $_SESSION["basketcount"]--;} header ("location:http://mi-linux.wlv.ac.uk/~0525154/basket.php"); }
-
... "/\:\!\!\!\:/", "/\:\?\?\?\:/", ... you must ecap '?' and '!' in pattern