Tje Posted November 4, 2014 Share Posted November 4, 2014 i've use php-event-calender for showing event from table.when i click on event date, it's dispay table details for relevent date correctly in localhost.but it's didn't show details in live server. index.php <div id="Calendar"> </div> <div id="Events"> </div> <script language="javascript" src="calendar.js"></script> calender.php <?php error_reporting(0); include("config.php"); /// get current month and year and store them in $cMonth and $cYear variables (intval($_REQUEST["month"])>0) ? $cMonth = intval($_REQUEST["month"]) : $cMonth = date("m"); (intval($_REQUEST["year"])>0) ? $cYear = intval($_REQUEST["year"]) : $cYear = date("Y"); // generate an array with all dates with events $sql = "SELECT * FROM reservation WHERE arrival LIKE '".$cYear."-".$cMonth."-%'"; $result = db::getInstance()->query($sql); while ($row = $result->fetch()) { $events[$row["arrival"]]["f_name"] = $row["f_name"]; $events[$row["arrival"]]["l_name"] = $row["l_name"]; } // calculate next and prev month and year used for next / prev month navigation links and store them in respective variables $prev_year = $cYear; $next_year = $cYear; $prev_month = intval($cMonth)-1; $next_month = intval($cMonth)+1; // if current month is December or January month navigation links have to be updated to point to next / prev years if ($cMonth == 12 ) { $next_month = 1; $next_year = $cYear + 1; } elseif ($cMonth == 1 ) { $prev_month = 12; $prev_year = $cYear - 1; } if ($prev_month<10) $prev_month = '0'.$prev_month; if ($next_month<10) $next_month = '0'.$next_month; ?> <table width="100%" style="width:800px;height:600px;background-color:#FFFFFF;"> <tr> <td class="mNav"><a href="javascript:LoadMonth('<?php echo $prev_month; ?>', '<?php echo $prev_year; ?>')"><<</a></td> <td colspan="5" class="cMonth"><?php echo date("F, Y",strtotime($cYear."-".$cMonth."-01")); ?></td> <td class="mNav"><a href="javascript:LoadMonth('<?php echo $next_month; ?>', '<?php echo $next_year; ?>')">>></a></td> </tr> <tr> <td class="wDays">M</td> <td class="wDays">T</td> <td class="wDays">W</td> <td class="wDays">T</td> <td class="wDays">F</td> <td class="wDays">S</td> <td class="wDays">S</td> </tr> <?php $first_day_timestamp = mktime(0,0,0,$cMonth,1,$cYear); // time stamp for first day of the month used to calculate $maxday = date("t",$first_day_timestamp); // number of days in current month $thismonth = getdate($first_day_timestamp); // find out which day of the week the first date of the month is $startday = $thismonth['wday'] - 1; // 0 is for Sunday and as we want week to start on Mon we subtract 1 for ($i=0; $i<($maxday+$startday); $i++) { if (($i % 7) == 0 ) echo "<tr>"; if ($i < $startday) { echo "<td> </td>"; continue; }; $current_day = $i - $startday + 1; if ($current_day<10) $current_day = '0'.$current_day; // set css class name based on number of events for that day if ($events[$cYear."-".$cMonth."-".$current_day]<>'') { $css='withevent'; $click = "onclick=\"LoadEvents('".$cYear."-".$cMonth."-".$current_day."')\""; } else { $css='noevent'; $click = ''; } echo "<td class='".$css."'".$click.">". $current_day . "</td>"; if (($i % 7) == 6 ) echo "</tr>"; } ?> </table> events.php <?php error_reporting(0); include("config.php"); $sql = "SELECT * FROM reservation WHERE arrival = '".mysql_real_escape_string($_REQUEST["date"])."' AND status='pending'"; $result = db::getInstance()->query($sql); while ($row = $result->fetch()) { echo "<h2>"."Reservation ID :"." ".$row["res_id"]."</h2>"; echo "<b>"."Client Name :"."</b>"."<span>".$row["f_name"]." ".$row["l_name"]."</span>"."</br>"; echo "<b>"."Address :"."</b>"."<span>".$row["address"]."</span>"."</br>"; echo "<b>"."City :"."</b>"."<span>".$row["city"]."</span>"."</br>"; echo "<b>"."Zip :"."</b>"."<span>".$row["zip"]."</span>"."</br>"; echo "<b>"."Country :"."</b>"."<span>".$row["country"]."</span>"."</br>"; echo "<b>"."E-mail :"."</b>"."<span>".$row["email"]."</span>"."</br>"; echo "<b>"."Contact No :"."</b>"."<span>".$row["contact"]."</span>"."</br>"; echo "<b>"."In Date :"."</b>"."<span>".$row["arrival"]."</span>"."</br>"; echo "<b>"."Out Date :"."</b>"."<span>".$row["departure"]."</span>"."</br>"; echo "<b>"."Total Price :"."</b>"."<span>".$row["tot_price"]."</span>"."</br>"; echo "<b>"."Room Id :"."</b>"."<span>".$row["room_id"]."</span>"."</br>"; echo "<b>"."No Of Beds :"."</b>"."<span>".$row["no_beds"]."</span>"."</br>"; } ?> live server show calender and event date fine.but didn't show event details for that date.it's show correctly in localserver. Quote Link to comment https://forums.phpfreaks.com/topic/292255-php-event-calender-not-working-in-live-server/ Share on other sites More sharing options...
mac_gyver Posted November 4, 2014 Share Posted November 4, 2014 what sort of database library functions is your db::getInstance() class using (mysql_, mysqli_, PDO)? the reason i ask is that your code is also using mysql_real_escape_string() and without a mysql_connect() statement, it won't return any result. it would also be throwing a php error if you had php errors being reported and logged/displayed. the reason this works on your development system is that some of the WAMP all in one development packages set up default mysql connection details matching your root database user and would allow a mysql_real_escape_string() function to work, whereas a live server wouldn't be doing such nonsense. you should be escaping string data (or using prepared queries) using a method present in your db::getInstance() class, not using mysql_ functions. edit: i see that in your recent threads on this forum that you are using the PDO database library functions. you would use the PDO quote() method. however, be advised that this adds the single-quote characters around the data, which means that you must remove the single-quotes you have in your existing sql query statement. in cases where you are putting external data into an sql query statement, you should use prepared queries, which will avoid all the problems like this associated with trying to escape/quote string data. Quote Link to comment https://forums.phpfreaks.com/topic/292255-php-event-calender-not-working-in-live-server/#findComment-1495671 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.