PHP - Require not loading page [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
When I try to require a file into my HTML, my web page isn't loading anymore.
The file I want to require is empty so it isn't a scripting error.
require_once('required/dbClass.php');
session_start();
$_SESSION['user'] = 'Test User';
$testing=true;
This code above is working just fine and my page is loading as it is supposed to.
But when I try the next code, my page isn't loading anymore
require 'config.php';
require_once('required/dbClass.php');
session_start();
$_SESSION['user'] = 'Test User';
$testing=true;
I don't know what's wrong, I've tried getting an error with error_reporting(E_ALL); but that doesn't display anything.
Did I do something wrong?

Config.php was in a different directory

Related

PHP script breaking rest of HTML document [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
EDIT: SOLVED - Thanks to the comment by #Adam
I have my index.php page, which all included functionality, until now, has worked.
I've written a small script (pasted below), using the Simple HTML DOM library to scrape an external webpage for an element value. This value is stored as $newprice inside the script.
However, when I place the script anywhere in the code, it a) doesn't run, and b) breaks all HTML/PHP/JS code preceding it.
<?php
include_once('../simple_html_dom.php');
$html = file_get_html('https://www.affordrentacar.co.uk/');
$traverse = $html->find('span.offer-price', 0);
$newprice = $traverse->plaintext;
?>
I've copied this script to one of my other PHP pages and tested echoing out the $newprice variable and that works fine. What could be causing this?
try to display errors :
error_reporting( E_ALL^E_NOTICE );
ini_set('display_errors', 1);
can be problem with connections, your local settings don't work with https

session_start() blocks page load [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I have a problem with the function session_start(); as it blocks file execution (i.e page loads forever) to even after PHP Max execution time, i thought it was a problem with my code however i cleared all my files and just used this simple script to test and it didn't work
<?php
session_start();
$_SESSION['name'] = "foo";
$name = $_SESSION['name'];
echo "My name is $name";
I'm using WAMP server version 3.0.6 64bit, Apache 2.4.23 - PHP 5.6.25 - MySQL 5.7.14
if you are using file sessions you will need to close writing to the session to prevent multiple PHP requests (that need $_SESSION data) from blocking.
example:
<?php
// start the session
session_start();
// I can read/write to session
$_SESSION['latestRequestTime'] = time();
// close the session
session_write_close();
// now do my long-running code.
more about the solution

Error message on my New Blog Post page which I cannot work out [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am in the process of incorporating a Blog Posts section in my website.
However I am receiving an error message on the New Post page which I am unsure of the cause of.
Any help would be greatly appreciated.
I have received the above two Warning Error messages above.
I have also covered parts of the directory because they show names.
This is what the code looks like at the line specified.
<?php
include "cms/posts.php";
?>
Line 155 is the middle line of code.
If there is any more information which is required please let me know.
Thanks!
Reply to comment 1: Hi, I'm not sure why it is trying to open that file as I've never seen or heard of the file "usr/lib/php:/usr/local/lib/php".
Use this code and make sure the file exists:
<?php
include __DIR__ . "/cms/posts.php"; // PHP >= 5.3
include dirname(__FILE__) . "/cms/posts.php"; // PHP < 5.3
?>

Header always redirect: [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
When admin log in to the admin panel it should redirect him to the admin panel and the second time to not, but it always redirecting.
if($logedin_admin='1'){
$logedin_admin=0;
$_SESSION['is_admin']=1;
header('Location: admin/index.php');
}
Can anyone tell me why?
I've made the if:
if(isset($logedin_admin) && $logedin_admin=='1'){
echo 'dsdasdas';
$logedin_admin=0;
$_SESSION['is_admin']=1;
header('Location: admin/index.php');
exit;
}
but it isn't redirecting and it isn't echoing dsdasdas
It should be if($logedin_admin=='1'){
You are doing an assignment operation instead of a comparison..
Also, make sure if the session was started...
The code..
<?php
session_start(); //<=--------- Add this
if($logedin_admin=='1'){
$logedin_admin=0;
$_SESSION['is_admin']=1;
header('Location: admin/index.php');
exit; //<=----------- Add an exit too.
}

PHP - start_session undefined [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I've been using session_start() fine with my other PHP files. Now however, I am trying to put functions into one file and then be able to call them from various other PHP files.
I simply have this in one file:
<?php require("CustomerFunctions.php");
start_session();
PrintCustomerTable();
?>
However I am getting Fatal error: Call to undefined function start_session()
Again, I am able to use start_session everywhere else in my files but now for some reason it won't work in this file. It has the same result even if I remove the require.
The function you're looking for is called session_start().

Categories