kdawg2k12 Posted February 10, 2012 Share Posted February 10, 2012 okay this sounds strange I know but but apart from html code in pure php the database values display correctly but when I combine with HTML code i get an offset error when retrieving certain values example results from database file no HTML coding: February10 2012 5pm MY EVENT NEW YORK ERROR when combined with HTML: February MYEVENT 2012 NewYork Link to comment https://forums.phpfreaks.com/topic/256793-error-offset-1-database-error/ Share on other sites More sharing options...
QuickOldCar Posted February 10, 2012 Share Posted February 10, 2012 Post your code and expected output for additional help. Link to comment https://forums.phpfreaks.com/topic/256793-error-offset-1-database-error/#findComment-1316463 Share on other sites More sharing options...
unknown1 Posted February 10, 2012 Share Posted February 10, 2012 Yeah going to have to post some code for help my friend. =) Link to comment https://forums.phpfreaks.com/topic/256793-error-offset-1-database-error/#findComment-1316467 Share on other sites More sharing options...
kdawg2k12 Posted February 10, 2012 Author Share Posted February 10, 2012 Here's the Code guys Thanks <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <body> <?PHP $thisMonth = date('m'); $thisDay = date('j'); $eventMonth = array(); $eventDay = array(); $eventYear= array(); $eventTime = array(); $eventName = array(); $eventLocation = array(); $textMonth= array(); $dbMonth=""; $dbDay=""; $i=1; $row=1; $conn = odbc_connect('myEvents','',''); $sql= "SELECT month,day, year, time, event,location FROM Events ORDER By ID"; $rs="$conn,$sql"; if (!$conn) { exit("Connection Failed: " . $conn); } $rs=odbc_exec($conn,$sql); if(!$rs) { exit("Error in SQL"); } $dbMonth=odbc_result($rs,"month"); $dbDay=odbc_result($rs,"day"); while($i<4) { if($dbMonth<$thisMonth) { odbc_fetch_row($rs); $dbMonth=odbc_result($rs,"month"); $dbDay=odbc_result($rs,"day"); } if($dbMonth==$thisMonth) if($dbDay< $thisDay) { odbc_fetch_row($rs); $dbMonth=odbc_result($rs,"month"); $dbDay=odbc_result($rs,"day"); } if($dbMonth==$thisMonth) if($dbDay>= $thisDay) { if($i<4) { if($dbMonth=="01") { $dbMonth="January"; $eventMonth[$i]= "January"; } if($dbMonth=="02") { $dbMonth="February"; $eventMonth[$i]= "February"; } if($dbMonth=="03") { $dbMonth="March"; $eventMonth[$i]= "March"; } if($dbMonth=="04") { $dbMonth="April"; $eventMonth[$i]= "April"; } if($dbMonth=="05") { $dbMonth="May"; $eventMonth[$i]= "May"; } if($dbMonth=="06") { $dbMonth="June"; $eventMonth[$i]= "June"; } if($dbMonth=="07") { $dbMonth="July"; $eventMonth[$i]= "July"; } if($dbMonth=="08") { $dbMonth="August"; $eventMonth[$i]= "August"; } if($dbMonth=="09") { $dbMonth="September"; $eventMonth[$i]= "September"; } if($dbMonth=="10") { $dbMonth="October"; $eventMonth[$i]= "October"; } if($dbMonth=="11") { $dbMonth="November"; $eventMonth[$i]= "November"; } if($dbMonth=="12") { $dbMonth="December"; $eventMonth[$i]= "December"; } $eventMonth[$i]; $eventDay[$i]=odbc_result($rs,"day")."\n"; $eventYear[$i]=odbc_result($rs,"year")."\n"; $eventTime[$i]=odbc_result($rs,"time")."\n"; $eventDay[$i]=odbc_result($rs,"event")."\n"; $eventLocation[$i]=odbc_result($rs,"location")."\n"; $i++; odbc_fetch_row($rs); $dbMonth=odbc_result($rs,"month"); $dbDay=odbc_result($rs,"day"); } } if($dbMonth>$thisMonth) if($dbDay< $thisDay) { if($i<4) { if($dbMonth=="01") { $dbMonth="January"; $eventMonth[$i]= "January"; } if($dbMonth=="02") { $dbMonth="February"; $eventMonth[$i]= "February"; } if($dbMonth=="03") { $dbMonth="March"; $eventMonth[$i]= "March"; } if($dbMonth=="04") { $dbMonth="April"; $eventMonth[$i]= "April"; } if($dbMonth=="05") { $dbMonth="May"; $eventMonth[$i]= "May"; } if($dbMonth=="06") { $dbMonth="June"; $eventMonth[$i]= "June"; } if($dbMonth=="07") { $dbMonth="July"; $eventMonth[$i]= "July"; } if($dbMonth=="08") { $dbMonth="August"; $eventMonth[$i]= "August"; } if($dbMonth=="09") { $dbMonth="September"; $eventMonth[$i]= "September"; } if($dbMonth=="10") { $dbMonth="October"; $eventMonth[$i]= "October"; } if($dbMonth=="11") { $dbMonth="November"; $eventMonth[$i]= "November"; } if($dbMonth=="12") { $dbMonth="December"; $eventMonth[$i]= "December"; } $eventMonth[$i]; $eventDay[$i]=odbc_result($rs,"day"); $eventYear[$i]=odbc_result($rs,"year"); $eventTime[$i]=odbc_result($rs,"time"); $eventDay[$i]=odbc_result($rs,"event"); $eventLocation[$i]=odbc_result($rs,"location")."\n"; $i++; odbc_fetch_row($rs); $dbMonth=odbc_result($rs,"month"); $dbDay=odbc_result($rs,"day"); } } if($dbMonth>=$thisMonth) if($dbDay>= $thisDay) { if($i<4) { if($dbMonth=="01") { $dbMonth="January"; $eventMonth[$i]= "January"; } if($dbMonth=="02") { $dbMonth="February"; $eventMonth[$i]= "February"; } if($dbMonth=="03") { $dbMonth="March"; $eventMonth[$i]= "March"; } if($dbMonth=="04") { $dbMonth="April"; $eventMonth[$i]= "April"; } if($dbMonth=="05") { $dbMonth="May"; $eventMonth[$i]= "May"; } if($dbMonth=="06") { $dbMonth="June"; $eventMonth[$i]= "June"; } if($dbMonth=="07") { $dbMonth="July"; $eventMonth[$i]= "July"; } if($dbMonth=="08") { $dbMonth="August"; $eventMonth[$i]= "August"; } if($dbMonth=="09") { $dbMonth="September"; $eventMonth[$i]= "September"; } if($dbMonth=="10") { $dbMonth="October"; $eventMonth[$i]= "October"; } if($dbMonth=="11") { $dbMonth="November"; $eventMonth[$i]= "November"; } if($dbMonth=="12") { $dbMonth="December"; $eventMonth[$i]= "December"; } $eventMonth[$i]; $eventDay[$i]=odbc_result($rs,"day")."\n"; $eventYear[$i]=odbc_result($rs,"year")."\n"; $eventTime[$i]=odbc_result($rs,"time")."\n"; $eventDay[$i]=odbc_result($rs,"event")."\n"; $eventLocation[$i]=odbc_result($rs,"location")."\n"; $i++; odbc_fetch_row($rs); $dbMonth=odbc_result($rs,"month"); $dbDay=odbc_result($rs,"day"); } } } odbc_close($conn); ?> <div> <?php echo $eventMonth[1]; echo $eventDay[2]; echo $eventYear[1]; echo $eventLocation[1]; ?> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/256793-error-offset-1-database-error/#findComment-1316576 Share on other sites More sharing options...
kdawg2k12 Posted February 10, 2012 Author Share Posted February 10, 2012 okay guys I found the problem I assigned the eventDay variable twice. thanks for your input Link to comment https://forums.phpfreaks.com/topic/256793-error-offset-1-database-error/#findComment-1316581 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.