PHP - Php Code To Find Out Model Of A Mobile Phone.
Dear Members,
I am a PHP developer and desisgning a WAP page for mobiles.I need some php code to find out the model of a mobile phone from where request is coming so that based on that information I can upload the proper CSS for my page.If you can give me some hints as well that would also help me to proceed further.Currently I am able to fetch user-agent of mobile but not able to find out the specific model of mobile. Similar Tutorialshello, i cant find this anywhere on the internet. i dont even know what to search. if you are on your phone and there is a phone number on a web page, sometimes you can click on that number and it will dial it. how can i do that? hello I've some code and I want find and cut url from it using php. this url link between 1 - 5 link. this mean some times 1 URL in the code sometimes 2 url in the code and ... can anyone help me? Code: [Select] MB</div><br/> <br/> <br/> <b><br/> DOWNLOAD<br/> <br/> <a href="http://uploading.com/files/c2182562/LIBERO%252B24%252BLUGLIO%252B2010.pdf/" target="_blank" rel="nofollow">http://uploading.com/files/c2182562/LIBERO%2B24%2BLUGLIO%2B2010.pdf/</a><br/> <br/> <br/> <br/> <br/> <a href="http://rapidshare.com/files/408736098/LIBERO_24_LUGLIO_2010.pdf.html" target="_blank" rel="nofollow">http://rapidshare.com/files/408736098/LIBERO_24_LUGLIO_2010.pdf.html</a></b> </div> <table class='file-express' width='100%'> <tr> <td style='text-align: left; color: #B2AC94; font-size: 3'><br>titletm= LIBERO 24 LUGLIO 2010 LIBERO 24 LUGLIO 2010 :found<br><font color="blue">2</font>http://www.avaxhome.ws/magazines/everyday_practical_electronics_vol_33_no_5_2004.html<br>File exists.dllink'MB</div><br/> <br/> <br/> Hey all, Basically I have this code which technically should work, but I have put an error in the logic somewhere and am really struggling to find it, I've been going over it for about an hour now :/ The error is that in the second part (// Enter them into the activities database if they're not already there), it won't enter them, and it won't show the word 'Randomevent1' either, so clearly somehow I have put in something to prevent it performing that step. Can anybody help me out? I'd be amazingly grateful, I have no clue how I've screwed it up. if(isset($_POST['submit'])){ $ownerid = $_SESSION['id']; // If completed = Y give an error $completeyn = "SELECT completed FROM activities WHERE playerno='$ownerid' AND activityno = '1'"; $completecheck=mysql_query($completeyn) or die(mysql_error()); while($row = mysql_fetch_array( $completecheck )) { if($row['completed'] == 'Y'){ echo 'Oops, you\'ve already done this twice today!';} else { // Enter them into the activities database if they're not already there $stepno2 = "SELECT playerno, timesdone FROM activities WHERE playerno='$ownerid' AND activityno = '1'"; $stepnoanswer2=mysql_query($stepno2) or die(mysql_error()); $num_rows2 = mysql_num_rows($stepnoanswer2); echo $num_rows2; if($num_rows2 == '0'){ $putintodb2 = mysql_query("INSERT INTO activities (playerno, activityno, timesdone) VALUES ('$ownerid', '1', '1')") or die("Error: ".mysql_error()); echo 'Randomevent1'; }else{ // If they are already there update their stepcount $updatestepcount2=("UPDATE activities SET timesdone=timesdone+'1' WHERE playerno='$ownerid' AND activityno = '1'"); $newstepcount2=mysql_query($updatestepcount2); echo 'Randomevent2';} // If this new stepcount is equal to 2, set completed to Y $checkstep = "SELECT timesdone FROM activities WHERE playerno='$ownerid' AND activityno = '1'"; $checkstepresult=mysql_query($checkstep) or die(mysql_error()); while($row = mysql_fetch_array( $checkstepresult )) { if($row['timesdone'] == '2'){ echo $row['timesdone']; $updatestepcount22=("UPDATE activities SET completed = 'Y' WHERE playerno='$ownerid' AND activityno = '1'"); $newstepcount22=mysql_query($updatestepcount22); } }}}} This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=306039.0 Here's a neat little script that you simply use by calling yourscript.php?microsoft (where microsoft is any keyword you want) and it returns 100 related keywords. It's pretty raw in it's form. I didn't write it. Purely for learning, I'm trying to figure out how to 1) issue a line break between each item in the elements of the arry? 2) return only the keywords and not the associated array info. Currently, it returns results like: Array ( => microsoft [1] => microsoft security essentials [2] => microsoft office [3] => microsoft templates [4] => microsoft updates [5] => microsoft silverlight [6] => microsoft word [7] => microsoft money [8] => microsoft office 2010 [9] => microsoft clip art [10] => microsoft [11] => microsoft security essentials [12] => microsoft office [13] => microsoft templates [14] => microsoft updates [15] => microsoft silverlight [16] => microsoft word [17] => microsoft money [18] => microsoft office 2010 [19] => microsoft clip art [20] => microsoft security essentials [21] => microsoft security essentials review [22] => microsoft security essentials alert [23] => microsoft security essentials update [24] => microsoft security essentials 2.0 I'm wanting to know how to make it return results like... microsoft microsoft security essential microsoft office microsoft templates etc.... Code: [Select] <?php function text_between($start,$end,$string) { if ($start != '') {$temp = explode($start,$string,2);} else {$temp = array('',$string);} $temp = explode($end,$temp[1],2); return $temp[0]; } function gsscrape($keyword) { $keyword=str_replace(" ","+",$keyword); global $kw; $data=file_get_contents('http://clients1.google.com/complete/search?hl=en&q='.$keyword); $data=explode('[',$data,3); $data=explode('],[',$data[2]); foreach($data as $temp) { $kw[]= text_between('"','"',$temp); } } #simple to use, just use yourscriptname.php?keywords if ($_SERVER['QUERY_STRING']!='') { gsscrape($_SERVER['QUERY_STRING']); foreach ($kw as $keyword) { gsscrape($keyword); } #all results are in array $kw... print_r($kw); } ?> When clicking on the link "groups", there is no problem printing out the first level subgroups. But when clicking on any of the subgroup, the second level subgroups are not being displayed. I have or die(mysql_error()); after some queries but I can not see what is the error. It always gives the same message: Quote No Products Found. Sorry, but there are no products in this section at the moment. The products are constantly being updated, however. Please try again later or contact us. How would I find out which part of the code fails? The code: <?php include 'scrptz/functions.php'; // Page vars $thisPage=$getVars["page"]; if($thisPage<1)$thisPage=1; $firstGroup=($thisPage*16)-16; // Get group details and stick them into an array $qMain="SELECT * FROM PGroups WHERE PG = '".$getVars["prodg"]."'"; $result=mysql_query($qMain) or die(mysql_error()); $groupDetails=mysql_fetch_array($result); // Get all sub groups in current product group $qMain="SELECT * FROM SubG WHERE ProdG = '".$getVars["prodg"]."'"; $result=mysql_query($qMain) or die(mysql_error()); // Stick sub groups in a 2D associative array $j=0; while ($row=mysql_fetch_array($result)) { foreach($row as $i=>$data)$array[$j][$i]=$data; $j++; } // Calculate vars for navigation $totalGroups=$j; $totalPages=ceil($totalGroups/16); // Set page title (for bookmark) $pageTitle=$groupDetails["GPname"]; // Set top title if($totalGroups>0){$topTitle="VIEW PRODUCTS";}else{$topTitle="ERROR";} ?> <html> <head> <title>Lock-Tech® Hi-Specification Architectural Hardware</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="scrptz/styles.css" rel="stylesheet" type="text/css"> <script language="JavaScript" type="text/javascript">var theID="<?php echo $getVars['uid']; ?>";</script> <script language="JavaScript" src="scrptz/content.js" type="text/javascript"></script> <script language="JavaScript" src="scrptz/menu.js" type="text/javascript"></script> <script language="JavaScript" src="scrptz/scripts.js" type="text/javascript"></script> </head> <body background="imgz/bg.gif" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0"<?php echo $notify ?>> <?php include("top.php"); ?> <table width="952" height="509" border="0" cellpadding="0" cellspacing="0" class="maintext"> <?php if($sessions['accCode']){?><form action="http://www.lock-tech.co.uk/index.php" method="post" name="logout" target="_parent"><input name="account" type="hidden" value="<?php echo $sessions['accCode']; ?>"><input name="killSession" type="hidden" value="<?php echo $getVars['uid']; ?>"></form><?php }?> <tr> <td width="1" rowspan="5" bgcolor="#000000"></td> <td height="21" background="imgz/topbar.gif" bgcolor="#14359E"> </td> <td height="21" colspan="5" valign="middle" background="imgz/topbar.gif" bgcolor="#14359E" class="mainyellow"><?php include("scrptz/dd_menu.php"); ?></td> <td height="21" background="imgz/topbar.gif" bgcolor="#14359E"> </td> <td width="1" rowspan="5" bgcolor="#000000"></td> </tr> <tr> <td width="5" rowspan="3"> </td> <td width="306" height="30" valign="bottom" class="title2"><?php echo $groupDetails["GPname"] ?></td> <td width="11" rowspan="3"><img src="imgz/maindiv.gif" width="11" height="466"></td> <td width="306" height="30" align="center" valign="bottom" class="title2"><?php if($totalGroups>0){?><a href="g_view.php?pgroup=<?php echo $groupDetails["PG"] ?>&uid=<?php echo $getVars['uid']; ?>" class="link4" onmouseover="window.status='View List of all Products in <?php echo $groupDetails["GPname"] ?>'; return true">VIEW ALL</a> | <a href="g_browse.php?pgroup=<?php echo $groupDetails["PG"] ?>&uid=<?php echo $getVars['uid']; ?>" class="link4" onmouseover="window.status='Browse all Products in <?php echo $groupDetails["GPname"] ?>'; return true">BROWSE ALL</a><?php }?></td> <td width="11" rowspan="3"><img src="imgz/maindiv.gif" width="11" height="466"></td> <td width="306" height="30" align="center" valign="bottom"> </td> <td width="5" rowspan="3"> </td> </tr> <tr> <td height="20" valign="top" class="mainbold"></td> <td width="306" rowspan="2" valign="top" class="maintext"> <?php for($i=$firstGroup; $i<($firstGroup+8) && $i<$totalGroups; $i++){?> <a href="sub.php?PSubG=<?php echo $array[$i]["SPG"] ?>&uid=<?php echo $getVars['uid']; ?>" class="link1" onmouseover="window.status='View Products in <?php echo $array[$i]["SPGname"] ?>'; return true"><?php echo $array[$i]["SPGname"] ?></a><br> <?php // Get all subsubs in current sub group $qMain="SELECT * FROM SubSubG WHERE SPG = '".$array[$i]["SPG"]."'"; $result=mysql_query($qMain) or die(mysql_error()); // Print subsubs while ($row=mysql_fetch_array($result)) { ?> [<a href="subsub.php?PSubSubG=<?php echo $row["SSPG"]?>&uid=<?php echo $getVars['uid']; ?>" class="link3" onmouseover="window.status='View Products in <?php echo $row["SSPGName"]?>'; return true"><?php echo $row["SSPGName"]?></a>] <?php } ?> <br><br> <?php }?></td> <td width="306" rowspan="2" valign="top" class="maintext"> <?php for($i=$firstGroup+8; $i<($firstGroup+16) && $i<$totalGroups; $i++){ ?> <a href="sub.php?PSubG=<?php echo $array[$i]["SPG"] ?>&uid=<?php echo $getVars['uid']; ?>" class="link1" onmouseover="window.status='View Products in <?php echo $array[$i]["SPGname"] ?>'; return true"><?php echo $array[$i]["SPGname"] ?></a><br> <?php // Get all subsubs in current sub group $qMain="SELECT * FROM SubSubG WHERE SPG = '".$array[$i]["SPG"]."'"; $result=mysql_query($qMain) or die("<font color=\"#FF0000\">ERROR {9.4}! Please navigate to a <a href=\"main.php?uid=".$getVars['uid']."\">different page</a> and then try this page again.</font>"); // Print subsubs while ($row=mysql_fetch_array($result)) { ?> [<a href="subsub.php?PSubSubG=<?php echo $row["SSPG"]?>&uid=<?php echo $getVars['uid']; ?>" class="link3" onmouseover="window.status='View Products in <?php echo $row["SSPGName"]?>'; return true"><?php echo $row["SSPGName"]?></a>] <?php } ?> <br><br> <?php }?></td> </tr> <tr> <td height="416" valign="top" class="mainbold"> <?php if($totalGroups>0) { ?> <img src="grp_pics/<?php echo $groupDetails["PG"] ?>.jpg" alt="Group Picture" galleryimg="no"><br><img src="imgz/pixel.gif" width="306" height="5"><br> <?php echo $groupDetails["GPText"] ?><?php } else { ?> or die(mysql_error()); <p class="noresult">No Products Found.</p><p class="mainbold">Sorry, but there are no products in this section at the moment. The products are constantly being updated, however. Please try again later or <a href="mailto:sales@lock-tech.co.uk" class="link1" onmouseover="window.status='Send us an Email.'; return true">contact us</a>.</p><?php }?></td> </tr> <tr> <td width="5" height="22" background="imgz/btmbar.gif" bgcolor="#14359E"> </td> <td width="306" height="22" align="center" valign="top" background="imgz/btmbar.gif" bgcolor="#14359E"><a href="javascript:history.back()" onmouseover="prev_btn.src='imgz/prev2.gif';window.status='Previous Page'; return true" onmouseout="prev_btn.src='imgz/prev.gif'"><img name="prev_btn" src="imgz/prev.gif" width="124" height="16" border="0"></a></td> <td width="11" height="22" bgcolor="#14359E"><img src="imgz/btmdiv.gif" width="11" height="22"></td> <td width="306" height="22" align="center" background="imgz/btmbar.gif" bgcolor="#14359E" class="nav"><? include 'scrptz/nav.php' ?></td> <td width="11" height="22" bgcolor="#14359E"><img src="imgz/btmdiv.gif" width="11" height="22"></td> <td width="306" height="22" align="center" valign="top" background="imgz/btmbar.gif" bgcolor="#14359E"><a href="javascript:directLink('<?php echo $prodLink; ?>','<? echo $pageTitle ?>')" onmouseover="link_btn.src='imgz/link2.gif'; window.status='Direct Link to This Page'; return true" onmouseout="link_btn.src='imgz/link.gif'"><img name="link_btn" src="imgz/link.gif" alt="" width="182" height="16" border="0"></a></td> <td width="5" height="22" background="imgz/btmbar.gif" bgcolor="#14359E"> </td> </tr> </table> </body> </html> Hi
I have a MySql database and wondered if there is a code to search a table field with a given string and display the number of unique occurrences.
The table is asterisk_cdr and would like to know how many calls received daily on a perticular channel.
Thanks
shmideo
Hello happy phpkkies, I search this forum for a sample php code on how to write a links scrapper that will recursively go through each page within a site and pull all the links. Then, I will save them to a database for analysis. I couldn't find something like that. Also, I was wondering if someone has or is selling a comments library in php. This is, a code or a set of functions that are related to commenting systems. For example; the library should have a function for blocking bad words or a function that will let people vote up or down comments made. Any ideas or links will be appreciated, thank you, V. I am developing a new promising service (media-industry) in the Los Angeles area. Contact me if interested.
Leroy. liroyleshed@gmail.com I have a form in which I want it to accept US phone formats, ie (123) 123-1234, 123-123-1234, 1-123-123-1234, etc.. Below is my code and I would really appreciate it if someone can tell me what I need to accept the #s. Thank you! $session = $_SESSION['verify']; $error = ''; if(trim($name) == '') { $error .= '<li>Your name is required.</li>'; } if(trim($email) == '') { $error .= '<li>Your e-mail address is required.</li>'; } elseif(!isEmail($email)) { $error .= '<li>You have entered an invalid e-mail address.</li>'; } if(trim($phone) == '') { $error .= '<li>Your phone number is required.</li>'; } elseif(!is_numeric($phone)) { $error .= '<li>Your phone number can only contain digits.</li>'; } if(trim($comments) == '') { $error .= '<li>You must enter a message to send.</li>'; } if($session != $verify) { $error .= '<li>The verification code you entered is incorrect.</li>'; } if($error != '') { echo '<div class="error_message">Attention! Please correct the errors below and try again.'; echo '<ul class="error_messages">' . $error . '</ul>'; echo '</div>'; } else { if(get_magic_quotes_gpc()) { $comments = stripslashes($comments); } Alright so I am writing up a function to verify various formats of US based phone numbers.. And I seemed to have run into a snag. This is what I have gotten so far, and for the most part works well. Code: [Select] function validate_phoneUS($number){ $numStripX = array('(', ')', '-', '.', '+'); $numCheck = str_replace($numStripX, '', $number); $firstNum = substr($number, 0, 1); if(($firstNum == 0) || ($firstNum == 1)) {return false;} elseif(!is_numeric($numCheck)){return false;} elseif(strlen($numCheck) > 10){return false;} elseif(strlen($numCheck) < 10){return false;} else{ $formats = array('###-###-####', '(###) ###-####', '(###)###-####', '##########', '###.###.####', '(###) ###.####', '(###)###.####'); $format = trim(ereg_replace("[0-9]", "#", $number)); return (in_array($format, $formats)) ? true : false; } } When I try to run these test numbers down the line.. Code: [Select] $number1 = '0234567890'; $number2 = '1234567890'; $number3 = "(555)555-5555"; $number4 = '555-555-5555'; $number5 = '555.555.5555'; $number6 = '5555555555'; $number7 = "(555) 555-5555"; I get these as a result.. 0234567890 is bad. 1234567890 is bad. (555)555-5555 is bad. 555-555-5555 is a valid phone number. 555.555.5555 is a valid phone number. 5555555555 is a valid phone number. (555) 555-5555 is bad. Where I am stuck is on the numbers that have the parenthesis wrapped around them. For a while I had it working with them and coming back as a valid number, and then I changed a couple things else where for something else. and now they come back as bad. I am getting tired, and I need some extra eyes to help me figure this out.. what did I snag myself on? Hi All, I only want to allow phone number in ###-###-####. Anything else I want an error. Here is what I have, which says any number is valid. Function: function checkPhone($number) { if(preg_match('^[0-9]{3}+-[0-9]{3}+-[0-9]{4}^', $number)) { return $number; } else { $items = Array('/\ /', '/\+/', '/\-/', '/\./', '/\,/', '/\(/', '/\)/', '/[a-zA-Z]/'); $clean = preg_replace($items, '', $number); return substr($clean, 0, 3).'-'.substr($clean, 3, 3).'-'.substr($clean, 6, 4); } } Checking Number: $number = '1231231234'; if(checkPhone($number)) { echo $number.' is a valid phone number.'; } else { echo $number.' is not a valid phone number.'; } This should give me the not valid message. Thanks Hi, I have a cakePHP program that works and displays data from a database table. The part I dont understand and I couldnt find anything on the cakephp blog as yet was the model was left blank? q1) The model is left blank but still works so what is the default behaviour here for the model? It doesnt seem to be needed to do anything i?. q2)I am selecting all the data from 1 table but how do I add a sql statement to select part of the table or a join of 2 tables? the find 'all' seems to just do that only in finding all data from a table. <?php class Post extends AppModel { /*var $name='User';*/ } ?> <?php class PostsController extends AppController { public $helpers=array('Html','Form'); public function index() { $this->set('posts',$this->Post->find('all')); } public function home() { $this->set('posts',$this->Post->find('all')); } } ?> view /// .. <?php foreach ($posts as $item): echo '<tr><td>'. $item['Post']['id']. '</td>'; echo '<td>'. $item['Post']['title'].'</td>'; echo '<td>'. $item['Post']['body'].'</td>'; echo '<td>'. $item['Post']['created'] .'</td>'; echo '</tr>'; endforeach; unset($item); ?> Can a person instantiate a model? If so how do you do it. I already know how to instantiate a class thank you Hey all,
I am making a application that requires a user to login in. I have a user model, which does such things as finds, registers, logins in, updates etc a user. It also grabs all of a users data from a database, such as their username, email address etc and checks whether or not a user is logged in.
The problem I face is this. I want to control what content a user can see depending on if they are logged in or not. In addition to this, I want to output the users data, such as their username, in other parts of the website – such as the header and footer. There is no real easy way of doing this, and requires the user model to be instantiated on every page. My question is should this class be a model or just a core library class?
Hello I'm developing a Model-View-Controller framework for my personal learning curve. I've created an active record class and I've got stuck when using variables in a where clause. My problem is this: When, in a where statement, you want to find the Users with the first name Mike, you might write SELECT Firstname, Surname FROM Users WHERE Firstname = 'Mike' Where Mike is enclosed with quotation marks. When you're comparing entities quotation marks shouldn't be used. For example, SELECT Firstname, Surname, OrderTitle FROM Users, Orders WHERE Firstname = 'Mike' AND Users.Firstname = Orders.Firstname So when using variables in my where statements, like $Name = Mike $this->Where(Firstname',$Name); $this->Where('Users.Firstname','Orders.Firstname'); How do I differentiate, in my function Where() when to enclose the string with quotation marks, i.e when it is a (Table.Entity) rather than a constant. Thank you Hi All, I guess there must be someway to do this with regex, but I'm not too hot on regex. What I want to do is check a text area for the presence of a phone number, and if it is there remove it. Ideally I don't want to remove all number as there might be a need for them to use a number, for example... I am 25 years old would be fine, but entering their number wouldn't be. Is there anyway of tacking this with regex, or is it going to be tricky? Many thanks, Greens85 Today, Amazon announced the "Fire Phone", what are your thoughts?
http://www.businessi...re-phone-2014-6
How to text a phone number in database as well as record recieved textmessages into mysql database. Any help here? i've been googling for ages. I know this should be easy.... However, to validate a 7-digit phone number, I wrote this: Code: [Select] <?php if(!empty($_POST['mobile_number'])) { if(!is_numeric($_POST['mobile_number']) || strlen($_POST['mobile_number']) != 7) { $errors[] = 'Please enter a 7-digit number without spaces or dashes for your <strong>Mobile</strong>.'; } else { $_SESSION['mobile_number'] = $_POST['mobile_number']; } } else { $_SESSION['mobile_number'] = ''; } ... but now I realise that numeric/integer validation won't work because where I am - in Ireland - mobile numbers can start with an initial zero, too. So, the following mobile numbers are possible: 0123456 0224466 How can I ensure that: each digit in the mobile number is numeric an initial zero is possible there are exactly 7 digits I suppose I loop through each digit, ensuring that that digit is numeric and break out of the loop if a non-numeric digit is encountered..? Any suggestions? TIA |