I'm having a sort-of-related issue, and I thought the above would help me, because I had been using $HTTP_SESSION_VARS and session_register and unregister on PHP 4.2.2... I switched over to $SESSION, and things seem to run a little smoother, but...
I'm having trouble getting it to make one specific value persistent. I've currently got two session vars set up, a string and an int. I've got a session_start at the top of every page. It keeps the string fine, but the int seems to only be there intermittently - the rest of the time it's null, but isset returns true. All of this is in the global scope, not inside of a function. The same code did work at some point, but I can't see anything I've changed that could be causing this. Any ideas what's going on?
<?php
session_start();
require_once('neo.lib.php');
$s_uid = $_SESSION['NEO_UID'];
echo $s_uid . "; " . $_SESSION['NEO_UID'] . "; " . $_SESSION['NICK'] . "; ";
if (($_SESSION['NEO_UID'] = "") || (!isset($_SESSION['NEO_UID']))) {
header("Location: http://sandbox.neoporia.net/");
}
$tid = $HTTP_POST_VARS['tid'];
mysql_select_db($database_neodb, $neodb);
$insertSQL = sprintf("INSERT INTO message (`to`,`from`,`time`,`subject`,`body`,`type`) VALUES (%s,%s,%s,%s,%s,%s)",
GetSQLValueString($tid,"int"),
GetSQLValueString($_SESSION['NEO_UID'],"int"),
GetSQLValueString("NOW()","func"),
GetSQLValueString($HTTP_POST_VARS['subject'],"text"),
GetSQLValueString($HTTP_POST_VARS['body'],"text"),
GetSQLValueString("forum","text"));
echo $insertSQL . "; " . $_SESSION['NEO_UID'] . "; " . $s_uid . "; ";
$Result1 = mysql_query($insertSQL, $neodb) or die(mysql_error());
$pid = mysql_insert_id($neodb);
Neo_Log($HTTP_SERVER_VARS['REMOTE_ADDR'],$_SESSION['NEO_UID'],$HTTP_SERVER_VARS['HTTP_REFERER'],$PHP_SELF, "forum_post", "POST_REPLY," . $pid . "," . $tid);
$insertGoTo = "/thread_view.php?tid=" . $tid;
header(sprintf("Location: %s", $insertGoTo));
Gives this output:
1; 1; tremor; INSERT INTO message (to,from,time,subject,body,type) VALUES (2,NULL,NOW(),'test','test','forum'); ; 1; Column 'from' cannot be null
If I retry it, I get:
; ; tremor; INSERT INTO message (to,from,time,subject,body,type) VALUES (2,NULL,NOW(),'test','test','forum'); ; ; Column 'from' cannot be null
What am I doing wrong?