Search code examples
phphtmlsqlhref

Failed to open stream - XAMPP


I am having an issue.

  • OS - Windows 10
  • Developing Website on XAMPP v30204
  • Using PHP

Calling dynamic data from sql via link examples:

http://127.0.0.1/abbgi/category-page.php?category_id=73 - works, pulls all data from the SQL database and shows correctly via html in table.

http://127.0.0.1/abbgi/index.php?content=in-ground-basketball-goal-installation.php - works ( this is static content on a page withing main directory that shows correctly within the index.php content shell )

http://127.0.0.1/abbgi/index.php?content=category-page.php?category_id=88 - bad - ERROR:

Warning: include(category-page.php?category_id=88): failed to open stream: No such file or directory in C:\xampp\htdocs\abbgi\index.php on line 98

Warning: include(): Failed opening 'category-page.php?category_id=88' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\abbgi\index.php on line 98

Code on index.php:

<?php 
    if (!isset($_REQUEST['content']))
        include("home.php");                    
    else
    {
        $content = $_REQUEST['content'];
        $nextpage = $content;
        include($nextpage);
    }
?>

It seems that when the link includes index.php pulling data from sql that it breaks.


Solution

  • Use & to separate data instead of ?

    http://127.0.0.1/abbgi/index.php?content=category-page.php&category_id=88 
    

    You have used ? instead of & after content=category-page.php