crackerjax Posted November 17, 2008 Share Posted November 17, 2008 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; ?> Link to comment https://forums.phpfreaks.com/topic/133015-gregoriantojd-error-after-changing-servers/ Share on other sites More sharing options...
bobbinsbro Posted November 17, 2008 Share Posted November 17, 2008 looks to me like you're using a month name (string posted from the birthmonth field in the form) instead of a month number (which is what the function gregoriantojd() expects). try this - change line 69 from this: $dob="$birthMonth/$birthDay/$birthYear"; to this: $timestamp = strtotime("$birthMonth $birthDay $birthYear"); $dob=date("m/d/Y", $timestamp); Link to comment https://forums.phpfreaks.com/topic/133015-gregoriantojd-error-after-changing-servers/#findComment-691942 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.