Page 2 of 2
Posted: Wed Nov 08, 2006 3:28 am
by volka
If you make
Code: Select all
<?php
echo "document.write('<fieldset><legend>GET parameter</legend>');";
foreach($_GET as $i=>$v) {
echo "document.write('$i: $v<br />');";
}
echo "document.write('</fieldset>');";
?>
the contents of map_data2.php what is printed?
Posted: Wed Nov 08, 2006 3:58 am
by garry27
i get the same.
i'm guessing there's a problem with the script url reference in create_crawl.php as $query_string outputs ok if i echo it out from within the php page:
dj=&liveMusic=&kidsZone=&lateLice=&nsArea=&food=true&garden=&skySport=true&cocktails=true&pool=true
heres the code again from create_crawl.php :
Code: Select all
$dj = $_GET['dj'];
$liveMusic = $_GET['liveMusic'];
$nsArea = $_GET['nsArea'];
$food = $_GET['food'];
$skySport = $_GET['skySport'];
$cocktails = $_GET['cocktails'];
$pool = $_GET['pool'];
$garden = $_GET['garden'];
$lateLice = $_GET['lateLice'];
$kidsZone = $_GET['kidsZone'];
//$query_string = 'foo=' . urlencode($) . '&bar=' . urlencode($bar);
$query_string = 'dj=' . urlencode($dj) . '&liveMusic=' . urlencode($liveMusic)
. '&kidsZone=' . urlencode($kidsZone) . '&lateLice=' . urlencode($lateLice)
. '&nsArea=' . urlencode($nsArea) . '&food=' . urlencode($food)
. '&garden=' . urlencode($garden) . '&skySport=' . urlencode($skySport)
. '&cocktails=' . urlencode($cocktails) . '&pool=' . urlencode($pool);
echo xhtmlheader('Create Pub Crawl', 'KEY', 'map_data2.php?'. htmlentities($query_string), 'mapFunctions.js'); //'map_data.php',
Posted: Wed Nov 08, 2006 4:18 am
by volka
I tried
Code: Select all
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>
<head>
<SCRIPT language=JavaScript src='map_data2.php?dj=&liveMusic=&kidsZone=true&lateLice=true&nsArea=true&food=&garden=&skySport=&cocktails=&pool= ' ></SCRIPT>
</head>
<body>
test
</body>
</html>
and the output was
GET parameter
dj:
liveMusic:
kidsZone: true
lateLice: true
nsArea: true
food:
garden:
skySport:
cocktails:
Posted: Wed Nov 08, 2006 5:15 am
by garry27
my mistake sorry. too many comment tags in my php script. heh
GET parameter
dj:
liveMusic:
kidsZone:
lateLice:
nsArea:
food: true
garden:
skySport:
cocktails: true
pool:
i get the correct data sent then. i've already rechecked the php code that generates $filter in a previous backup so i don't know why it causes my script to fail when i include a reference to $filter.
Posted: Wed Nov 08, 2006 6:16 am
by volka
neither do I since I thought
<SCRIPT language=JavaScript src='map_data2.php?dj=&liveMusic=&kidsZone=true&lateLice=true&nsArea=true&food=&garden=&skySport=&cocktails=&pool= ' ></SCRIPT>
is a copy&paste example of the output of your script?
Posted: Wed Nov 08, 2006 6:37 am
by garry27
... interesting. if i change the $_GET variable to $_POST, my map markers will output along with the jscript alertbox with $sql_str (previously $filter)as the value. but obviously the value of $sql_str is still empty . if i change it back, my markers dissappear and no checkbox, just like before.
what the hells going on?
here's the full script for map_functions2.php which is called in the header of create_crawl2.php
Code: Select all
<?php
require_once('common.php');
db_connect();
// remove any harmless run-time notices
// error_reporting(E_ALL ^ E_NOTICE);
// create an array for amenity checkbox names
$chkbox_arr = array ( 'dj', 'liveMusic', 'nsArea','food','skySport', 'cocktails'
,'pool', 'garden', 'lateLice', 'kidsZone' );
// remove any checkboxes from the array which haven't been checked by the user
for ( $i = 0; $i <10; $i++ ) {
$element = $chkbox_arr[$i];
if ( !isset( $_POST[$element] ) ) {
unset( $chkbox_arr[$i] );
}
}
// re-sort the index and count the elements in $chkbox_arr
sort ($chkbox_arr);
$result = count($chkbox_arr);
//add sql code to each element in order to filter by element='y'
for ( $i = 0; $i <$result; $i++ ) {
$chkbox_arr[$i]=' AND Amenities.'.$chkbox_arr[$i]."='y'";
}
// string together all elements in a single string
$sql_str = implode(" ", $chkbox_arr );
// $sql = mysql_query ("select Pubs.pubID from Pubs, Amenities where Pubs.pubID=Amenities.pubID $filter") or die( 'Invalid query: ' . mysql_error() );
// $sql2 = mysql_query ("select Latitude, Longitude, pubName, pubStreetNo, pubStreet, pubCity, pubCounty, pubPostcode, pubPhone from Pubs where Pubs.pubID=Amenities.pubID $filter") or die( 'Invalid query: ' . mysql_error() );
$sql = mysql_query ( " select Latitude, Longitude, pubName, pubStreetNo, pubStreet, pubCity, pubCounty,
pubPostcode, pubPhone from Pubs " ) or die( 'Invalid query: ' . mysql_error() );
$markers = array();
while( $elements = mysql_fetch_array($sql) ) {
$br = '<br>';
$markers[] = '{'
." 'latitude' : " .$elements[0] .','
." 'longitude' : " .$elements[1] .','
." 'name' : '" .$sql_str."'"
// ."'address': '" .$elements[3] .$br .$elements[4] .$br .$elements[5]
// .$br .$elements[6] .$br .$elements[7] ."',"
// ."'phone': '" .$elements[8] ."'"
.'},';
}
//convert array into a single string variable
$markers = implode( ' ', $markers );
//remove the end comma in the string
$markers = substr_replace($markers,"",-1);
$jscript = 'var markers; markers =' .'[' .$markers .'];';
print " alert( '" .$sql_str ."' );";
print $jscript;
?>
btw thanks for everyones help!
Posted: Wed Nov 08, 2006 6:53 am
by garry27
volka, im not sure what you meant in your previous message. here's a link if you want to take a look at the urls feedback and stuff

:
http://www.nl-webspace.co.uk/~unn_p9218 ... ndpubs.php
Posted: Wed Nov 08, 2006 9:30 am
by volka
Sorry, I give up understanding what you're trying to do.