Jump to content

crackerjax

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

crackerjax's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I paid to have an insurance site built, and it worked great on the coder's test server, but when I moved it over to my side there were lots of problems. I fixed the mysql problems (created accounts on my side, imported data, change db names in the include) but the last error I can't fix is this: Warning: gregoriantojd() expects parameter 1 to be long, string given in /home/nickj3/public_html/rescuequote/shortform.php on line 75 Table 'nickj3_shortInsForm.__halfwaypast' doesn't exist I get this error on this url: http://www.rescuequote.com/shortform.php No matter the input. I think the fact that it can't figure out the age of the applicant other things are failing. I thought it might be a php version issue so I upgraded the server to v5.2 from 4.4 but no change. Mind you, I actually received the finished site over a year ago and haven't heard back from the original coder with my problems, and don't entirely expect to. From looking at the code, can you tell why this might be giving his error and what needs to be changed? Much appreciated- Nick <?php include("include/db.php"); include("include/header.php"); if (!isset($_POST['Submit'])): ?> <h2>Instant Insurance Estimate</h2> <form action="shortform.php" method="POST"> <table border="0" cellpadding="2" cellspacing="1"> <tr><td colspan="2" class="rateclass">Please enter the following information</td></tr> <tr class="tcontent"><td>Birth Date:</td> <td><select name="birthMonth"> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <select name="birthDay"> <?php $i = 1; while ($i <= 31) { echo "<option value=$i>$i</option>"; $i++; } echo "</select>"; echo "<select name=birthYear>"; $j = 1937; //starting year while ($j <= 1988) //ending year { echo "<option value=$j>$j</option>"; $j++; } ?> </select></td></tr> <tr class="tcontent"> <td>Are you a smoker?</td> <td> Yes <input type="radio" value="smoker" name="smoker" checked> No <input type="radio" value="nonsmoker" name="smoker"> </td></tr> <tr class="tcontent"> <td>Gender:</td> <td> Male <input type="radio" value="male" name="gender" checked> Female <input type="radio" value="female" name="gender"> </td></tr> <tr><td colspan="2" class="rate"><input type="submit" name="Submit" value="Submit"></td></tr> </table> </form> <br/><br/><br/><br/><br/><br/> <?php include("include/footer.php"); else: //find difference between 2 dates function //take from http://www.developertutorials.com/tutorials/php/calculating-difference-between-dates-php-051018/page1.html $dob="$birthMonth/$birthDay/$birthYear"; function dateDiff($dformat, $endDate, $beginDate) { $date_parts1=explode($dformat, $beginDate); $date_parts2=explode($dformat, $endDate); $start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]); $end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]); return $end_date - $start_date; } //use the above function to turn the age from then (DOB) to NOW into a # of years old, rounded down $ageInYears=floor(dateDiff("/", date("m/d/Y", time()), $dob)/365.25); $halfYearOlder = False; //Half birthday determininininer function overHalf ($birthMonth, $birthDay, $currentMonth, $currentDay) { global $halfYearOlder; //this is boolean to signify which table to access if ($birthMonth > $currentMonth) { $daysTill = (30.416 * ($birthMonth - $currentMonth) + ($birthDay - $currentDay)); if ($daysTill < 182.5) { $halfYearOlder = True; } } else if ($birthMonth < $currentMonth) { $daysSince = (30.416 * ($currentMonth - $birthMonth) + ($currentDay - $birthDay)); if ($daysSince > 182.5) { $halfYearOlder = True; } } else if ($birthMonth == $currentMonth AND $birthDay > $currentDay) { $halfYearOlder = True; } } overHalf($birthMonth,$birthDay,date(n),date(j)); //State of $halfYearOlder true increments year $halfTable = 'justturned'; if ($halfYearOlder) { $tableAge = $ageInYears++; $halfTable = 'halfwaypast'; } //so now its time to bring up the DB // open connection to MySQL server dbConnect("nickj3_shortInsForm"); if ($halfTable == "justturned") { $query = "SELECT * FROM " . $gender . "_" . $smoker . "_justturned, " . $gender . "_" . $smoker . "_halfwaypast WHERE " . $gender . "_" . $smoker . "_justturned.age = " . $ageInYears . " AND " . $gender . "_" . $smoker . "_halfwaypast.age = " . $ageInYears; } else { $query = "SELECT * FROM " . $gender . "_" . $smoker . "_halfwaypast, " . $gender . "_" . $smoker . "_justturned WHERE " . $gender . "_" . $smoker . "_halfwaypast.age = " . $ageInYears . " AND " . $gender . "_" . $smoker . "_justturned.age = " . $ageInYears; } $result = mysql_query($query) or die(mysql_error()); // store the record of the "example" table into $row $row = mysql_fetch_array( $result ); if ($smoker == "nonsmoker") { if ($halfTable == "justturned") { $Super10L = number_format($row[1],2); $Super10H = number_format($row[2],2); $Pref10L = number_format($row[3],2); $Pref10H = number_format($row[4],2); $Plus10L = number_format($row[5],2); $Plus10H = number_format($row[6],2); $Stan10L = number_format($row[7],2); $Stan10H = number_format($row[8],2); $Super20L = number_format($row[9],2); $Super20H = number_format($row[10],2); $Pref20L = number_format($row[11],2); $Pref20H = number_format($row[12],2); $Plus20L = number_format($row[13],2); $Plus20H = number_format($row[14],2); $Stan20L = number_format($row[15],2); $Stan20H = number_format($row[16],2); $Super30L = number_format($row[17],2); $Super30H = number_format($row[18],2); $Pref30L = number_format($row[19],2); $Pref30H = number_format($row[20],2); $Plus30L = number_format($row[21],2); $Plus30H = number_format($row[22],2); $Stan30L = number_format($row[23],2); $Stan30H = number_format($row[24],2); } else { $Super10L = number_format(min($row[1],$row[26]),2); $Super10H = number_format(max($row[2],$row[27]),2); $Pref10L = number_format(min($row[3],$row[28]),2); $Pref10H = number_format(max($row[4],$row[29]),2); $Plus10L = number_format(min($row[5],$row[30]),2); $Plus10H = number_format(max($row[6],$row[31]),2); $Stan10L = number_format(min($row[7],$row[32]),2); $Stan10H = number_format(max($row[8],$row[33]),2); $Super20L = number_format(min($row[9],$row[34]),2); $Super20H = number_format(max($row[10],$row[35]),2); $Pref20L = number_format(min($row[11],$row[36]),2); $Pref20H = number_format(max($row[12],$row[37]),2); $Plus20L = number_format(min($row[13],$row[38]),2); $Plus20H = number_format(max($row[14],$row[39]),2); $Stan20L = number_format(min($row[15],$row[40]),2); $Stan20H = number_format(max($row[16],$row[41]),2); $Super30L = number_format(min($row[17],$row[42]),2); $Super30H = number_format(max($row[18],$row[43]),2); $Pref30L = number_format(min($row[19],$row[44]),2); $Pref30H = number_format(max($row[20],$row[45]),2); $Plus30L = number_format(min($row[21],$row[46]),2); $Plus30H = number_format(max($row[22],$row[47]),2); $Stan30L = number_format(min($row[23],$row[48]),2); $Stan30H = number_format(max($row[24],$row[49]),2); } } else { if ($halfTable == "justturned") { $PS10L = number_format($row[1],2); $PS10H = number_format($row[2],2); $S10L = number_format($row[3],2); $S10H = number_format($row[4],2); $PS20L = number_format($row[5],2); $PS20H = number_format($row[6],2); $S20L = number_format($row[7],2); $S20H = number_format($row[8],2); $PS30L = number_format($row[9],2); $PS30H = number_format($row[10],2); $S30L = number_format($row[11],2); $S30H = number_format($row[12],2); } else { $PS10L = number_format(min($row[1],$row[14]),2); $PS10H = number_format(max($row[2],$row[15]),2); $S10L = number_format(min($row[3],$row[16]),2); $S10H = number_format(max($row[4],$row[17]),2); $PS20L = number_format(min($row[5],$row[18]),2); $PS20H = number_format(max($row[6],$row[19]),2); $S20L = number_format(min($row[7],$row[20]),2); $S20H = number_format(max($row[8],$row[21]),2); $PS30L = number_format(min($row[9],$row[22]),2); $PS30H = number_format(max($row[10],$row[23]),2); $S30L = number_format(min($row[11],$row[24]),2); $S30H = number_format(max($row[12],$row[25]),2); } } ?> <h2>Your Quick Quotes</h2> <h4>Rates are per month cost for $500,000 worth of coverage.</h4> <p>The range of rates that you see are collected from over 60 of the top rated insurance companies. Our job is to find the company that will give you the <em>very best rate</em> at your age, health history, and lifestyle. <br> <a href="contact.php">Click here for a personalized quote.</a></p> <table width="250" border="0" cellpadding="2" cellspacing="1"> <?php if ($smoker == "nonsmoker") { echo "<tr><td class='rateclass' colspan='2'>Super Preferred Rate</td></tr>"; if ($Super10L > 0) { echo "<tr class='rate'><td>10 year term</td><td>$$Super10L - $$Super10H</td></tr>";} if ($Super20L > 0) { echo "<tr class='rate'><td>20 year term</td><td>$$Super20L - $$Super20H</td></tr>";} if ($Super30L > 0) { echo "<tr class='rate'><td>30 year term</td><td>$$Super30L - $$Super30H</td></tr>";} echo "<tr><td class='rateclass' colspan='2'>Preferred Rate</td></tr>"; if ($Pref10L > 0) { echo "<tr class='rate'><td>10 year term</td><td>$$Pref10L - $$Pref10H</td></tr>";} if ($Pref20L > 0) { echo "<tr class='rate'><td>20 year term</td><td>$$Pref20L - $$Pref20H</td></tr>";} if ($Pref30L > 0) { echo "<tr class='rate'><td>30 year term</td><td>$$Pref30L - $$Pref30H</td></tr>";} echo "<tr><td class='rateclass' colspan='2'>Standard Plus Rate</td></tr>"; if ($Plus10L > 0) { echo "<tr class='rate'><td>10 year term</td><td>$$Plus10L - $$Plus10H</td></tr>";} if ($Plus20L > 0) { echo "<tr class='rate'><td>20 year term</td><td>$$Plus20L - $$Plus20H</td></tr>";} if ($Plus30L > 0) { echo "<tr class='rate'><td>30 year term</td><td>$$Plus30L - $$Plus30H</td></tr>";} echo "<tr><td class='rateclass' colspan='2'>Standard Rate</td></tr>"; if ($Stan10L > 0) { echo "<tr class='rate'><td>10 year term</td><td>$$Stan10L - $$Stan10H</td></tr>";} if ($Stan20L > 0) { echo "<tr class='rate'><td>20 year term</td><td>$$Stan20L - $$Stan20H</td></tr>";} if ($Stan30L > 0) { echo "<tr class='rate'><td>30 year term</td><td>$$Stan30L - $$Stan30H</td></tr>";} } else { echo "<tr><td class='rateclass' colspan='2'>Preferred Smoker</td></tr>"; if ($PS10L > 0) { echo "<tr class='rate'><td>10 year term</td><td>$$PS10L - $$PS10H</td></tr>";} if ($PS20L > 0) { echo "<tr class='rate'><td>20 year term</td><td>$$PS20L - $$PS20H</td></tr>";} if ($PS30L > 0) { echo "<tr class='rate'><td>30 year term</td><td>$$PS30L - $$PS30H</td></tr>";} echo "<tr><td class='rateclass' colspan='2'>Standard Smoker</td></tr>"; if ($S10L > 0) { echo "<tr class='rate'><td>10 year term</td><td>$$S10L - $$S10H</td></tr>";} if ($S20L > 0) { echo "<tr class='rate'><td>20 year term</td><td>$$S20L - $$S20H</td></tr>";} if ($S30L > 0) { echo "<tr class='rate'><td>30 year term</td><td>$$S30L - $$S30H</td></tr>";} } ?> </table> <?php include("include/footer.php"); endif; ?>
  2. Fixed.  My original code was just sloppy.  Missing a $ here and there.  :P
  3. How about someone look at the original code and tell me if that makes sense.  Any help is appreciated.
  4. Interesting thing I just read: http://us3.php.net/strtotime The function expects to be given a string containing a US English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT), relative to the timestamp given in now, or the current time if none is supplied. That might explain the 1970 thing.  We need a better function.
  5. I'm getting erratic results.  Look at these urls: http://www.nickjohnsonphoto.com/short5.php?birthMonth=4&birthDay=15&birthYear=1925&smoker=no&gender=male&submit= Above is born 1925, definitely not 36 yrs old. http://www.nickjohnsonphoto.com/short5.php?birthMonth=12&birthDay=15&birthYear=1986&smoker=no&gender=male&submit= Above is 1986, and age 19 is appropriate. From the 36 years old problem I gather that the cut off is 1970 birthyear, which is the case.  If they're born before 1970, I get 36 yrs and a half for my response.  Here is the actual code I have. My only guess is that the numbers are getting so large after 1970 its falling apart.  Ideas? [code] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled</title> </head> <body> <?php   //starting froms scratch on short5 //using the script found on http://www.phpfreaks.com/forums/index.php/topic,112347.0.html // requires $bday in YYYY-MM-DD format // returns an array with 2 values: 1) age and 2) boolean T or F if they are half way to next bday function getAge($bday)   {     $time = time();     $bdts = strtotime($bday);     $year = 60 * 60 * 24 * 365;     $agets = abs($time - $bdts);     $age  = floor($agets / $year);     $bal  = $agets % $year;     $days = floor($bal / (60 * 60 * 24));     $half = $days > 182 ? true : false;     return array($age, $half);   } $bday = "$birthYear-$birthMonth-$birthDay"; $age  = getAge($bday); echo "$age[0] years old. You are " . ($age[1] ? '' : 'not ') . "halfway to your next birthday!"; ?> </body> </html> [/code]
  6. try www.nickjohnsonphoto.com/short6.php which goes to short5.php It always says I'm over half.  Something seems wrong.
  7. I've only been working with PHP for about a month so this might be something really simple.  I've got a form calling to a another file with a birthday.  I want to know how old the person is.  Then I want to know if they're half way to their next birthday.  So if they're 182 days past thier birthday, I know, or less than 182 from their next.  Thats the logic I'm trying to use. The pages are up at www.nickjohnsonphoto.com/short3.php and www.nickjohnsonphoto.com/short4.php I commented out the mysql part because I'm putting that on hold until this gets worked out, but it seems to work correctly now. Short 3 has the same value for the radios to keep debugging simple. ignore that. The issue I'm having now is the logic of the halfOver function if statements isn't working right.  Does anyone understand what I'm trying to do? here is the code: short 3 [code] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled</title> </head> <body> <h1>Instant insurance estimate</h1> <h3>Please enter the following information</h3> <form method="get"       action="short4.php">   <table>     <tr>       <td>Birth Date:     <select name=birthMonth>   <option value=1>January</option>   <option value=2>February</option>   <option value=3>March</option>   <option value=4>April</option>   <option value=5>May</option>   <option value=6>June</option>   <option value=7>July</option>   <option value=8>August</option>   <option value=9>September</option>   <option value=10>October</option>   <option value=11>November</option>   <option value=12>December</option> </select> <select name=birthDay> <?php       $i = 1;   while ($i <= 31)     {   echo "<option value=$i>$i</option>";   $i++; } echo "</select>"; echo "<select name=birthYear>";   $j = 1925; //starting year   while ($j <= 1988) //ending year     {   echo "<option value=$j>$j</option>";   $j++; } ?>       </td> </tr> <tr>   <td>     Smoker: Yes     <input type=radio name="smoker" value="no"> No <input type=radio name="smoker" value="no">   </td>   <td>     Male:     <input type=radio name="gender" value="male"> Female: <input type=radio name="gender" value="male">   </td> </tr>   </table>   <button type=submit name="submit">Submit</button> </form> </body> </html> [/code] and short4: [code] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled</title> </head> <body> <?php   //find difference between 2 dates function //take from http://www.developertutorials.com/tutorials/php/calculating-difference-between-dates-php-051018/page1.html $dob="$birthMonth/$birthDay/$birthYear"; function dateDiff($dformat, $endDate, $beginDate)   {     $date_parts1=explode($dformat, $beginDate);     $date_parts2=explode($dformat, $endDate);     $start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);     $end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);     return $end_date - $start_date;   } //use the above function to turn the age from then (DOB) to NOW into a # of years old, rounded down $ageInYears=floor(dateDiff("/", date("m/d/Y", time()), $dob)/365.25); $halYearOlder = 0; echo "<br>Age in Years before addition<br>"; echo $ageInYears; //Half birthday determininininer function overHalf ($birthMonth, $birthDay, $currentMonth, $currentDay) {   global $halfYearOlder;   if ($birthMonth > $currentMonth)     {       $daysTill = (30.416 * ($birthMonth - $currentMonth) + ($birthDay - $currentDay));       if ($daysTill < 182)         {           echo "<br>$daysStill<br>";           $ageInYears++;           $halfYearOlder = 1;         }     }     else if ($birthMonth < $currentMonth)       {         $daysSince = (30.416 * ($currentMonth - $birthMonth) + ($currentDay - $birthDay));         if (daysSince > 182)           {             echo "<br>$daysStill<br>";             $ageInYears++;             $halfYearOlder = 6; //6 is just so i know its not the 1 from before.  Another debug value.           }       }       else if ($birthMonth == $currentMonth)         {           $halfYearOlder = 0;         } } //so now its time to bring up the DB // open connection to MySQL server mysql_connect("localhost", "nickj3_guest", "pass") or die(mysql_error()); mysql_select_db("nickj3_shortInsForm") or die(mysql_error()); overHalf($birthMonth,$birthDay,date(n),date(j)); echo "<br>Now the age is: "; echo $ageInYears; echo "<br>the state of halfover is: "; echo $halfYearOlder; echo "<br>"; // Determine our Query echo $gender; echo "<br>"; echo $smoker; echo "<br>"; echo (dateDiff("/", date("m/d/Y", time()), $dob)/365.25); echo "<br>"; /* if ($gender == "male")   {     if ($smoker == "no")   {     $query="SELECT 20yrSuPreMax FROM maleNonSmoker WHERE age = 6";       }   } // Retrieve all the data from the "example" table $result = mysql_query($query) or die(mysql_error());  // store the record of the "example" table into $row $row = mysql_fetch_array( $result ); echo "Name: ".$row[0]; echo "<br>This person is $ageExploded[0] years old and $ageExploded[1]"; mysql_free_result($result); mysql_close ("localhost", "nickj3_guest", "pass"); */ ?> </body> </html> [/code]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.