473,395 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Change database from mysql 4 to mysql 5 affects my calendar event page

I changed my database from mysql 4.1.10 to mysql 5.0 and I encountered error in my calendar event page. The output of my calendar date was change instead of date it becomes “>” and also when I press the button to move to another month I can’t move to another month. I have no idea why it happened.
Here is the old calendar code:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     $dbCnx = @mysql_connect("localhost","", "") or die('Could not Connect to the database')
  3.     mysql_select_db("mydb");    
  4. ?>
  5. <html>
  6. <script>
  7. function goLastMonth(month, year){
  8. if(month == 1){
  9. --year;
  10. month = 13;
  11. }
  12. document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month-1)+'&year='+year;
  13. }
  14. function goNextMonth(month, year){
  15. if(month == 12){
  16. ++year;
  17. month = 0;
  18. }
  19. document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month+1)+'&year='+year;
  20. function remChars(txtControl, txtCount, intMaxLength)
  21. {
  22. if(txtControl.value.length > intMaxLength)
  23. txtControl.value = txtControl.value.substring(0, (intMaxLength-1));
  24. else
  25. txtCount.value = intMaxLength - txtControl.value.length;
  26. }
  27. function checkFilled() {
  28. var filled = 0
  29. var x = document.form1.calName.value;
  30. if (x.length > 0) {filled ++}
  31. var y = document.form1.calDesc.value;
  32. if (y.length > 0) {filled ++}
  33. if (filled == 2) {
  34. document.getElementById("Submit").disabled = false;
  35. }
  36. else {document.getElementById("Submit").disabled = true} // in case a field is filled then erased
  37. }
  38. </script>
  39. <body>
  40. <?php
  41. $day = (isset($_GET["day"])) ? $_GET['day'] : "";
  42. $month = (isset($_GET["month"])) ? $_GET['month'] : "";
  43. $year = (isset($_GET["year"])) ? $_GET['year'] : "";
  44. if(empty($day)){ $day = date("j"); }
  45. if(empty($month)){ $month = date("n"); }
  46. if(empty($year)){ $year = date("Y"); } 
  47. $currentTimeStamp = strtotime("$year-$month-$day");
  48. $monthName = date("F", $currentTimeStamp);
  49. $numDays = date("t", $currentTimeStamp);
  50. $counter = 0;
  51. function hiLightEvt($eMonth,$eDay,$eYear){
  52. $todaysDate = date("n/j/Y");
  53. $dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear;
  54. if($todaysDate == $dateToCompare){
  55. $aClass='class="today"';
  56. }else{
  57. $sql="select count(calDate) as eCount from calTbl where calDate = '" . $eMonth . '/' . $eDay . '/' . $eYear . "'";
  58. $result = mysql_query($sql);
  59. while($row= mysql_fetch_array($result)){
  60. if($row['eCount'] >=1){
  61. $aClass = 'class="event"';
  62. }elseif($row['eCount'] ==0){
  63. $aClass ='class="normal"';
  64. }
  65. }
  66. }
  67. return $aClass;
  68. }
  69. ?>
  70. <div id="Calendar_Event">
  71. <table width="350" cellpadding="0" cellspacing="0">
  72. <tr>
  73. <td width="50" colspan="1">
  74. <input type="button" value=" < " onClick="goLastMonth(<?php echo $month . ", " . $year; ?>);">
  75. </td>
  76. <td width="250" colspan="5">
  77. <span class="title" style="color:#FFFFFF"><?php echo $monthName . " " . $year; ?></span><br>
  78. </td>
  79. <td width="50" colspan="1" align="right">
  80. <input type="button" value=" > " onClick="goNextMonth(<?php echo $month . ", " . $year; ?>);">
  81. </td>
  82. </tr> 
  83. <tr>
  84. <th>M</td>
  85. <th>T</td>
  86. <th>W</td>
  87. <th>T</td>
  88. <th>F</td>
  89. <th>S</td>
  90. <th>S</td>
  91. </tr>
  92. <tr>
  93. <?php
  94. for($i = 1; $i < $numDays+1; $i++, $counter++){
  95. $dateToCompare = $month . '/' . $i . '/' . $year;
  96. $timeStamp = strtotime("$year-$month-$i");
  97. if($i == 1){
  98. $firstDay = date("N", $timeStamp);
  99. for($j = 1; $j < $firstDay; $j++, $counter++){
  100. echo "<td>&nbsp;</td>";
  101. }
  102. if($counter % 7 == 0 ){
  103. ?>
  104. </tr><tr>
  105. <?php
  106. }
  107. ?>
  108. <!--right here--><td width="50" <?=hiLightEvt($month,$i,$year);?>><a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$i;?></a></td> 
  109. <?php
  110. }
  111. ?>
  112. </table>
  113. </div>
  114. <div id="New_Event">
  115. <?php
  116. if(isset($_GET['v'])){
  117. if(isset($_POST['Submit'])){
  118. $sql="insert into calTbl(calName,calDesc,calDate,calStamp) values('" . $_POST['calName'] ."','" . $_POST['calDesc'] . "','" . $_POST['calDate'] . "',now())";
  119. mysql_query($sql);
  120. }
  121. $sql="select calName,calDesc, DATE_FORMAT(calStamp, '%a %b %e %Y') as calStamp from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'";
  122. $result = mysql_query($sql);
  123. $numRows = mysql_num_rows($result);
  124. if ($_SESSION['username']=="user1") 
  125. $check1=mysql_query("SELECT * FROM tbllogin WHERE Username='user1' AND Department='Staff' AND Permission='True'"); 
  126. $check2 = mysql_fetch_array($check1); 
  127. $username = $check2['Username']; 
  128. $dep = $check2['Department']; 
  129. $permiss = $check2['Permission']; 
  130. if($username=="user1" && $dep=="Staff" && $permiss=="True"){ 
  131. $_SESSION['isallowed'] = $check2['Permission']; 
  132. ?> 
  133. <a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">Add Even</a><a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">t</a>
  134. <?php  
  135. }
  136. else 
  137. { echo "You cannot Add New Event"; } 
  138. ?>
  139. </div>
  140. <div id="Cal_Event">
  141. <?php
  142. if(isset($_GET['f'])){
  143. include 'calform.php';
  144. }
  145. if($numRows == 0 ){
  146. echo '';
  147. }else{
  148. echo '<h3>Event Listed</h3>';
  149. while($row = mysql_fetch_array($result)){
  150. ?>
  151. <h5><?=$row['calName'];?></h5>
  152. <?=$row['calDesc'];?><br/>
  153. Listed On: <?=$row['calStamp'];?>
  154. <?php
  155. }
  156. }
  157. }
  158. ?>
  159. </div>
  160. </body>
  161. </html>
  162.  
On my new codes I only change the codes for the connection of database like the “host”, ”username”, ”password”, ”database name”, “table name”.
Honestly, I have no idea why it happened after I change my database. Actually my tbluser was work so I connected in my database on my other webpage.
Any help is highly appreciated. Thank you in advance.
Oct 20 '10 #1
1 1356
Dormilich
8,658 Expert Mod 8TB
what datatype is the `calDate` field in the new DB?
Oct 20 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: c-bass | last post by:
How many database does MySQL Support?
2
by: aa | last post by:
How do I import Access database into MySQL?
0
by: bettina | last post by:
I had an Access database and I had always used in my tables (whenever possible) pop up lists to choose elements.. for example, for a column I've wrote in "Datensatzherkunft" SELECT tbl.field1 FROM...
1
by: Paul D. Fox | last post by:
I've seen how you can send e-mail through ASP.NET, but how about sending an Outlook Calendar event after the "Submit" button is pressed? Does anyone have a small sample of this? Paul
0
by: sangmin.park | last post by:
Hello. I made a page using .net calendar. At first, I build this page with 3 frames. "top", "menu", "main" "menu" frame has page links and .net calendar. Now, the page was revised to use...
4
by: Bob Alston | last post by:
Anyone have experience with converting an access app from Jet database to Mysql? I am specifically looking for any changes I would have to make to my access forms, queries, modules, vba code, etc....
6
by: craigkenisston | last post by:
How to change database name on the fly? I have an asp.net application in which a user connects to a sql server, where there's a centralized database with the users table and general settings....
6
by: markodilore | last post by:
Hey Guys, you helped me once when I tryied to create a database : "Access denied for user ''@'localhost' ". On my Mac OS 10.4, I had no problem creating database and modifying it from the terminal....
1
ddtpmyra
by: ddtpmyra | last post by:
I keep on looking on open source code of calendar event out of PHP but most of them are for commercial use. Anybody, who has good resource of calendar scripts with a tutorial from a scratch you...
6
by: najmi | last post by:
hai.. i have used jquery fullcalendar for my application and i have one problem that is how to display the event from the database.i have found the sample given in php but i want it in jsp.can...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.