Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-03-2007, 12:36 PM   PM User | #1
danielwarner
Regular Coder

 
Join Date: Oct 2005
Location: Surrey, England
Posts: 286
Thanks: 2
Thanked 2 Times in 2 Posts
danielwarner is an unknown quantity at this point
$_GET variables from a url string

im using a set of GET's form a url string that is generated from a search form. The problem is that none of the variables are showing up when echoed. The variables are obviously there because they are held in the url.

The problem i think i may have broken it down to is that the string looks a little something like this:

www.domain.com/search/?keywords=keywords..etc...

do i need to include the file name in order for the $_GET to work? I did a test with this and worked better than without the file name but that may have been because it was a different file. Is there a way of doing this using $_GET variables?


I flicked through the idea of sessions but i decided that i much prefer the idea of the url changing per search, this way the user can copy the search result url into an email etc...

Thanks for your help.
__________________
Daniel Warner
- - - - - - - - - -
GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.
danielwarner is offline   Reply With Quote
Old 01-03-2007, 01:39 PM   PM User | #2
MRMAN
Regular Coder

 
Join Date: Jan 2006
Location: Preston, Lancashire, England
Posts: 285
Thanks: 0
Thanked 0 Times in 0 Posts
MRMAN is an unknown quantity at this point
Do you have a sample of your code that you have. It would make it easier to see what the problem is
MRMAN is offline   Reply With Quote
Old 01-03-2007, 01:54 PM   PM User | #3
danielwarner
Regular Coder

 
Join Date: Oct 2005
Location: Surrey, England
Posts: 286
Thanks: 2
Thanked 2 Times in 2 Posts
danielwarner is an unknown quantity at this point
ok well this is a very bad example. I know the query doesnt work or anything yet and the code is scrappy but thats because im only trying to build the query at the moment...

PHP Code:
<?php

    
//Return Query Builder
    
$manufacture_query $_GET['manufacture'];
    
$berth_query $_GET['berth'];
    
$location_query $_GET['location'];
    
$keywords_query $_GET['keywords'];
    
$from_query $_GET['from'];
    
$to_query $_GET['to'];
    
$private_query $_GET['private'];
    
$trade_query $_GET['trade'];
    
$year_query $_GET['year'];
    
$man_id2 $manufacture_query;

        if(
$from_query != ""){$search_returned 1;}

        if(
$_GET["manufacture"] == "0"){$manufacture_query "";}
        if(
$_GET["location"] == "0"){$location_query "";}
        if(
$_GET["year"] == "0"){$year_query "";}
        if(
$_GET["berth"] == "0"){$berth_query "";}

//Attempting to echo results
echo $manufacture_query "<br>" .
     
$berth_query "<br>" .
     
$location_query "<br>" .
     
$keywords_query "<br>" .
     
$from_query "<br>" .
     
$to_query "<br>" .
     
$private_query "<br>" .
     
$trade_query "<br>" .
     
$year_query "<br>";

    if(
$search_returned 1){
    
$result "SELECT * FROM `adverts` WHERE `manufacture_id` ='$manufacture_query' && location_id ='$location_query' ORDER BY `timestamp` DESC";
    echo 
$result;
    }
    else { 
$result "SELECT * FROM `adverts` ORDER BY `timestamp` DESC"; }
Im pretty sure there is nothing wrong with the way i attempt to echo the variables...i did a var_dump and the result came back NULL so the $_GET doesnt want to collect the data from the url.

Heres a (not) working example. http://www.caravansandtrailertents.co.uk/search/ The page should show the query trying to be built for development purposes and it should try to echo the variable...thats why the code shows a series of <br>'s with no information.

The reason i dont want to use search/index.php is because caravansandtrailertents.co.uk/search/ is a mod_rewrite in my .htdocs for the url ...co.uk/index.php?pageref=search
__________________
Daniel Warner
- - - - - - - - - -
GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.

Last edited by danielwarner; 01-03-2007 at 01:56 PM..
danielwarner is offline   Reply With Quote
Old 01-03-2007, 02:19 PM   PM User | #4
MRMAN
Regular Coder

 
Join Date: Jan 2006
Location: Preston, Lancashire, England
Posts: 285
Thanks: 0
Thanked 0 Times in 0 Posts
MRMAN is an unknown quantity at this point
I think this may be a problem with the mod rewrite. but i have never done mod rewrite so i can't say for sure.

Sorry
MRMAN is offline   Reply With Quote
Old 01-03-2007, 02:48 PM   PM User | #5
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
What version of php are you using?
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 01-03-2007, 02:53 PM   PM User | #6
danielwarner
Regular Coder

 
Join Date: Oct 2005
Location: Surrey, England
Posts: 286
Thanks: 2
Thanked 2 Times in 2 Posts
danielwarner is an unknown quantity at this point
www.caravansandtrailertents.co.uk/phpinfo.php
__________________
Daniel Warner
- - - - - - - - - -
GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.
danielwarner is offline   Reply With Quote
Old 01-03-2007, 03:02 PM   PM User | #7
MRMAN
Regular Coder

 
Join Date: Jan 2006
Location: Preston, Lancashire, England
Posts: 285
Thanks: 0
Thanked 0 Times in 0 Posts
MRMAN is an unknown quantity at this point
like i said i think its a problem with your mod rewrite. if you do this

Code:
http://www.caravansandtrailertents.co.uk/index.php?pageref=search&manufacture=13
then "13" is shown on the screen on its own and in the mysql_query
MRMAN is offline   Reply With Quote
Old 01-03-2007, 03:05 PM   PM User | #8
danielwarner
Regular Coder

 
Join Date: Oct 2005
Location: Surrey, England
Posts: 286
Thanks: 2
Thanked 2 Times in 2 Posts
danielwarner is an unknown quantity at this point
do you have any suggestions in this case for how i can hide the url string containing the index.php?pageref....etc?
__________________
Daniel Warner
- - - - - - - - - -
GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.
danielwarner is offline   Reply With Quote
Old 01-03-2007, 03:14 PM   PM User | #9
MRMAN
Regular Coder

 
Join Date: Jan 2006
Location: Preston, Lancashire, England
Posts: 285
Thanks: 0
Thanked 0 Times in 0 Posts
MRMAN is an unknown quantity at this point
why do you need to pass the search details in the url. can't you make the form a post form (method="post") and change $_GET[" to $_POST["

if you can't then this link http://www.phpfreaks.com/tutorials/23/1.php might help with the mod_rewrite
MRMAN is offline   Reply With Quote
Old 01-03-2007, 04:15 PM   PM User | #10
danielwarner
Regular Coder

 
Join Date: Oct 2005
Location: Surrey, England
Posts: 286
Thanks: 2
Thanked 2 Times in 2 Posts
danielwarner is an unknown quantity at this point
Wow thanks for that tutorial, im working on converting it but by reading it i have realised that i have made a huge mistake in my .htaccess file and can improve the effeciency LOADS!

Thanks again!
__________________
Daniel Warner
- - - - - - - - - -
GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.
danielwarner is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:41 AM.


Advertisement
Log in to turn off these ads.