Jump to content

[SOLVED] Something Strange. Variable Not Passing On! Please Help!


paulman888888

Recommended Posts

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

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

 

Archived

This topic is now archived and is closed to further replies.

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