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
Related
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
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 6 years ago.
Improve this question
I am trying to create an image that changes dependent on the genre grabbed from an icecast server, I am pretty sure I have the base code correct I think I've just incorrectly inputted the PHP variable.
<?php
$stats = $core->radioInfo( "http://http://sc.onlyhabbo.net:8124/status-json.xsl" );
?>
<img src=http://www.habbo.com/habbo-imaging/avatarimage?user=<?php
echo $stats['genre'];
?>&action=std&direction=2&head_direction=2&gesture=sml&size=m&img_format=gif/>
is the full code. Have I inputted the PHP variable incorrectly
Where are the quotes in your Html?
<img src="http://www.habbo.com/habbo-imaging/avatarimage?user=<?php
echo $stats['genre'];
?>&action=std&direction=2&head_direction=2&gesture=sml&size=m&img_format=gif"/>
UPDATE EVERYBODY
This is now resolved, I decided to go down the CURL route for this, and at first it didn't work until my host raised our CloudLinux Process Limit. I am unsure what the actual issue with this code was, but the CURL route works fine. Thank you for any answers
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
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
?>
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().