rmelino
Members-
Posts
67 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
rmelino's Achievements
Member (2/5)
0
Reputation
-
Sorry, the working one is in the original thread. Here it is again... $query = "SELECT a.student_name, city, state, request_date, lat, lng, ( 3959 * acos( cos( radians('".mysql_real_escape_string($center_lat)."') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('".mysql_real_escape_string($center_lng)."') ) + sin( radians('".mysql_real_escape_string($center_lat)."') ) * sin( radians( lat ) ) ) ) AS distance FROM lesson_requests a INNER JOIN (SELECT student_name, MAX(request_date) AS MaxRequestDate FROM lesson_requests WHERE ( 3959 * acos( cos( radians('".mysql_real_escape_string($center_lat)."') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('".mysql_real_escape_string($center_lng)."') ) + sin( radians('".mysql_real_escape_string($center_lat)."') ) * sin( radians( lat ) ) ) ) < ".mysql_real_escape_string($radius)." GROUP BY student_name) b ON a.student_name = b.student_name AND a.request_date = b.MaxRequestDate HAVING distance < ".mysql_real_escape_string($radius)." ORDER BY distance LIMIT 0 , 10";
-
I am building on a query that someone from this forum helped me with shown at the end of this thread: http://www.phpfreaks.com/forums/index.php/topic,266134.0.html What i am trying to do is join in another table to the query called 'vendor'. That table has a value called 'user_purchased' and as one of the filters at the end of the complete query I have to make sure that 'user_purchased' from the table named 'vendor' does not contain the words 'abc_company'. using MATCH like this ...AND NOT MATCH(user_purchased) AGAINST ('abc_company') Could someone help me with the join of this additional table? Thanks in advance!
-
Hello, I have been driving myself crazy to try to do what seems so simple. I have a form where i ask zip code. I am using colorbox to popup a lightbox with an iframe after you input your zipcode. I need to pass the zip code value from the form into the source URL of the iframe. My form code looks like this: <div class="form-zip-start"> <p>Enter your zip code to begin your search:</p> <form id="submit" action="#" name="submit" method="post"> <input name="zip" id="zip" type="text" value="" class="zip-start" /> <div class="form-submit"><a href="/form.htm" rel="zipformSubmit" class="zipformSubmit">Submit</a></div> </form> </div> My js code looks like this: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script src="/ppc/colorbox/colorbox/jquery.colorbox.js"></script> <script> $(document).ready(function(){ $("a[rel=zipformSubmit]").click(function() { $("form#submit").submit(function(e) { var zip = $('#zip').attr('value'); colorbox({href: "?zip=" + zip, iframe:true, innerWidth:800, innerHeight:600}); }); }); }); </script> the end result should be an iframe loaded like...src="/form.htm?zip=92108" the 92108 value should be from the form input called 'zip' I can't seem to get the zip code value to pass properly. Can anyhow show me what i'm doing wrong? Thanks!
-
Thank you all for the helpful replies. Any chance you could provide a code example of how i would convert my existing entries to yyyy/mm/dd h/m/s using STR_TO_DATE()? Thanks again for your help!
-
Hi All, I am trying to do a query between a date range and having problems. I know the main issue is that i stored my date values in my db improperly (i used varchar, doh!). Anyhow, i'm trying to see if there is a workaround instead of having to reformat my whole db for every time entry. Right now, my time entries look like this: 08/19/11 16:13:05 I am trying to write a simple query that allows me to pull results from within a date range where i can change month, day or year. So, something like this: $query = "SELECT * FROM blah WHERE `dog` LIKE '%lab%' AND request_date BETWEEN ' 08/10/11 16:13:05' AND 08/19/11 16:13:05' "; or, changing the days... $query = "SELECT * FROM blah WHERE `dog` LIKE '%lab%' AND request_date BETWEEN ' 08/15/11 16:13:05' AND 08/19/11 16:13:05' "; or, changing the months... $query = "SELECT * FROM blah WHERE `dog` LIKE '%lab%' AND request_date BETWEEN ' 07/15/11 16:13:05' AND 08/19/11 16:13:05' "; or, changing the years... $query = "SELECT * FROM blah WHERE `dog` LIKE '%lab%' AND request_date BETWEEN ' 08/15/10 16:13:05' AND 08/19/11 16:13:05' "; using the queries above don't seem to pull the accurate results. Could someone help? Thanks in advance
-
Hello, Hoping someone can help... I am pulling records from a db of cities and state abbrevs. My db has many duplicate city names but i want to echo out only the distinct ones. My query is based on a radius around a city and i think this might be what is tripping up the DISTINCT mysql query. Here is what i have: $teachradius = 50; $add_under = array(" " => "_"); $query = sprintf("SELECT DISTINCT city, state_abbrev, ( 3959 * acos( cos( radians('%s') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lat ) ) ) ) AS distance FROM cities HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20", mysql_real_escape_string($lat_i), mysql_real_escape_string($lng_i), mysql_real_escape_string($lat_i), mysql_real_escape_string($teachradius)); $result = mysql_query($query); while ($row = @mysql_fetch_assoc($result)){ echo '<li><a href="/' . strtolower($row['state_abbrev']) . '/' . strtolower(strtr($row['city'],$add_under)) . '.html">' . ucwords($row['city']) . ', ' . $row['state_abbrev'] . ' Dogs</a></li>',"\n"; } Can you see what I might be doing incorrectly in my query so that i can echo out distinct city names / state abbrevs only? Thanks in advance...
-
that did the trick, thanks!
-
Hi Russel, Thanks for the suggestion but i am getting a 500 error when i add [L]. I have moved the following above the rewrite conds and and added [L] like so: redirect 301 /old-page1.html http://www.mysite.com/new-page1.html [L] redirect 301 /old-page2.html http://www.mysite.com/new-page2.html [L] Any other ideas of what i might be doing wrong?
-
Hello, I am having a problem with the rewrites i have set up. I currently have the following in my htaccess file: <IfModule mod_rewrite.c> RewriteEngine On # send any non-files or non-folders to the root index.php file RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /profile.html?id=$1 [QSA,L] </IfModule> This piece is working fine and is essentially making it so whenever there is a page like this: http://www.mysite.com/profile.html?id=john, it is converted to a url like this: http://www.mysite.com/john I am also wanting to add several individual 301 redirects. I added them like this: redirect 301 /old-page1.html http://www.mysite.com/new-page1.html redirect 301 /old-page2.html http://www.mysite.com/new-page2.html The problem is, these individual 301 redirects are doing this: http://www.mysite.com/old-page1.html redirects to: http://www.mysite.com/new-page1.html?id=old-page1.html How can i make it so that that i don't get the "?id=old-page1.html' ? This is happening on all of my listed individual 301 redirects. Thanks in advance for any help!
-
Hello, I am having a problem with the rewrites i have set up. I currently have the following in my htaccess file: <IfModule mod_rewrite.c> RewriteEngine On # send any non-files or non-folders to the root index.php file RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /profile.html?id=$1 [QSA,L] </IfModule> This piece is working fine and is essentially making it so whenever there is a page like this: http://www.mysite.com/profile.html?id=john, it is converted to a url like this: http://www.mysite.com/john I am also wanting to add several individual 301 redirects. I added them like this: redirect 301 /old-page1.html http://www.mysite.com/new-page1.html redirect 301 /old-page2.html http://www.mysite.com/new-page2.html The problem is, these individual 301 redirects are doing this: http://www.mysite.com/old-page1.html redirects to: http://www.mysite.com/new-page1.html?id=old-page1.html How can i make it so that that i don't get the "?id=old-page1.html' ? This is happening on all of my listed individual 301 redirects. Thanks in advance for any help!
-
look for certain words from array list within a string
rmelino replied to rmelino's topic in PHP Coding Help
perfect, that works! Thank you very much for your help -
look for certain words from array list within a string
rmelino replied to rmelino's topic in PHP Coding Help
i got rid of the error but that isn't working either for the following reason: as i understand it the code is saying this on form submit: look at $full_string, if you find the first value in array $spam, then send the spam email notification, if not, send the all is ok email. Now, loop through again and look for the second word in array $spam. if the second word is in $full_string, send the spam alert email, otherwise, send an email that says all is ok, and so on and so on. The problem with this is, I want to check $full_string to see if any of the $spam array words exist. If they do, send a single spam alert email. If they don't, send a single 'all is ok' email. Does this make sense? -
look for certain words from array list within a string
rmelino replied to rmelino's topic in PHP Coding Help
Flolam, I tried your solution but keep getting Parse error: syntax error, unexpected T_ELSE ... i think because i have multiple if statements within yours? Here is a fuller version of the code: $full_string = $name.' | '.$email.' | '.$message; $spam = array("test", "viagra"); foreach ($spam as $spamword) { if (strrpos($full_string, $spamword)) { //if flagged for spam, insert into temp db $query = @mysql_query("INSERT INTO lsome_db () VALUES ()"); /***********START SPAM ALERT EMAIL*******************/ include $_SERVER['DOCUMENT_ROOT'] . "/email_templates/email_spam_alert.php"; //lead control $echo = '<h2>SPAM ALERT:<br /><br /></h2><p>'.$email_err.'<br/>'.$subject_err.'<br />'.$message_err.'</p>'; if ($lead_control == 1) { mail($email_err, $subject_err, $message_err, $headers_err); } elseif ($lead_control == 2) { echo $echo; } elseif ($lead_control == 3) { mail("email@email.com", $subject_err, $message_err, $headers_err); } if ($lead_control == 2) { echo '<h1>ECHO REPORT</h1>'; } else { header("Location: /contact.html?id=$username"); } /***********END SPAM ALERT EMAIL*******************/ } } else { //send off a different email any ideas? -
look for certain words from array list within a string
rmelino replied to rmelino's topic in PHP Coding Help
thanks for your responses. I tried using in_array(): however i don't know how to use that in conjunction with stristr $spam = array("test", "viagra"); if (in_array(stristr($full_string), $spam)) { echo "This is SPAM";} What am i doing wrong in the example above? -
Hello, I'm having trouble getting a piece of code to work and as a result right now i have bloated code on a simple task. Currently my code looks like this: //convert responses into one string to check for spam $full_string = $name.' | '.$email.' | '.$message; //look for spam words if ( (stristr($full_string, 'test')) || (stristr($full_string, 'http')) || (stristr($full_string, 'www')) || (stristr($full_string, 'site')) || (stristr($full_string, 'fake')) || (stristr($full_string, 'viagra')) || (stristr($full_string, 'cialis')) || (stristr($full_string, 'asdf')) || (stristr($full_string, 'txt')) || (stristr($full_string, 'doc')) || (stristr($full_string, 'xls')) || (stristr($full_string, 'htm')) || (stristr($full_string, 'sale')) || (stristr($full_string, 'free')) ){ I would like to instead place all my 'spam' words in an array like this $spam_array = array('test', 'viagra', cialis...etc If i had all my spam words in an array, how would i write an if statement to check if any of those words appeared in $full_string ? Thanks for your help!