473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do you capture the dynamic data that comes in with a URL?

I'm trying to capture the dynamic data that comes in with the URL and put them into variables and then store them in my database.
Following line is the disguised Url with the data.
http://xxxxxx.net/xxxxxxxx/xxxxxx/xxxxxx.htm?lat=36.3&long=-115.2625

The data is:
'lat' value = 36.3 (this will be stored in a varchar(10) field in the database. (field is for latitude)
'long' value = -115.2625 (this will be stored in a varchar(10) field in the database. (field is for longitude)

The form is working fine but I can't seem to capture this data from the url.
I have searched the web and I'm starting to go crazy and was hoping you could help.

I have attached my 'index.php' file with my mods all marked with //custom so you could see what I was trying to do.

Any help that you could give me would really be appreciated.

Looking forward to your reply

Thank you

Ray Ward
Attached Files
File Type: txt index.txt (3.5 KB, 13 views)
May 6 '11 #1
5 1664
JKing
1,206 Expert 1GB
Hi there,

It looks like you are accessing it properly through $_GET.

Are you receiving any errors?
May 6 '11 #2
No errors.
All other data on form is being correctly stored into my database, only the 'lat' & 'long, fields are not being stored.
I even looked at the url and the 'lat' and 'long' fields were present.
This is really puzzling
If you have any other ideas please let me know.
Thanks for the reply
Ray
May 6 '11 #3
JKing
1,206 Expert 1GB
Just to clarify, are the $lat and $lang variables being populated and just not being inserted in the database or are the variables set to empty strings?
May 6 '11 #4
variables are set to empty strings.
I found this out by using the print & echo cmds.
The rest of my variables are coming from a form the customer completes on his smart phone and the 'lat', 'long' fields are added by his cell phone to the end of the url.
May 6 '11 #5
If the URL has been directly manipulated programmatically, you will not find the variables in the GET array:

You must then extract it yourself from the URL (accessed with $current_url = $_SERVER['REQUEST_URI'];). The following code is not mine. It extracts the pseudo-variables from the URL and assigns them to name, value pairs in an array:

Expand|Select|Wrap|Line Numbers
  1. // Found at http://www.logon2.com.au/blog/archive/coding/coding-php/extract-get-variables-
  2. //...from-url-string-to-array-php-function */                 function getVariableFromUrl($url)
  3. {
  4. //we need to see if this URL is passing any GET variables
  5. $variablesStart = strpos($url, "?") + 1;
  6. if (!$variablesStart)
  7. {
  8. // no variables!
  9. return(false);
  10. }
  11. //before we extract the variables, we need to remove any anchors
  12. $variablesEnd = strpos($url,"#",$variablesStart);
  13. if ($variablesEnd)
  14. {
  15. $getVariables = substr($url, $variablesStart, $variablesEnd - $variablesStart);
  16. }
  17. else
  18. {
  19. $getVariables = substr($url, $variablesStart);
  20. }
  21. //next, we split the URL into an arrays containing variable name and value pairs (ie. "variable=value")
  22. $variableArray = explode("&", $getVariables);
  23. //we will iterate through each of the array pairs (ie. "variable=value")
  24. foreach ($variableArray as $arraySet)
  25. {
  26. $nameAndValue = explode("=", $arraySet);
  27. //using the above examples, $nameAndValue[0] would be "variable" and $nameAndValue[1] would be "value"
  28. $output[$nameAndValue[0]] = urldecode($nameAndValue[1]);
  29. }
  30. return($output);
  31. }
  32.  
Mar 20 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: JerryB | last post by:
i am looking for a way to capture some data from a web DB that is set up to only allow a user to view one page of a query at a time or to print the entire query. i don't want to print and retype...
5
by: Charlie | last post by:
Hi, The description of Python always mentions "very high level dynamic data types". Now, I can't seem to find any examples of these (nothing described with this term anyway). Is this simply...
4
by: Alan Silver | last post by:
Hello, I'm trying to use an ArrayList to do data binding, but am getting an error I don't understand. I posted this in another thread, but that was all confused with various other problems,...
3
by: Trev | last post by:
Hi, I have a series of functions which do the following: ValidateData( args ); //args if of type ArrayList // Work out if the data is valid or not, and work out the type of args - int, string,...
3
by: Stephens | last post by:
Hi, I'm new in web services. I just made 2 web services using C# and .Net that receive a string and integer and echo the data back to client. If I make a client using C# and .Net, I can send...
0
by: ting ting | last post by:
How can I save the database information into a XML file using ASP.net 2.0? I want to load the records once per day from the server when the user open the PC to avoid the web page to capture the data...
2
by: Max2006 | last post by:
Hi, I can see ASP.NET MVC and ASP.NET Dynamic Data extensions are not tagged as beta anymore here: http://www.asp.net/downloads/ Does this mean that we have the final release and we can...
1
by: markla | last post by:
Hi, Can someone help me understand why for the code below, when added as a "FieldTemplate" in Dynamic Data, and rendered for a field, does not trigger the "test" function and hence update the...
1
by: Peter | last post by:
ASP.NET 3.5 I am using HowerMenueExtender to do Balloon popups inside a DataList, and it works fine for static data, but I don't know how to display dynamic data, I don't know how/where to...
1
by: sutch | last post by:
I have created a DDE( Dynamic-Data Exchange) Client (Console) application to interact with a legacy DDE Server. This client is working perfectly I am asked to develop same functionality in a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.