简体   繁体   中英

php urlencode htmlentities issue

I'm getting an error:

Warning: include(friday_set.php?x=First+Set&y=2): failed to open stream: No such file or directory in...

When I go to my url -> "friday_set.php?x=First+Set&y=2" everything comes out how it should

I understand the main reason is that I'm not properly encoding the url and the url can't quantify the & in the string

My code is this (which is similar to what is described in the php manual ):

<?php
 $sel_name = 'First Set';
 $admin_id = '2';

   $query_string = 'x=' . urlencode($sel_name) . "&y=" . urlencode($admin_id);
   include ("friday_set.php?" . htmlentities($query_string));
?>

I can't seem to spot the problem...anyone have a solution??

instead of parsing the vars in the file url i suggest this:

<?php
 $sel_name = 'First Set';
 $admin_id = '2';

   include ("friday_set.php");
?>

inside friday_set.php check for either $_GET[x] for direct url or $sel_name for include.

if(isset($_GET['x'])){
$sel_name=$_GET['x'];
}//else $sel_name  is just $sel_name unless you want to check its populated also

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM