473,788 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

URL parsing in order to use as a variable

Can anyone tell me if it's possible to enter a URL such as

http://www.streetfish.co.uk/1234

and take the number and pass it to the index.php script (where the
number is the user's mySQL user id.

This is pretty much what happens with tinyurl.com (as far as I
understand) but the examples I have read regarding this are using
different technologies.

If anyone can help, or if you can let me know if you've seen a similar
example, I'd appreciate some help.

Thanks,

Dylan

Dec 20 '05 #1
7 1512
Following on from dylan's message. . .
Can anyone tell me if it's possible to enter a URL such as

http://www.streetfish.co.uk/1234

and take the number and pass it to the index.php script (where the
number is the user's mySQL user id.


The functionality you want is in the web server itself.
Look in the Apache docs for something like (never done it) URL
Rewriting.
--
PETER FOX Not the same since the submarine business went under
pe******@eminen t.demon.co.uk.n ot.this.bit.no. html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.dem on.co.uk>
Dec 20 '05 #2
Ok, I don't know exactly, but you would use an .htaccess script I
expect to get the address sent to a php script, then from that use the
substr command to take out the main url leaving you with 1234 which you
could put into a variable. You could just have something like this
though : streetfish.co.u k/link?id=1234 much easier.

Dec 20 '05 #3
@Peter: His server is ISS so he wont find anything helpful looking at
the apache docs, look at the errorpages.

Dec 20 '05 #4
dylan wrote:
Can anyone tell me if it's possible to enter a URL such as

http://www.streetfish.co.uk/1234


On Apache, there is an AcceptPathInfo= on directive, which should do
what you want (the corresponding variable in PHP is PATH_INFO - see
http://php.net/reserved.variables). Only it doesn't. I logged this as
a bug at: http://issues.apache.org/bugzilla/show_bug.cgi?id=8880 but it
was denied (they suggest a workaround at the bottom of the report). I
never did understand why they didn't want to do fix it.

I also didn't implement their suggestion because I now (as I suspect
most others) use url rewriting, a little of which is described at:
http://www.codecomments.com/archive2...-8-574178.html (of course,
there is more documentation at
http://httpd.apache.org/docs/2.0/urlmapping.html and
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html)

By the way, notice that PHP address above. It's doing the same thing
you want done. Don't know what to tell you for non Apache.

Csaba Gabor from Vienna

Dec 21 '05 #5
dylan wrote:
Can anyone tell me if it's possible to enter a URL such as

http://www.streetfish.co.uk/1234
and take the number and pass it to the index.php script (where the


On Apache, there is an AcceptPathInfo= on directive, which should do
what you want (the corresponding variable in PHP is PATH_INFO - see
http://php.net/reserved.variables - notice they are also doing what you
want). Only it doesn't. I logged this as a bug at:
http://issues.apache.org/bugzilla/show_bug.cgi?id=8880 but it was
denied (they suggest a workaround at the bottom of the report). I
never did understand why they didn't want to do fix it.

I also didn't implement their suggestion because I now (as I suspect
most others) use url rewriting, a little of which is described at:
http://www.codecomments.com/archive2...-8-574178.html (of course,
there is more documentation at
http://httpd.apache.org/docs/2.0/urlmapping.html and
http://httpd.apache.org/docs/2.0/mis...iteguide.html). There is
also a concrete example at:
http://mail-archives.apache.org/mod_...l.yahoo.com%3E

Don't know what to tell you for non Apache.

Csaba Gabor from Vienna

Dec 21 '05 #6
<?
$url= $_SERVER['PHP_SELF']; //gives you url
$userid=strrchr ($url,"/"); // gives u /1234
$userid=substr( $file,1); // gives u 1234 by eliminating /

/* i think u got it */
?>

<?php

echo $_SERVER['HTTP_HOST']; //outputs sitename.com etc
echo $_SERVER['REQUEST_URI']; //outputs /index.php etc
?>

Dec 22 '05 #7
hi,

Thanks for your help on this, been really busy lately, and only now
getting a chance to look at this,

I'll let you know how I get on.

Dylan

Jan 13 '06 #8

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

Similar topics

9
1959
by: Lisa | last post by:
I have a select statement that gives me the following results (for example) "test documentation/software product version document.doc" I need to parse the data to only grab everything between the "/" and ".". So, in other words, "software product version document" - I have absolutley no idea how to do this - can anyone help???? Thanks in advance! Lisa
7
4043
by: Johnny Sandaire | last post by:
Greetings, I have a file that I have written some data into it in the following manner: Charlene1719056:2011392059"1.908.555.1212"07083 The data is arranged in this order: name, size,Unique key,phone number, zip code
35
3392
by: .:mmac:. | last post by:
I have a bunch of files (Playlist files for media player) and I am trying to create an automatically generated web page that includes the last 20 or 30 of these files. The files are created every week and are named XX-XX-XX.ASX where the X's represent the date i.e. 05-22-05.asx The files are a specific format and will always contain tags like the following: <TITLE>My media file title</TITLE> <AUTHOR>Media file author</AUTHOR> <Ref href =...
6
7658
by: BerkshireGuy | last post by:
Does anyone know of a good function that will parse out parts of an SQL statement that is passed to it in seperate variables? It should be able to parse statements that contain ORDERBY, WHERE, GROUP, etc. Thank you, Brian
29
4266
by: zoltan | last post by:
Hi, The scenario is like this : struct ns_rr { const u_char* rdata; }; The rdata field contains some fields such as :
6
2318
by: giulianodammando | last post by:
In the development of a simple numerical simulation software i need to read some initialization parameters from a file that looks like: # Global Setup species = 1; \begin{specie}<1> name = NITROGEN;
8
2200
by: junky_fellow | last post by:
Hi, Sorry, for asking similar questions again and again. 1) I want to know how should we reslove the ambiguities in a c expression ? Should we use precedence table as mentioned in K&R book or should we refer to the ANSI C grammar ? 2) As told by many people in this newsgroup that ANSI C grammar does
5
5517
by: bmichel | last post by:
Hey, What I'm doing is the following: - Load XML data a file - Parsing the XML data - Printing some parsed content The problem is that the script execution is stopping before all the content is parsed and printed. Maybe the PHP is out of memory after a while. That would make sense
9
1554
by: dave.degroot | last post by:
What does this mean? PHP Parse error: parse error, unexpected T_CONSTANT_ENC\ APSED_STRING in /home/web/david/processedorder.php on line 23, referer: http://\ degroot.xidus.net/
13
4515
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple command set consisting of several single letter commands which take no arguments. A few additional single letter commands take arguments:
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10364
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
10172
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
10110
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
9967
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
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
6750
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
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
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.