Jump to content

Recommended Posts

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

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.