PHP - Count 'banned'
I want to get the COUNT if any of these fields (Fielda, Fieldb, Fieldc, Fieldd, Fielde, Fieldf, Fieldg, Fieldh) contain the word "Banned". But this code doesn't work.
$like = count("Fielda, Fieldb, Fieldc, Fieldd, Fielde, Fieldf, Fieldg, Fieldh LIKE '%".implode("%' OR Fielda, Fieldb, Fieldc, Fieldd, Fielde, Fieldf, Fieldg, Fieldh LIKE '%", explode('Banned'))."%'"); echo($like); Similar Tutorialshello i have the following question i have a script that gets the user ip and if the ip is in the 'file' it redirects it to google <?php $ip=$_SERVER['REMOTE_ADDR']; $file=file('bad_ips'); foreach($file as $files){ if(stristr($files, $ip) === FALSE) { header('location:index1.php'); }else { header('location:http://google.com'); } } ?> in the file the ips are line by line example: 2.2.2.2 4.4.4.4 but the problem is this if the ip `2.2.2.2` enters i wnat to search in the file for just 2.2 if searches only if i put the entire ip in the `file` 2.2.2.2 Im wanting to not allow people to post any links in the comments section of a form (spammers) and have created a comma delimited list of essentially of every known domain name extension. To apply the filter I have the following code: Code: [Select] $WordAllowed = true; $BannedWords = explode(",", ReadDB($Options["ban_words"])); if (count($BannedWords)>0) { $checkComment = strtolower($_REQUEST["comment"]); for($i=0;$i<count($BannedWords);$i++){ $banWord = trim($BannedWords[$i]); if (trim($BannedWords[$i])<>'') { if(preg_match("/".$banWord."/i", $checkComment)){ $WordAllowed = false; break; } } } } if($WordAllowed==false) { $SysMessage = $OptionsLang["Banned_word_used"]; } else { Insert into my table I could have sworn this was working last time I was in this code but recently checking it again it is blocking pretty much everything claiming a banned word is used. The only thing I can get to post is 'lol'. Trying funny phrases like: first! or Great information, thanks, this is a test of the comment section, etc....they all get flagged Can anyone with fresh eyes assist? Im weary and frustrated and its been forever since I wrapped my head around this. My banned word list: Code: [Select] www,http,com,org,.aero,.asia,.biz,.com,.coop,.edu,.gov,.info,.int,.jobs,.mil,.mobi,.museum,.name,.net,.org, .pro,.tel,.travel,.xxx,.a,.bitnet,.ac,.ad,.ae,.af,.ag,.ai,.al,.am,.an,.ao,.aq,.ar,.as,.at,.au,.aw,.az,.ba,.bb,.bd,.be,.bf,.bg ,.bh,.bi,.bj,.bm,.bn,.bo,.br,.bs,.bt,.bv,.bw,.by,.bz,.ca,.cc,.cf,.cg,.ch,.ci,.ck,.cl,.cm,.cn,.co,.com,.cr,.cs,.cu,.cv,.cx,.cy,.cz ,.de,.dj,.dk,.dm,.do,.dz,.ec,.edu,.ee,.eg,.eh,.er,.es,.et,.fi,.fj,.fk,.fm,.fo,.fr,.fx,.ga,.gb,.gd,.ge,.gf,.gh,.gi,.gl,.gm,.gn ,.gov,.gp,.gq,.gr,.gs,.gt,.gu,.gw,.gy,.hk,.hm,.hn,.hr,.ht,.hu,.id,.ie,.il,.in,.io,.iq,.ir,.is,.it,.jm,.jo,.jp,.ke,.kg,.kh,.ki,.km ,.kn,.kp,.kr,.kw,.ky,.kz,.la,.lb,.lc,.li,.lk,.lr,.ls,.lt,.lu,.lv,.ly,.ma,.mc,.md,.mg,.mh,.mil,.mk,.ml,.mm,.mn,.mo,.mp,.mq,.mr, .ms,.mt,.mu,.mv,.mw,.mx,.my,.mz,.na,.nc,.ne,.net,.nf,.ng,.ni,.nl,.no,.np,.nr,.nt,.nu,.nz,.om,.org,.pa,.pe,.pf,.pg,.ph, .pk,.pl,.pm,.pn,.pr,.pt,.pw,.py,.qa,.re,.ro,.ru,.rw,.sa,.sb,.sc,.sd,.se,.sg,.sh,.si,.sj,.sk,.sl,.sm,.sn,.so,.sr,.st,.su,.sv, .sy,.sz,.tc,.td,.tf,.tg,.th,.tj,.tk,.tm,.tn,.to,.tp,.tr,.tt,.tv,.tw,.tz,.ua,.ug,.uk,.um,.us,.uy,.uz,.va,.vc,.ve,.vg,.vi,.vn,.vu,.wf, .ws,.ye,.yt,.yu,.za,.zm,.zr,.zw Thanks in advance for any help Hi guys, I need your help. I am trying to insert the rows in the mysql database as I input the values in the url bar which it would be like this: Code: [Select] www.mysite.com/testupdate.php?user=tester&pass=test&user1=tester&email=me@shitmail.com&ip=myisp However i have got a error which i don't know how to fix it. Error: Column count doesn't match value count at row 1 <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbusername'); define('DB_PASSWORD', 'mydbpassword'); define('DB_DATABASE', 'mydbname'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $username = clean($_GET['user']); $password = clean($_GET['pass']); $adduser = clean($_GET['user1']); $email = clean($_GET['email']); $IP = clean($_GET['ip']); if($username == '') { $errmsg_arr[] = 'username is missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'PASSWORD is missing'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $sql = "INSERT INTO `members` (`username`,`email`,`IP`) VALUES ('$adduser','$email','$IP')"; if (!mysql_query($sql,$link)) { die('Error: ' . mysql_error()); } echo "The information have been updated."; } ?> Here's the name of the columns i have got in my database: Code: [Select] username IP I have input the correct columns names, so I can't correct the problem I am getting. Please can you help? This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=331562.0 Why am I getting this error when there are 3 Fields with 3 values? Column count doesn't match value count at row 1 Code: [Select] $sql5="INSERT INTO participants (participant_name, team_no, sport) VALUES ('".implode("','$_POST[team]'),('",$_POST['participant_name'])."','$_POST[team]','$sport')"; Anyone can help me? <?php $tbl_name="menu"; $kategorije = mysql_query("SELECT * FROM $tbl_name WHERE Left(menu_name, 1) BETWEEN 'A' AND 'M' ORDER BY menu_name ASC"); if (!$kategorije) { die("Database query failed: " . mysql_error()); } while ($row=mysql_fetch_array( $kategorije )) { echo "<div id=lista-header><h4>{$row["menu_name"]}</h4></div>"; $id_sub=$row['id_menu']; $podkategorije = mysql_query("SELECT * FROM submenu WHERE id_menu=$id_sub ORDER BY sub_name ASC", $connection); if (!$podkategorije) { die("Database query failed: " . mysql_error()); } echo "<ul class=\"pod\">"; while ($pod=mysql_fetch_array( $podkategorije )) { echo "<li><a href=index.php?=podkate?".$pod["id_sub"]." class=black>{$pod["sub_name"]}</a><hr size=1 align=left width=100px color=#cccccc></li>"; } echo "</ul>"; } ?> In this way, I get list with categories and hes subcategories. How to count how many subcategories have each categories, and count how many articles have each categories? Example (I wanna get this kind of look): Categories name (3) subcategoriesname (2) subcategoriesname (4) subcategoriesname (7) Categories name (5) subcategoriesname (1) subcategoriesname (14) subcategoriesname (9) subcategoriesname (2) subcategoriesname ( Categories name (2) subcategoriesname (28) subcategoriesname (17) Where the numbers represent how many categories and sub-items have articles returns -30. how can i remove the minus so it just returns 30 Code: [Select] $days = (strtotime(date("Y-m-d")) - strtotime($info['expiredate'])) / (60 * 60 * 24) echo $days Hello, I'm using the following code to count the amount of SQL results and divide it. Works great as is but I want to alter it so it works with categories. $amount = mysql_query('SELECT COUNT(`car_id`) AS num FROM `tbl_cars`') or die(mysql_error()); $amount_row = mysql_fetch_assoc($amount); I tried adding... WHERE car_cat = '".$cat."' which causes an error. Why doesn't this work, and how can I get the amount of results as a variable? Hey All, I need to count and display the number of rows I have. <?php //declare the SQL statement that will query the database $query = " SELECT COUNT(id) FROM connectvisits WHERE staffid = '$staffid' "; //execute the SQL query and return records $result = mssql_query($query); $thismonth = mssql_num_rows($result); echo "Total Meetings This Month: "; echo $thismonth; echo "<br />"; ?> For some reason I keep getting a result of 1. Everything else I try gives me a "Resource ID" number. Any help would be apprecaited. Maybe I have the completely wrong code. Thanks! Hello,
I am trying to get the report of my sales table. I want to get total number of leads for each month. And then i have to use this data to create graph using google graph.
But i am not getting how eactly i can get this.
Here is my code
<?php if(isset($_POST['submit'])) { $type = $_POST['type']; $sql="select * from leads where lead_customer='".$type."'"; $query=mysql_query($sql); while ($row = mysql_fetch_array($query)) { list($year,$month,$day)=explode("-", $row['last_modified']); $l = $row['last_modified']; $count=mysql_num_rows($month); echo $count; $myurl[] = "['".$month."', ".$count."]"; } print_r($myurl); echo implode(",", $myurl); } ?>But for $count, it doesn't show any values. below is my database. Capture.PNG 18.16KB 0 downloads Please suggest me hey i'm just woundering how i would go abouts on echoing unread messages sent to a user i want to beable to see how many unread messages i have I want the quickest(least resource hungry) way of getting the number of specific rows from a large table. E.g I want to retrieve the number of entries by a specific username. What would be the best method? To use COUNT or just SELECT num_rows? Method 1: ------------- $query = "SELECT COUNT(usrname) AS usrname FROM table WHERE usrname='$usrname' "; $res = mysql_query($query) or die(mysql_error()); $array = mysql_fetch_array($res, MYSQL_ASSOC); $count = $array['usrname']; Method 2: ------------- $query = "SELECT usrname FROM table WHERE usrname='$usrname' "; $res = mysql_query($query) or die(mysql_error()); $count = mysql_num_rows($res); Personally I think method 2 would be quicker but I read alot about using count() to speed things up. Thanks! Hey, having an odd issue, looking to show players whos within 25 ranks of them lower and higher, i'm unsure as to why the following code doesn't actually do it... would anyone care to explain... Code: [Select] <?php $score = $playerdata['score']; $sql = "SELECT * FROM `players` WHERE '$score' BETWEEN 25 AND 75 ORDER BY `score` DESC"; $query = mysql_query($sql) or die(mysql_error()); $i=0; while($players = mysql_fetch_array($query)) { $i++; ?> This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=320042.0 I have an XML document that id decrypted and shown onto a table. At the bottom of the page, I'm trying to have it count up one Code: [Select] foreach($Data as $Types) // loop through book foreach($Types as $Colors) // loop through book { print_r(count($Colors->Color)); } There are 4 colors, blue, green, red, yellow. Blue is listed 7 times, green is 3, red is 8, and yellow is 4 times. What I expect it to print is: 7 3 8 4 Instead, it's printing this: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 If I was to just do the print function without count, it lists like this: blue red blue red green yellow blue red yellow red red green yellow yellow blue blue green blue yellow blue red red blue red My end-goal of this code is to get it to print this: Blue: 7 Green: 3 Red: 8 Yellow: 4 Hi fellas, having a bit of trouble getting a count from the database where the field is not empty? $count= "SELECT COUNT(unid) FROM table"; $result2 = mysql_query($count) or die("Select Failed!"); $counter = mysql_fetch_array($result2); echo $counter[0]; From what i have read, this should get all the not null results from the field, but it gets all of them. Some are empty, the ones i want have various id numbers in them. Is there a way to get just the numbers where there is an id number present? Can any one tell me whats the best ( actually error free ) which i can use to count the number of rows finally resulting after select command. I use this ... Code: [Select] $sql = mysql_query("select * from usname where name1='$name1' and name2='$name2' and amm='$amm'"); $num=mysql_num_rows($sql); echo $num; But it always gives the same error.... and the error is.......... Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\money\insert.php on line 20 where line 20 is... Code: [Select] $num=mysql_num_rows($sql); - Pranshu Agrawal pranshu.a.11@gmail.com Hi, I want the user to be able to go to one page and hit a button, once he hits the butten I want a count down to start from 10 minutes. When the user goes to the page within those 10 minutes, I want it to show him a live countdown until those ten minutes run out. Any ideas how I would go about doing this? I have this SQL query that gathers set information for the Salesperson($user) that is logged in and viewing theri need information. Everything works weell, except my Loop Count. I don't know, what I am doping incorrectly. It returns only two values which are the same. But the Query returns 10 values for that user. When I run the query direct in SQL DB. What am I missing? Code: [Select] <div class='page_content clearfix'> <div class='grid_8 first'> <?php $salesPersonId = & JFactory::getUser()->get('username'); //$merchantId = JFactory::getSession()->get('merchantId'); $db =& JFactory::getDBO(); $query = " SELECT XXX_merchant.*, XXX_merchant.name as MercName, XXX_merchant.address as MercAddress FROM XXX_sales_person, jXXX_merchant WHERE XXX_sales_person.user_name = '$salesPersonId' AND XXX_merchant.sales_person_id = XXX_sales_person.id"; $db->setQuery( $query ); $row = $db->loadObject(); //echo $query; //echo $query; //echo '<br>'; //echo $salesPerson->name; ?> <?php $link = 'index.php?option=XXX&controller=deal&task=view&id=' . $row->id; $count = 0; foreach ( $row as $row): $link = '/index.php?option=XXX&controller=merchant&task=edit&cid[]=' . $row->id; ?> <div class='quickie_login grid_9 last' style="width: 140px"> <div class='text_center' id='login_banner'> <div class='page_content text_center'> <div class="avatar" style="float: left; margin-top: -10px; padding: 0px;"> <a class="k2Avatar ubAvatar" href="<?php echo $link; ?>" title="<?php echo JText::_($row->MercName); ?> Edit Account" target="_blank"> <span class="ubName" style="display: block; margin-top: -20px;"><b><?php echo $row->MercName; ?></b> </span> <?php if(!empty($row->logo_url)) { $imagePathArr = unserialize(urldecode($row->logo_url)); $link='http://'; $link.= $_SERVER["SERVER_NAME"].$link_server.DS; $link.=$imagePathArr[0]; $link =str_replace("\\","/",$link); ?> <img src='<?php echo $link; ?>' alt="<?php echo $row->name; ?>" style="max-width: 100px; height:100px;"/> <?php } ?> </a> </div> <div class="sales-system2"> <div style="display: block; margin-top: 0px;"> </div> </div> </div> </div> <?php endforeach;?> |