TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Passing a variable from JavaScript to PHP (http://www.talkphp.com/general/5587-passing-variable-javascript-php.html)

bigcougar 09-28-2010 11:50 PM

Passing a variable from JavaScript to PHP
 
Here is my little problem.

I have this page:

http://www.troutsalmonchar.com/ART_BC_LKS_Horseshoe.php

If you click on the map , you will see the name the php file and the parameter (variable) that I am trying to pass on to it.

The idea is that the drop down menu will be populated with data from the server based on this filtering parameter.

Here is my php file

Code:

<?php
$link = mysql_connect('server', 'user', 'password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
if(!mysql_select_db(julesjelez_IC_20100723_183411))
    die ("Error selecting db:".mysql_error());
echo $_REQUEST[area];
$area = $_REQUEST['area'];
$result=@mysql_query("SELECT ID, W_Name from Streams_Lakes WHERE W_Country=$area");

if (!$result)
        die("Error retrieving customer from database.");
while ($row=mysql_fetch_array($result)) {
        echo $row["ID"]."\n".
                $row["W_Name"];
}


?>

Do you see my mistake? The JavaScript request function seems to work OK, as well as the connection to the server.

Seraphim 10-04-2010 02:05 PM

It looks to me like it is producing a http GET in a field that the PHP is not written to accept.


try http://www.troutsalmonchar.com/ART_B...Horseshoe.php?area=CNUS for example, editing the Javascript to trigger the $_REQUEST[area] in your PHP. That should at least produce the reply you are looking for, which can then be directed into the dropdown instead of the message box.


All times are GMT. The time now is 08:58 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0