TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-28-2010, 11:50 PM   #1 (permalink)
The Visitor
Newcomer 
 
Join Date: Sep 2010
Posts: 1
Thanks: 0
bigcougar is on a distinguished road
Default 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.
bigcougar is offline  
Reply With Quote
Old 10-04-2010, 02:05 PM   #2 (permalink)
The Visitor
 
Join Date: Oct 2010
Location: On the intertubes
Posts: 2
Thanks: 0
Seraphim is on a distinguished road
Default

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.
Send a message via AIM to Seraphim Send a message via MSN to Seraphim
Seraphim is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Easily Format JSON using PHP and Interpret using Javascript Wildhoney Advanced PHP Programming 13 02-01-2013 11:05 AM
Building Javascript PHP problem captainmerton Absolute Beginners 2 10-31-2009 10:02 AM
passing a java variable to php pipesportugal Advanced PHP Programming 11 08-27-2009 10:49 PM
Treat PHP Strings as Objects (Like Javascript) Wildhoney Tips & Tricks 14 06-19-2009 01:34 PM
Preventing Spam with PHP and Javascript Wildhoney General 9 10-24-2007 11:35 AM


All times are GMT. The time now is 02:12 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design