• I had this on another host and all was fine with the custom search and display page. After migrating over to Name.com, it will not load the winery-display page and displays 403:Forbidden. I can take off the search parameters and the page loads without displaying the message. In either case, it displays no data.

    Is there a setting within the WP site or Control Panel that I need to change so that it allows parameters in the address line? I have disabled all plugins and done a reinstall of WP.

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • I don’t think it’s an issue with having parameters in the URL. For example, appending:

    ?p=2 will redirect to you same page as expected.

    ?s=sample shows the Search Results page with the above page in the list of results.

    So query parameters are working as expected. Looking at the Winery Results I was able to get that working too without running into a 403 error. Appending this works for me:

    winery-results/?winename=&cityst=Washington%28DC%29&regionst=Central%28DC%29&Search=Search I’m not sure why the images can’t be found. Maybe check the media library on those.

    Maybe try clearing your browsers cache as it could be caching an old version of the site or it’s files.

    Thread Starter sjlink39

    (@sjlink39)

    I have the code

    $winename = get_query_var( 'winename', '' );
    			$cityst = get_query_var( 'cityst', '-select-' );
    			$regionst = get_query_var( 'regionst', '-select-' );
    			if($winename <> '') {
    				$winerys = $wpdb->get_results("SELECT * FROM Wineries WHERE Name LIKE '%".$winename."%' ORDER By Name");
    			}

    yet it is like get_query_var is not working since it never sets $winerys
    I installed the Query Monitor plugin and it indicates that $winerys is unknown

    Thread Starter sjlink39

    (@sjlink39)

    I have added

    function wwp_custom_query_vars_filter($vars) {
        $vars[] = 'winename';
    	$vars[] = 'cityst';
    	$vars[] = 'regionst';
    	$vars[] = 'Search';
        return $vars;
    }
    add_filter( 'query_vars', 'wwp_custom_query_vars_filter' );

    to functions.php

    I’m not sure why you would want to use query_vars at all. You’re not necessarily making endpoints. My understanding of how query_vars work is that they need to be accompanied by custom rewrite rules to process the query vars. Pre the docs:

    Allows (publicly allowed) query vars to be added, removed, or changed prior to executing the query. Needed to allow custom rewrite rules using your own arguments to work, or any other custom query variables you want to be publicly available.

    If you want to work with query strings you can use if/else:

    $wine = isset( $_GET, $_GET['winename'] ) ? $_GET['winename'] : '';

    Or in PHP 7+

    $cityst = isset( $_GET['cityst'] ?? '-select-';

    Thread Starter sjlink39

    (@sjlink39)

    I tried your isset example and it didn’t retrieve the query variables. Then I tried the code below and it still doesn’t retrieve the variables. Then I took out the query_vars add filter and it still didn’t help.

    $winename = $_GET['winename'];
    			$cityst = $_GET['cityst'];
    			$regionst = $_GET['regionst'];

    Maybe I set up the isset wrong – $cityst = isset( $_GET['cityst'] ) ?? '-select-';

    Help!

    This looks right if you’re running PHP 7.

    $cityst = isset( $_GET['cityst'] ) ?? '-select-';

    Otherwise it would look like this:

    $wine = isset( $_GET, $_GET['winename'] ) ? $_GET['winename'] : '';

    Where are you running this code? Any specific hook or file? Are you certain the file is being uploaded and that you are in the right file? Are you running it in PHP tags?

    <?php $wine = isset( $_GET, $_GET['winename'] ) ? $_GET['winename'] : ''; ?>`

    Thread Starter sjlink39

    (@sjlink39)

    PHP 7.4, but it runs through until the last one. Apparently not picking up any of the parameters. Even at the end, it gets $regionst as empty.

    	<?php 
    			$winename = $_GET['winename'];
    			$cityst = isset( $_GET['cityst'] ) ?? '-select-';
    			$regionst = $_GET['regionst'];
    			if($winename <> '') {
    				$winerys = $wpdb->get_results("SELECT * FROM Wineries WHERE Name LIKE '%".$winename."%' ORDER By Name");
    			}
    			if($cityst <> '-select-') {
    				$citypos = strlen($cityst)-5;
    				$st = substr($cityst,$citypos,2);
    				$city = substr($cityst,0,$citypos-3);
    				/*$city = 'Wilson';
    				$st = 'NC'; */
    				$winerys = $wpdb->get_results("SELECT * FROM Wineries WHERE City = '".$city."' AND State = '".$st."' ORDER By Name");
    			}
    			if($regionst <> '-select-') {
    				/*$citypos = strlen($regionst)-3;
    				$st = substr($regionst,$citypos,2);
    				$region = substr($regionst,0,$citypos-1);*/
    				$region = $regionst;
    				$st = 'NC';
    				$winerys = $wpdb->get_results("SELECT * FROM Wineries WHERE Region = '".$region."' AND State = '".$st."' ORDER By Name");
    			}'
    • This reply was modified 3 years, 7 months ago by bcworkz. Reason: code fixed

    Where is this PHP ran, what file? Are you sure that file is being used?

    Thread Starter sjlink39

    (@sjlink39)

    It is being run at the top of winery-results. Query Monitor plugin shows that both of the Select routines are being run with empty variables. I can change it to hardcoding the variables and the Piedmont(NC) region displays nicely.

    Are you calling this after wp_head() and/or get_header() has been called? Are you calling global $wpdb;

    Thread Starter sjlink39

    (@sjlink39)

    Yes, and global $wpdb is called in searchform.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘403 Error When Passing Parameters’ is closed to new replies.