
2levelsabove
Members-
Posts
180 -
Joined
-
Last visited
Never
Everything posted by 2levelsabove
-
the best I have been able to research so far is: Regex: US vehicle VIN numbers for vehicles with GVW < 10k lbs ********************************************* ^([A-Z]{3}|\d{3})[A-Z]{2}\d{2}([A-Z]{1}|\d{1})([\d{1}|X{1})([A-Z]+\d+|\d+[A-Z]+)\d{5}$ any better out there ? I know this is a touch one.
-
How to copy an image from a remote img url onto my server ?
2levelsabove replied to 2levelsabove's topic in PHP Coding Help
Umm I have no malicious intent. Just a simple question because I need to to migrate some content from existing site to another. -
Anyone know of a function ? I can write it but am running into a time crunch and i know that sounds lazy. Thanks again
-
Thanks alpha. I appreciate your help on this matter
-
Thanks a lot guys !!! you guys are awesome!! Im just so new with regex!
-
Daniel, ok i tried this. but still nothing is outputted. $phone_number = 'sjkadkjsahsahdsjkjdjhdshkjdk jsakhkjhk 469-767-7695 sadsadsadsadsad'; $pattern3="/^(?:\((\d{3})\) |(\d{3})-)(\d{3})-(\d{4})$/"; if (preg_match_all($pattern3, $phone_number, $matches)) { // we have a match, dump sub-patterns to $matches $phone_number = $matches[0]; // original number $area_code = $matches[1]; // 3-digit area code $exchange = $matches[2]; // 3-digit exchange $number = $matches[3]; // 4-digit number $extension = $matches[4]; // extension print_r($matches); }
-
Hello why is this not working ? all i want is to be able to match numbers in format of xxx-xxx-xxxx or (xxx) xxx-xxxx $phone_number = 'sjkadkjsahsahdsjkjdjhdshkjdk jsakhkjhk 469-767-7695 sadsadsadsadsad'; $pattern3='/^([0-1]([\s-./\\])?)?(\(?[2-9]\d{2}\)?|[2-9]\d{3})([\s-./\\])?(\d{3}([\s-./\\])?\d{4}|[a-zA-Z0-9]{7})$/'; if (preg_match($pattern3, $phone_number, $matches)) { // we have a match, dump sub-patterns to $matches $phone_number = $matches[0]; // original number $area_code = $matches[1]; // 3-digit area code $exchange = $matches[2]; // 3-digit exchange $number = $matches[3]; // 4-digit number $extension = $matches[4]; // extension print_r($matches); }
-
can this email addres finder function be improved ?
2levelsabove replied to 2levelsabove's topic in Regex Help
Thanks a lot guys! you guys are awesome! -
any feedback is appreciated. function extract_emails_from($string){ preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches); return $matches; }
-
[SOLVED] how to get all TEXT between the $ and newline character ?
2levelsabove replied to 2levelsabove's topic in Regex Help
Thank you ! -
[SOLVED] how to get all TEXT between the $ and newline character ?
2levelsabove replied to 2levelsabove's topic in Regex Help
you are my hero. really dumb question but i have to ask: $/m ? -
The function below has 2 alert boxes. When I run it, sometimes the outer alert box comes empty. Please explain in a human manner why . function ItemCount()//returns the number of items in carousel { if (window.XMLHttpRequest) { var req = new XMLHttpRequest(); } else if (window.ActiveXObject) { var req = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("upgrade browser"); } req.open("POST", "/includes/_process/getPortfolioCount.php", true); req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); req.send(null); req.onreadystatechange = function() { if ((req.readyState == 4) && (req.status == 200)) { if (req.responseText.length) { document.getElementById('portfolioCount').value=req.responseText; alert(req.responseText); } } } alert("out:"+document.getElementById('portfolioCount').value); return document.getElementById('portfolioCount').value; }//function
-
Ok it is PHP causing the problem. The following line seems to mess up the MySQL connection. $docPageCount=getPDFPageCount($uploadFile);//this function gets the number of pages from PDF function getPDFPageCount ($filePath = '') { $retval = 1; $bin = '/usr/bin/pdf2ps -sOutputFile=- '.$filePath.' | grep -c "%%Page: "'; //error_log($bin,1,"[email protected]"); $cmd = "{$bin}"; $retval = shell_exec($cmd); return $retval; } // getPDFPageCount
-
I have a PHP page that uploads files and then inserts into a table the name of the file that was uploaded. I recently changed servers and find myself in a situation where certain files would cause MySQL server to go away. I out put the insert query and when I paste that on MYSQL console, it seems to insert that fine. The uploaded files that cause the "MySQL server has gone away error" vary in size anywhere from 512 K to 4 MB so size of the files doenst seem to be causing any problems. Even if i do a mysql_ping(0 right before the query and try to reconnect the database upon failure, the insert query just does not go through. But as I mentioned before, i am able to manually paste the same query in MySQL console windows and it inserts fine. by the way this is my query INSERT INTO prFile ( ProjectID , FileName , FileLoc , SortOrder , DateUploaded , FilePath , ThumbnailPath , NumPages ) VALUES ( 212 , 'p1012434.jpg' , 'p1012434.jpg' , 1 , NOW() , '/home/test/public_html/user/15/4e0738b2cae1beac2f82371f56a8864c/files/p1012434.jpg' , '/home/test/public_html/user/15/4e0738b2cae1beac2f82371f56a8864c/files/tn/p1012434.jpg' , 1 ) I am totally lost in this and would appreciate some insight.
-
The req.open doesnt even get called sometimes in IE and thus nothing gets returned. Works perfectly in FF function GetCarModels(makeID) { var d = document; var f = d.forms['rideinfo']; if (window.XMLHttpRequest) { var req = new XMLHttpRequest(); } else if (window.ActiveXObject) { var req = new ActiveXObject("Microsoft.XMLHTTP"); } req.open("GET", "include/_process/getmodels.php?json=1&makeID="+makeID, true); req.setRequestHeader('Content-Type', 'application/json'); req.send(null); req.onreadystatechange = function() { if ((req.readyState == 4) && (req.status == 200)) { var jsonContacts = eval('(' + req.responseText + ')'); f.model.options.length = 0; f.model.options[0] = new Option("All",0); for (var x = 0; x < jsonContacts.length; x++) { d.getElementById("model").options[x+1] = new Option(jsonContacts[x].model,jsonContacts[x].atrModelsID); //HELLO!!!! }//for loop } } }//function
-
Any recommendation on any good PHP ad management modules ?
2levelsabove replied to 2levelsabove's topic in PHP Coding Help
anyone ? -
What is $dif ??????????? And why is "$query = "select * from zips where zips.lat < $lat1 AND zips.lat > $lat2 AND zips.lon < $lon1 AND zips.lon > $lon2";" used ? Please explain. Thank you!! @$zipsearch = $_GET['zipsearch']; @$radius = $_GET['radius']; $dif = '2'; $results=''; $data=array(); //if(!empty($zipsearch)){} $query = "select * from zips where zip = '$zipsearch' LIMIT 1"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); if(empty($row)){$results = "<tr><td align='center' class='results' style='font-size:16px;font-weight:bold;color:red;font-family:arial;'>Invalid zip code</td></tr>";} $lat = $row['lat'];$lon = $row['lon']; $lat1 = ($lat + $dif); $lat2 = ($lat - $dif); $lon1 = ($lon + $dif); $lon2 = ($lon - $dif); $query = "select * from zips where zips.lat < $lat1 AND zips.lat > $lat2 AND zips.lon < $lon1 AND zips.lon > $lon2"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)){ $dist = great_circle_distance($lat,$row['lat'],$lon,$row['lon']); if ($dist < $radius){ array_unshift($row,$dist); $row[0]=round($row[0],2); $data[] = $row; } } sort($data); // $data now has the zip codes and distances in increasing order of distance from $_GET['zipsearch']; function great_circle_distance($lat1,$lat2,$lon1,$lon2){ /* Convert all the degrees to radians */ $lat1 = deg_to_rad($lat1); $lon1 = deg_to_rad($lon1); $lat2 = deg_to_rad($lat2); $lon2 = deg_to_rad($lon2); /* Find the deltas */ $delta_lat = $lat2 - $lat1; $delta_lon = $lon2 - $lon1; /* Find the Great Circle distance */ $temp = pow(sin($delta_lat/2.0),2) + cos($lat1) * cos($lat2) * pow(sin($delta_lon/2.0),2); $EARTH_RADIUS = 3956; $distance = $EARTH_RADIUS * 2 * atan2(sqrt($temp),sqrt(1-$temp)); return $distance; } function deg_to_rad($deg){ $radians = 0.0; $radians = $deg * M_PI/180.0; return($radians); }
-
<form method="post" action="javascript:void(0);" name="ShareOptionsForm" onsubmit="if (VerifyForm('ShareOptionsForm')) { AddShareJob(); HideShareOptions(); setTimeout('RefreshCart()', 1000); } else { return false; }"> <p><label for="ContactID">Recipient</label><br /> <select name="ContactID" id="ContactID" onChange="FadeOutError('RecipientError')"> <option value="">Select a Recipient...</option> <?php if (isset($recipients) && !empty($recipients)) { foreach ($recipients as $recipient) { $recipientText = ''; if (!empty($recipient['Company'])) { $recipientText = $recipient['Company'] . ' - '; } $recipientText .= "{$recipient['FirstName']} {$recipient['LastName']}"; /* ({$recipient['Email']}) */ print "<option value=\"{$recipient['ContactID']}\">{$recipientText}</option>\n"; } } ?> </select> or <input type="button" name="AddNewRecipient" id="AddNewRecipient" value="Add New Recipient" onclick="ShowShareNewRecipient();" /></p> <div id="RecipientError" class="error" style="display:<?php if (isset($RecipientError)) echo 'block'; else echo 'none'; ?>"><?php if (isset($RecipientError)) echo $RecipientError; ?> </div> <h2>Permissions</h2> <p>Permissions tell us how you want this recipient to be allowed to share these documents. Move the slider below to control the level of permissions.</p> <div id="PermissionExplanation" style="font-style:italic;font-weight:bold;text-align:center;width:500px;height:35px;"><p>This recipient will not be allowed to share these documents.</p></div> <input type="hidden" name="PermissionID" value="1" /> <input type="radio" name="permission" id="permission1" value="152" onclick="ChangePermissionGraphic(152)" /> <input type="radio" name="permission" id="permission2" value="313" onclick="ChangePermissionGraphic(313)"/> <input type="radio" name="permission" id="permission3" value="466" onclick="ChangePermissionGraphic(466)"/> <p><img src="images/permission1.jpg" width="500" height="174" alt="Permissions" border="0" id="PermissionGraphic" /></p> <p> <input type="submit" name="Submit" value="Share These Documents" /> <input type="button" name="Cancel" value="Cancel" id="Cancel" onclick="HideShareOptions();" /></p> <script language="JavaScript" type="text/javascript"> <!-- // Script placed here because apparently problems crop up in IE otherwise. var Image1 = new Image(); Image1.src = "images/permission1.jpg"; var Image2 = new Image(); Image2.src = "images/permission2.jpg"; var Image3 = new Image(); Image3.src = "images/permission3.jpg"; function ChangePermissionGraphic(v) { //alert("test from slider"); d = document; f = d.ShareOptionsForm; switch (v) { case 152: d.getElementById('PermissionGraphic').src = 'images/permission1.jpg'; d.getElementById('PermissionExplanation').innerHTML = '<p>This recipient will not be allowed to share these documents.</p>'; f.PermissionID.value = 1; break; case 313: d.getElementById('PermissionGraphic').src = 'images/permission2.jpg'; d.getElementById('PermissionExplanation').innerHTML = '<p>This recipient will be allowed to share these documents with other people, but they will not be allowed to share the documents.</p>'; f.PermissionID.value = 2; break; case 466: d.getElementById('PermissionGraphic').src = 'images/permission3.jpg'; d.getElementById('PermissionExplanation').innerHTML = '<p>These documents can be shared with anybody.</p>'; f.PermissionID.value = 3; break; } } //--> </script> </form>
-
look at variable "test". i have tried to set it up everywhere. I get a successful response but it just does not like to set a variable. function isSpecBook(fileid) { var test = "test"; if (window.XMLHttpRequest) { var req = new XMLHttpRequest(); } else if (window.ActiveXObject) { var req = new ActiveXObject("Microsoft.XMLHTTP"); } req.open("GET", "include/_process/isSpecBook.php?FileID="+fileid+"&json=1", true); req.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); req.send(null); req.onreadystatechange = function() { test = "success"; if ((req.readyState == 4) && (req.status == 200)) { if (req.responseText.length) { test = "success"; //var jsonSpec = eval('(' + req.responseText + ')'); if (req.responseText == "success"){ test = "success"; } } } test = "success"; }//////req.onreadystatechange = function() { return test; }//function
-
function isSpecBook(fileid) { var count = 0; if (window.XMLHttpRequest) { var req = new XMLHttpRequest(); } else if (window.ActiveXObject) { var req = new ActiveXObject("Microsoft.XMLHTTP"); } req.open("GET", "isSpecBook.php?FileID="+fileid+"&json=1", true); req.setRequestHeader('Content-Type', 'application/json'); req.send(null); req.onreadystatechange = function() { if ((req.readyState == 4) && (req.status == 200)) { var jsonSpec = eval('(' + req.responseText + ')'); for (var x = 0; x < jsonSpec.length; x++) { count=1; alert(count1); // count within function } } }//req.onreadystatechange = function() { alert(count);//count outside function }//function For some reason I am having scope issues. The count inside the function seems to work fine but the one outside right before the end of function never gets set. please help. thanks