paulman888888 Posted June 12, 2009 Share Posted June 12, 2009 hi; My variable $userpostcode is no being passed on from line 2; ($userpostcode=$userdata['postcode'] to line 15 ($body.="<tr><th>ID</th><th>Event Name</th><th>Date</th><th>PostCode</th><th>Distance from ".$userpostcode."</th><th>View Event</th></tr>" or any line after that. I don't understand! To check i echo after line 2 to see if there way a variable in $userpostcode and there was. Everything else added to $body is echo later and i can see it all but that 1 variable isn't showing at all. Why? Please please please help me. Code <?php $userpostcode=$userdata['postcode']; $page_title='Events'; $page_subtitle='Showing All '; $userpostcode=$_REQUEST['postcode']; $header_scripts='<script src="'.$site_location.'/js/sorttable.js"></script>'; $query = "SELECT * FROM chess_event ";if(isset($_GET['when'])){ $only=strtolower($_GET['when']);$when=$only;if($only == 'upcoming'){$page_subtitle.=' Upcoming'; $query.= " WHERE day > CURDATE()";$page_title.=" - Upcoming"; }elseif($only == 'past'){ $page_subtitle.=' Past';$query .= " WHERE day < CURDATE()";$page_title.=" - Past";}}else{$page_title.=" - All";} $result = mysql_query($query)or die(mysql_error()); $page_subtitle.=' Events'; $body.='<table border="0" width="100%" cellspacing="0" class="sortable">'; $body.="<tr><th>ID</th><th>Event Name</th><th>Date</th><th>PostCode</th><th>Distance from ".$userpostcode."</th><th>View Event</th></tr>"; while($row = mysql_fetch_array($result)){ $body.="<tr>"; $body.='<td><center><a href="/?page=View_Event&id='.$row['id'].'">'.$row['id']."</a></center></td>\n"; $body.="<td><center>".$row['name']."</center></td>"; $body.="<td><center>".mysql2uk($row['day'])."</center></td>"; $body.="<td><center>".$row['postcode']."</center></td>"; $body.="<td><center>".get_latlong_from_postcodes($userpostcode, $row['postcode'])."</center></td>"; $body.='<td><center><a href="/?page=View_Event&id='.$row["id"].'">More</a></center></td>'; $body.="</tr>"; $i++; // increment counter }$body.="</table>"; ?> Thankyou in advance Paul Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted June 12, 2009 Share Posted June 12, 2009 Line 2: $userpostcode=$userdata['postcode']; So where is $userdata set? Quote Link to comment Share on other sites More sharing options...
paulman888888 Posted June 12, 2009 Author Share Posted June 12, 2009 its set in my index file. My index.php inlcludes every other page on it. i did this is a test to see where the error was lyeing. index.php $userdata['postcode']='SW10'; include'page.php'; page.php <?php $userpostcode=$userdata['postcode']; $page_title='Events'; echo 'test; '.$userpostcode; $page_subtitle='Showing All '; $userpostcode=$_REQUEST['postcode']; $header_scripts='<script src="'.$site_location.'/js/sorttable.js"></script>'; $query = "SELECT * FROM chess_event ";if(isset($_GET['when'])){ $only=strtolower($_GET['when']);$when=$only;if($only == 'upcoming'){$page_subtitle.=' Upcoming'; $query.= " WHERE day > CURDATE()";$page_title.=" - Upcoming"; }elseif($only == 'past'){ $page_subtitle.=' Past';$query .= " WHERE day < CURDATE()";$page_title.=" - Past";}}else{$page_title.=" - All";} $result = mysql_query($query)or die(mysql_error()); $page_subtitle.=' Events'; $body.='<table border="0" width="100%" cellspacing="0" class="sortable">'; $body.="<tr><th>ID</th><th>Event Name</th><th>Date</th><th>PostCode</th><th>Distance from ".$userpostcode."</th><th>View Event</th></tr>"; while($row = mysql_fetch_array($result)){ $body.="<tr>"; $body.='<td><center><a href="/?page=View_Event&id='.$row['id'].'">'.$row['id']."</a></center></td>\n"; $body.="<td><center>".$row['name']."</center></td>"; $body.="<td><center>".mysql2uk($row['day'])."</center></td>"; $body.="<td><center>".$row['postcode']."</center></td>"; $body.="<td><center>".get_latlong_from_postcodes($userpostcode, $row['postcode'])."</center></td>"; $body.='<td><center><a href="/?page=View_Event&id='.$row["id"].'">More</a></center></td>'; $body.="</tr>"; $i++; // increment counter }$body.="</table>"; ?> And on the 3rd line it echo-ed the $userpostcode but not on the lines below it. Why? where has this variable gone? Thankyou in advance again Paul Quote Link to comment Share on other sites More sharing options...
paulman888888 Posted June 12, 2009 Author Share Posted June 12, 2009 sorry i found the error. i had a get command updating it sorry for any time wasted Quote Link to comment 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.