0

I'm creating a signup page, when I add required fields to establish database connections in the beginning of the body of my signup page(splash.php) i encounter a 404 error upon page loading on localhost when I open a preview window in Adobe Dreamweaver. I additionally encounter these 2 errors when manually opening splash.php through the url bar: 1. Warning: require_once(/start/db.php): failed to open stream: 2. Fatal error: require_once(): Failed opening required '/start/db.php' (include_path='.;C:\php\pear')

I've looked into the folders containing the files, those 2 php files seem to open fine and are present in the "start" folder. I cannot figure out why requiring these files causes a 404 error & the other 2.

Here is the beginning html doc for splash.php: the 2 require_once codes are causing the problem.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link rel="stylesheet" href="/ink/post_creation.css">
</head>

<body>
<?php require_once("/start/db.php"); ?>
<?php require_once("/start/signup.php"); ?>

Here is the beginning of the database:

<!doctype html>
<?php
$dbhost = 'localhost';
$dbname = 'start';
$dbuser = 'xxxxx';
$dbpass = 'xxxxx';
$connection = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if ($connection->connect_error) die("Fatal Error");

And beginning of signup.php:

<!doctype html>
<?php
if (isset($_POST['signup'])) 
{
require_once('/start/db.php');
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['pwd'];

I'd hoped it would simply load the page, any help would be fantastic!

akemedis
  • 414
  • 2
  • 6
  • 17
  • if you can list how your files are stored it would be easier to check – fmsthird Apr 11 '19 at 04:35
  • 2
    The path you have mentioned is wrong. /start/db.php => Corresponds to the root folder /start, which is not the case. If you have this file in the current working directory, you can simply do, `require_once "db.php";` Or, provide correct path. – Naveen Kumar Apr 11 '19 at 04:35
  • so its: ampps>www>start, all the files are contained in the start folder, but i believe the root folder is specified as www. The correct path i would have thought was /start/db.php because www is the root folder – akemedis Apr 11 '19 at 04:47
  • 1
    require_once will try to include the given file in the given /start/ path (where /start is at the same level as /root). If the file isn't found there, it will check the _include_path_ env variable. If your current script is in the same directory as db.php, you can simply specify, `require_once 'db.php';` – Naveen Kumar Apr 11 '19 at 05:04
  • Oh i understand now! Thankyou! :) – akemedis Apr 11 '19 at 05:15

0 Answers0