Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 计数($\u会话)始终返回0_Php_Session - Fatal编程技术网

Php 计数($\u会话)始终返回0

Php 计数($\u会话)始终返回0,php,session,Php,Session,我写了这个剧本: <html> <head> <link rel="stylesheet" type="text/css" href="../../css/stile.css"> </head> <body> <?php include_once("../../classi/funzioni.php"); include_once("../../classi/config.php"); include_once("../../

我写了这个剧本:

<html>
<head>
<link rel="stylesheet" type="text/css" href="../../css/stile.css"> 
</head>
<body>

<?php
include_once("../../classi/funzioni.php");
include_once("../../classi/config.php");
include_once("../../classi/auth.lib.php");

session_start(); //Inizio la sessione

list($status, $user) = auth_get_status();

if($status == AUTH_LOGGED && $user['nome_negozio']=="Black Fashion"){

echo "<h1>ORDINE DA CLIENTE</h1>";

$prodotto="SELECT * FROM elenco_movimenti WHERE cliente='".$user['nome_negozio']."'";//query
echo "<br><b>QUERY</b><br>";    
echo $prodotto; 

$prodotto=$db_magazzino->query($prodotto);
$prodotto=$prodotto->fetch_row(); 

$i=count($_SESSION);    
$_SESSION[$i]=$prodotto; 
}

?>

<form name="form1" method="post" action="./ordine_da_cliente.php">
<label for="barcode"><b>Codice a barre</b></label>
<input type="text" name="barcode" >
<input type="submit" name="submit" value="OK">
</form>

</body>
</html> 

你的问题是:

<html>
<head>
<link rel="stylesheet" type="text/css" href="../../css/stile.css"> 
</head>
<body>

<?php
include_once("../../classi/funzioni.php");
include_once("../../classi/config.php");
include_once("../../classi/auth.lib.php");

session_start(); //Inizio la sessione
正如你所知,它说:

注意: 要使用基于cookie的会话,必须在将任何内容输出到浏览器之前调用会话_start()

我发现了错误:

如果我删除以下行:

include_once("../../classi/funzioni.php");    
include_once("../../classi/config.php");    
include_once("../../classi/auth.lib.php");    
config.php页面包含以下行:
error\u reporting(E\u ALL&~E\u NOTICE)//0 E_ALL

然后我看到这个通知:
注意:未知:跳过第0行未知中的数字键1

那么如果我写这个:
$\u SESSION['ordine.''1']=“你好吗?”

它保存会话。我不太喜欢这种方法,但现在它能用了

无论如何,谢谢你的支持


亲切问候。

第一次,如果您没有为
$\u会话
变量设置任何内容,则计数为0。在那之后,应该是1,在那之后是2,等等。。。在
session\u start()
之后插入
var\u dump($\u session)
进行检查,您是否已填充
$\u session
是的,它始终仅填充一个元素,并且计数始终为0。您写道:“我编写了此函数:”您是指脚本。你是否在表格所在的页面上开始会话?那么,
$user['nome_negozio']
来自哪里?你能编辑你的帖子,如果不是太大的话,给我看整个脚本吗?为什么不使用关联数组。。这看起来令人困惑不,它仍然不起作用:(还有其他方法吗?PS如果我从服务器中的另一个页面(在同一文件夹中)执行var_dump($_会话),它将显示0个元素(如果我将$_会话[0]=“lorem ipsium”;…为什么???其他页面(具有$_会话变量)该站点的任何部分都能正常工作。@RiparazioneComputerMestreDa在发送任何输出之前,您真的在使用
会话\u start()
吗?即使是
之前的一个空格,我确认。没有来自@RiparazioneComputerMestreDa的任何空格不,不是来自

include_once("../../classi/funzioni.php");    
include_once("../../classi/config.php");    
include_once("../../classi/auth.lib.php");