It works ok on local host but buggy on remote host!
| From: | H.T | Date: | Tue, 24 Apr 2007 20:40:52 +0000 |
| Subject: | It works ok on local host but buggy on remote host! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-253626@lists.php.net to get a copy of this message | ||
Hi coders,
I wrote this piece of code to use for Google searching using daterange
directive. it works ok on local host running IIS and PHP 5.1.2 but when i
test it on my host running php 4.4.4 on linux, $julian_days_from and
$julian_days_to variables don't get assigned any values and therefor they
remain empty!
What is wrong with this code?
Here is the code:
<?php
if ($_POST){
if (empty($_POST['from'])){
$error[]='Please enter From date.';
}
else{
$from=explode('-',$_POST['from']);
$julian_days_from = gregoriantojd($from[1],$from[0],$from[2]);
}
if (empty($_POST['to'])){
$error[]='Please enter To date.';
}
else {
$to=explode('-',$_POST['to']);
$julian_days_to = gregoriantojd($to[1],$to[0],$to[2]);
}
if ($julian_days_from>$julian_days_to){
$error[]='From date can not be greater than To date!';
}
if (empty($_POST['search'])){
$error[]='Please enter your search term.';
}
if (!isset($error)){
$search_ready=explode(' ',$_POST['search']);
foreach($search_ready as $search_ready_val){
$search_term=$search_term.'+'.$search_ready_val;
}
switch($_POST['search_in']){
case ('web'):
$query='http://www.google.com/search?hl='.$_POST['language'].'&q='.$search_term.'+'.'daterange:'.$julian_days_from.'-'.$julian_days_to.'&lr=lang_'.$_POST['language'];break;case
('images'): $query='http://images.google.com/images?hl='.$_POST['language'].'&q='.$search_term.'+'.'daterange:'.$julian_days_from.'-'.$julian_days_to.'&lr=lang_'.$_POST['language'];break;case
('video'): $query='http://video.google.com/videosearch?hl='.$_POST['language'].'&q='.$search_term.'+'.'daterange:'.$julian_days_from.'-'.$julian_days_to.'&lr=lang_'.$_POST['language'];break;case
('book'): $query='http://books.google.com/books?hl='.$_POST['language'].'&q='.$search_term.'+'.'daterange:'.$julian_days_from.'-'.$julian_days_to.'&lr=lang_'.$_POST['language'];break;default:}
//header("Location:".$query);}}?><html><head><meta
http-equiv="Content-Language" content="en-us"><title>Google Assistance
- Date Rage Search</title><meta http-equiv="Content-Type"
content="text/html; charset=utf-8"><meta name="keywords"
content="google,assistance,search,daterange,seo,linkchecker,meta tag generator,online metric
converter,mail search,weblogsearch, search in weblogs,google page rank,pagerank,google hack,google
sitemap,site map generator,online tools,seo tools,webmasters"><meta
name="description" content="This website helps you use Google betterand faster. It
even provids some SEO tools such as Meta Maker and LinkChecker..."><meta
name="author" content="Hamed Takmil" /><script
language="javascript" src="date_picker.js"></script><script
type="text/javascript">function squery(){
window.location.assign("index.php?action=save");}<?phpif ($_POST &&
count($error)==0){ echo
"window.open('".$query."');\n";}?></script></head><body
bgcolor="#ffffff" topmargin="0"><form action="index.php"
method="POST"name="simple"><div align="center"><table
border="0" cellpadding="0" cellspacing="0" width="1024">
<tr> <td><img src="shim.gif" width="26" height="1"
border="0" alt=""></td> <td><img src="shim.gif"
width="37" height="1" border="0" alt=""></td>
<td><img src="shim.gif" width="122" height="1"
border="0" alt=""></td> <td><img src="shim.gif"
width="4" height="1" border="0" alt=""></td>
<td><img src="shim.gif" width="76" height="1"
border="0" alt=""></td> <td><img src="shim.gif"
width="35" height="1" border="0" alt=""></td>
<td><img src="shim.gif" width="48" height="1"
border="0" alt=""></td> <td><img src="shim.gif"
width="82" height="1" border="0" alt=""></td>
<td><img src="shim.gif" width="82" height="1"
border="0" alt=""></td> <td><img src="shim.gif"
width="82" height="1" border="0" alt=""></td>
<td><img src="shim.gif" width="81" height="1"
border="0" alt=""></td> <td><img src="shim.gif"
width="44" height="1" border="0" alt=""></td>
<td><img src="shim.gif" width="17" height="1"
border="0" alt=""></td> <td><img src="shim.gif"
width="21" height="1" border="0" alt=""></td>
<td><img src="shim.gif" width="82" height="1"
border="0" alt=""></td> <td><img src="shim.gif"
width="156" height="1" border="0" alt=""></td>
<td><img src="shim.gif" width="14" height="1"
border="0" alt=""></td> <td><img src="shim.gif"
width="15" height="1" border="0" alt=""></td>
<td><img src="shim.gif" width="1" height="1"
border="0" alt=""></td> </tr> <tr> <td
valign="top" align="left" colspan="17"
height="12"></td> <td valign="top" align="left"
rowspan="8" width="15"> </td> <td width="1"
height="12"><img src="shim.gif" width="1"
height="12"border="0" alt=""></td> </tr> <tr>
<td valign="top" align="left" rowspan="2"
width="26"> </td> <td valign="top" align="left"
colspan="3" height="78"> <img name="index_C2_R2"
src="images/index_C2_R2.jpg" width="163"height="78"
border="0" alt="Helps you find things better"></td> <td
valign="top" align="left" colspan="13" height="78">
<table border="0" width="100%" id="table5"
height="100%"cellspacing="1"> <tr>
<td> </td> </tr> </table> </td> <td
width="1" height="78"><img src="shim.gif" width="1"
height="78"border="0" alt=""></td> </tr> <tr>
<td valign="top" align="left" colspan="16"
height="9"></td> <td width="1" height="9"><img
src="shim.gif" width="1" height="9"border="0"
alt=""></td> </tr> <tr> <td valign="top"
align="left" rowspan="5" width="26"> </td> <td
valign="top" align="left" colspan="2"
height="32"><imgname="index_C2_R4" src="images/index_C2_R4.jpg"
width="159" height="32"border="0" alt=""></td>
<td valign="top" align="left" colspan="2"
height="32"><a href="index.php"> <img
name="index_C4_R4" src="images/index_C4_R4.jpg"
width="80"height="32" border="0" alt="Date Rage
Search"></a></td> <td valign="top" align="left"
colspan="2" height="32"><a href="weblog.php"> <img
name="index_C6_R4" src="images/index_C6_R4.jpg"
width="83"height="32" border="0" alt="Search in
Weblogs"></a></td> <td valign="top" align="left"
width="82" height="32"><ahref="converter.php"> <img
name="index_C8_R4" src="images/index_C8_R4.jpg"
width="82"height="32" border="0" alt="Units
Converter"></a></td> <td valign="top" align="left"
width="82" height="32"><ahref="mailerch.php"> <img
name="index_C9_R4" src="images/index_C9_R4.jpg"
width="82"height="32" border="0" alt="Get the results of your
search in yourmailbox"></a></td> <td valign="top"
align="left" width="82"
height="32"><ahref="metamaker.php"> <img
name="index_C10_R4" src="images/index_C10_R4.jpg"
width="82"height="32" border="0" alt="Meta Tag
Maker"></a></td> <td valign="top" align="left"
width="81" height="32"><ahref="pagerank.php"> <img
name="index_C11_R4" src="images/index_C11_R4.jpg"
width="81"height="32" border="0" alt="Get google page
rank"></a></td> <td valign="top" align="left"
colspan="3" height="32"><ahref="sitemap.php"> <img
name="index_C12_R4" src="images/index_C12_R4.jpg"
width="82"height="32" border="0" alt="Google Site Map
Generator"></a></td> <td valign="top" align="left"
width="82" height="32"><a href="checker.php"> <img
name="index_C15_R4" src="images/index_C15_R4.jpg"
width="82"height="32" border="0" alt="Link
Checker"></a></td> <td valign="top" align="left"
colspan="2" height="32"><imgname="index_C16_R4"
src="images/index_C16_R4.jpg" width="170"
height="32"border="0" alt=""></td> <td
width="1" height="32"><img src="shim.gif" width="1"
height="32"border="0" alt=""></td> </tr> <tr>
<td valign="top" align="left" colspan="16"
height="4"><imgname="index_C2_R5" src="images/index_C2_R5.jpg"
width="983" height="4"border="0" alt=""></td>
<td width="1" height="4"><img src="shim.gif"
width="1" height="4"border="0" alt=""></td>
</tr> <tr> <td valign="top" align="left" rowspan="2"
width="37"> <img name="index_C2_R6"
src="images/index_C2_R6.jpg" width="37"height="29"
border="0" alt="More tools comming soon!"></td> <td
valign="top" align="left" colspan="15"
height="7"><imgname="index_C3_R6" src="images/index_C3_R6.jpg"
width="946" height="7"border="0" alt=""></td>
<td width="1" height="7"><img src="shim.gif"
width="1" height="7"border="0" alt=""></td>
</tr> <tr> <td valign="top" align="left" colspan="4"
height="22"><imgname="index_C3_R7" src="images/index_C3_R7.jpg"
width="237" height="22"border="0" alt=""></td>
<td align="center" colspan="6"
rowspan="2"background="images/index_C7_R7.jpg"> <table
border="0" width="100%" id="table1"> <tr>
<td width="80%"> <input type="text" name="search"
size="35" style="padding:0px;width: 100%; border-style: solid; border-width: 1px;
"></td> <td align="center"> <input
type="submit" value="Search" name="B1"style="font-family: Tahoma;
font-size: 8pt; width: 76; height: 22"></td> </tr> </table>
</td> <td valign="top" align="left" colspan="5"
rowspan="2"><imgname="index_C13_R7"
src="images/index_C13_R7.jpg" width="290"
height="45"border="0" alt=""></td> <td
width="1" height="22"><img src="shim.gif" width="1"
height="22"border="0" alt=""></td> </tr> <tr>
<td valign="top" align="left" colspan="5"
height="23"><imgname="index_C2_R8" src="images/index_C2_R8.jpg"
width="274" height="23"border="0" alt=""></td>
<td width="1" height="23"><img src="shim.gif"
width="1" height="23"border="0" alt=""></td>
</tr> <tr> <td valign="top" align="left" rowspan="5"
width="26"> </td> <td valign="top" align="left"
colspan="16" height="20"><imgname="index_C2_R9"
src="images/index_C2_R9.jpg" width="983"
height="20"border="0" alt=""></td> <td
valign="top" align="left" rowspan="5"
width="15"> </td> <td width="1"
height="20"><img src="shim.gif" width="1"
height="20"border="0" alt=""></td> </tr> <tr>
<td valign="top" align="left" colspan="12"
height="32"><imgname="index_C2_R10"
src="images/index_C2_R10.jpg" width="710"
height="32"border="0" alt=""></td> <td
valign="top" align="left" colspan="3"
height="32"><imgname="index_C14_R10"
src="images/index_C14_R10.jpg" width="259"
height="32"border="0" alt=""></td> <td
valign="top" align="left" width="14"
height="32"> </td> <td width="1"
height="32"><img src="shim.gif" width="1"
height="32"border="0" alt=""></td> </tr> <tr>
<td valign="top" align="left" colspan="12"
height="272"background="images/index_C2_R11.jpg"> <div
align="center"> <table border="0" width="90%"
id="table2"> <tr> <td
colspan="6"><b><font size="2"
face="Verdana">DateRange</font></b><hr></td>
</tr> <tr> <td width="9%"><font
size="2" face="Verdana"> From:</font></td>
<td width="17%"><font face="Arial"> <input
type="text" name="from" size="20" style="height:
20"readonly="readonly"></font></td> <td
width="9%"><font face="Verdana"> <a
href="#"> <img border="0"
src="images/DatePicker.gif" width="21"height="17"
onclick="javascript:show_calendar('document.simple.from',document.getElementsByName('from').value);"></a></font></td>
<td width="6%"><font size="2"
face="Verdana">To :</font></td> <td
width="23%"><font face="Arial"> <input
type="text" name="to" size="20" style="height:
20"readonly="readonly"></font></td> <td
width="31%"><font face="Verdana"> <a
href="#"> <img border="0"
src="images/DatePicker.gif" width="21"height="17"
onclick="javascript:show_calendar('document.simple.to',document.getElementsByName('to').value);"></a></font></td>
</tr> <tr> <td width="96%"
colspan="6"><b> <font face="Tahoma"
size="2" color="#FF0000"> <?php if
(isset($error)){ foreach($error as $error_val){ echo
$error_val.'<br>'; } } ?>
</font></b></td> </tr> <tr>
<td width="98%" colspan="6"><b><font
size="2"face="Verdana"> Search
in</font></b><hr></td> </tr> <tr>
<td width="98%" colspan="6"><font face="Verdana">
<span style="font-size: 9pt"> <input
type="radio" value="web"
checkedname="search_in"></span></font><font face="Verdana"
style="font-size:9pt">Web </font><font
face="Verdana"> <span style="font-size: 9pt">
<input type="radio"
name="search_in"value="images"></span></font><font
face="Verdana" style="font-size:9pt">Images
</font><span style="font-size: 9pt"><font
size="2"face="Verdana"> <input type="radio"
name="search_in"value="video"></font></span><font
face="Verdana" style="font-size:9pt">Videos
</font><font size="2" face="Verdana"> <span
style="font-size: 9pt"> <input type="radio"
name="search_in"value="book"></span><font face="Verdana"
style="font-size:9pt">Books</font></font></td> </tr>
<tr> <td width="98%"
colspan="6"><b><font size="2" face="Tahoma">
Language</font></b><hr></td> </tr>
<tr> <td width="98%" colspan="6"
align="center"> <p align="left"> <select
size="1" name="language"style="font-family: Tahoma; font-size: 8pt; height:
20"> <option selected value="en">English</option>
<option value="fa">Farsi</option> <option
value="it">Italian</option> <option
value="es">Spanish</option> <option
value="fr">French</option> <option
value="de">Deustch</option> <option
value="ar">Arabic</option> </select></td>
</tr> <tr> <td width="98%" colspan="6"
align="center"> <input type="reset" value="Reset"
name="B3" style="font-family:Tahoma; font-size: 8pt; width: 76; height:
22"></td> </tr> </table> </div> </td>
<td valign="top" align="left" colspan="3"
height="272"background="images/index_C14_R11.jpg"> <div
align="center"> <table border="0" width="96%"
id="table3"> <tr> <td> <p
align="center"><b> <font size="2"
face="Verdana" color="#000080">Search a particular date
range</font></b></td> </tr> <tr>
<td> <p align="left" style="margin: 10px
15px"><fontface="Verdana"> <span style="font-size:
8pt">An undocumented but powerful feature of Google's search is the
ability to search within a particular date range. Before delving into the actual use
of date range searching, there are a few things you shouldknow. First,
a date range search has nothing to do with thecreation date of the content and
everything to do with the indexingdate of the content. If I create a page on March 8,
1999, for instance, and Google doesn't get around to indexing it untilMay
22, 2002, for the purposes of a date range search, the datein question is May
22, 2002.</span></font></p> <p align="left"
style="margin: 10px 15px"> <font face="Verdana"
style="font-size: 8pt">Second, Googlecan index pages several times, and
each time it does so, thedate on it changes. So don't count on a date range
search staying consistent from day to day. The
"daterange:timestamp" can change when a page is indexed more than
once. Whether itdoes change depends on whether the content of the page
haschanged.</font></p> <p align="left" style="margin:
10px 15px"> <font face="Verdana" style="font-size:
8pt"> <a target="_parent"href="http://reviews.cnet.com/4520-10165_7-6206764-2.html">
More...</a></font></td> </tr>
</table> </div> </td> <td valign="top" align="left"
rowspan="2" width="14"> </td> <td width="1"
height="272"><img src="shim.gif" width="1"
height="272"border="0" alt=""></td> </tr> <tr>
<td valign="top" align="left" colspan="12"
height="22"><imgname="index_C2_R12"
src="images/index_C2_R12.jpg" width="710"
height="22"border="0" alt=""></td> <td
valign="top" align="left" colspan="3"
height="22"><imgname="index_C14_R12"
src="images/index_C14_R12.jpg" width="259"
height="22"border="0" alt=""></td> <td
width="1" height="22"><img src="shim.gif" width="1"
height="22"border="0" alt=""></td> </tr> <tr>
<td align="center" colspan="16" height="56"> <table
border="0" width="100%" id="table4" height="40">
<tr> <td width="35%"><font face="Tahoma"
style="font-size:8pt"> <a
href="help.php">Help</a> |
<ahref="contact.php">Contact Me</a> | <a
target="_blank" href="http://www.google.com">GoogleSearch</a>
| <a href="policy.php">Site Policy</a>
| <a href="other_links.php">Other
Links</a></font></td> <td style="border-left: 2px solid
#C0C0C0" width="354"><fontface="Tahoma"> <span
style="font-size: 8pt"> © AllRights
Reserved</span></font></td> <td align="center"><a
href="http://www.google.com"target="_blank">
<img border="0" src="images/google_powered.png"
width="80"height="15"></a> <a href="http://www.php.net" target="_blank">
<img border="0" src="images/php-powered.gif"
width="80"height="15"></a> <a href="http://www.linux.org" target="_blank">
<img border="0" src="images/linux_powered.gif"
width="80"height="15"></a></td> </tr>
</table> </td> <td width="1" height="56"><img
src="shim.gif" width="1" height="56"border="0"
alt=""></td>
</tr></table></div></form></body></html>