473,748 Members | 10,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query Strings, extract() and including pages

I wanted to do:
include('page.h tm?id=12&foo=ba r');

But since I can't (and don't want to make another seperate HTTP request
with include('http://...')); I was wondering if there's a function
similar to extract(); that can handle a query string as input, so that I
could:
$id = 12;
$foo = 'bar';
include('page.h tm');

I am using this on a 'processor' style page to interperet URLs as
http://foo.com/bla. It consults a database to manage a large number of
URLs to their pages.

Jul 17 '05 #1
5 2060
Logical wrote:
I wanted to do:
include('page.h tm?id=12&foo=ba r');

But since I can't (and don't want to make another seperate HTTP request
with include('http://...')); I was wondering if there's a function
similar to extract(); that can handle a query string as input, so that I
could:
$id = 12;
$foo = 'bar';
include('page.h tm');

In your included file, you can use:

global $id, $foo;

And you'll be able to use those variables just like any other variable.

--
Pieter Nobels
Jul 17 '05 #2

"Logical" <me@privacy.net > wrote in message
news:41******** *************** @un-2park-reader-01.sydney.pipen etworks.com.au. ..
I wanted to do:
include('page.h tm?id=12&foo=ba r');

But since I can't (and don't want to make another seperate HTTP request
with include('http://...')); I was wondering if there's a function
similar to extract(); that can handle a query string as input, so that I
could:
$id = 12;
$foo = 'bar';
include('page.h tm');

I am using this on a 'processor' style page to interperet URLs as
http://foo.com/bla. It consults a database to manage a large number of
URLs to their pages.


Don't quite understand what you're trying to do, but I think parse_str() is
what you're looking for.
--
Obey the Clown - http://www.conradish.net/bobo/
Jul 17 '05 #3
Pieter Nobels wrote:
Logical wrote:
I wanted to do:
include('page.h tm?id=12&foo=ba r');

But since I can't (and don't want to make another seperate HTTP
request with include('http://...')); I was wondering if there's a
function similar to extract(); that can handle a query string as
input, so that I could:
$id = 12;
$foo = 'bar';
include('page.h tm');


In your included file, you can use:

global $id, $foo;

And you'll be able to use those variables just like any other variable.


Isn't global-ing variables like that not required?
<http://www.php.net/manual/en/language.variab les.scope.php>

I'm actually more concerned about how to get $id and $foo 'out of' the
query string attached to the URL (this part: page.htm?id=12& foo=bar).
Jul 17 '05 #4
Chung Leong wrote:
"Logical" <me@privacy.net > wrote in message
news:41******** *************** @un-2park-reader-01.sydney.pipen etworks.com.au. ..
I wanted to do:
include('page .htm?id=12&foo= bar');

But since I can't (and don't want to make another seperate HTTP request
with include('http://...')); I was wondering if there's a function
similar to extract(); that can handle a query string as input, so that I
could:
$id = 12;
$foo = 'bar';
include('page .htm');

I am using this on a 'processor' style page to interperet URLs as
http://foo.com/bla. It consults a database to manage a large number of
URLs to their pages.

Don't quite understand what you're trying to do, but I think parse_str() is
what you're looking for.

parse_str(), that's it!
Thanks.
Jul 17 '05 #5
"Logical" wrote:
Pieter Nobels wrote:
Logical wrote:
I wanted to do:
include(’page.h tm?id=12&foo=ba r’);

But since I can’t (and don’t want to make another seperate HTTP request with include(’http://...’)); I was wondering if there’s a function similar to extract(); that can handle a query string as input, so that I could:
$id = 12;
$foo = ’bar’;
include(’page.h tm’);


In your included file, you can use:

global $id, $foo;

And you’ll be able to use those variables just like any

other variable.

Isn’t global-ing variables like that not required?
<http://www.php.net/manual/en/language.variab les.scope.php>

I’m actually more concerned about how to get $id and $foo
’out of’ the
query string attached to the URL (this part:
page.htm?id=12& foo=bar).


When you include a file, it inherits the scope of variables at the
point of inclusion. It means that $id and $foo are available to the
included script already. You would need to declare them as global
only if your include is a function.

steve

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-Query-St...ict138606.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=466974
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1496
by: theboss3 | last post by:
I am having trouble with accessing files with query strings. For example the code "require 'template.php?102932'" gives the following error: Warning: main(/www/blog/template.php?102932): failed to open stream: Invalid argument in C:\www\blog\2004\12\27\best-of-2004\index.php on line 54 Fatal error: main(): Failed opening required
20
5772
by: Ravi | last post by:
Hi, I have about 200GB of data that I need to go through and extract the common first part of a line. Something like this. >>>a = "abcdefghijklmnopqrstuvwxyz" >>>b = "abcdefghijklmnopBHLHT" >>>c = extract(a,b) >>>print c "abcdefghijklmnop"
4
2781
by: Venkat | last post by:
Hi All, I need to copy strings from a single dimensional array to a double dimensional array. Here is my program. #include <stdio.h> #include <stdlib.h>
6
29940
by: Martin Lacoste | last post by:
Ok, before I headbutt the computer... don't know why when I add criteria in a query, I get an 'invalid procedure call'. I also don't know why after searching the help in access, the various access newsgroups, the access support centre, I can seem to find no similar situation. I am not using any references, or VBA at all in the first place. I am trying to set up a simple (or so I thought) query to work with the text of two tables. ...
3
2097
by: Serious_Practitioner | last post by:
Good day, and thank you in advance for any assistance you can provide. I have a table in an Access 2000 .mdb file, and I've run into something odd and insolvable, at least for me. The database is for membership information. This particular table, called tblMembershipInfo, has fields/columns as follows - fldMemNum - Member Number fldActionDate - The date when the entry was made in that row - Data type is Date/Time, no format specified
8
2589
by: Bob | last post by:
I need to create a Regex to extract all strings (including quotations) from a C# or C++ source file. After being unsuccessful myself, I found this sample on the internet: @"@?""""|@?"".*?(?!\\).""|''|'.*?(?!\\).'" I am inputting the entire source file string and using it with RegexOptions.Singleline. This works OK with, unless the string ends with a back-slash. For example: "This is a test\\". Can anybody see how to fix this...
2
1512
by: Jeff Gardner | last post by:
Greetings: I am attempting to split an input string using the str_word_count function to return multiple single word query variables. I can create an array based on $search=(str_word_count($search, 1, '0123456789')); (I want words and/or numbers). I can extract named variables from the resulting array via $search=extract($search, EXTR_PREFIX_ALL, search); and then call each variable by
2
1361
by: Simon Rigby | last post by:
Hi folks, ASP.NET2, Sql Server 2005 I have an app that executed a sql server query that produces an XML file used as the DateFile for an XMLDataSource bound to a TreeView. The bizarre thing is that it seems to be cached even if I make a change to the stored procedure. For example I changed a string literal in the proc and it was completely ignored then next time I viewed the page.
17
2732
by: NeoAlchemy | last post by:
I am starting to find more web pages that are using a query parameters after the JavaScript file. Example can be found at www.opensourcefood.com. Within the source you'll see: <script src="/shared/scripts/common.js?revision=1.6" type="text/javascript">. I am trying to see if there is any big deal to this or a best practice that is starting to creep up in the JavaScript community. If this is used only as a way to distinguish what...
0
8828
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9367
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9319
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.