Jump to content


Photo

Update AP2.0 & PHP5.2 issues to AP2.2 & PHP5.4


  • Please log in to reply
6 replies to this topic

#1 jvrothjr

jvrothjr

    Advanced Member

  • Members
  • PipPipPip
  • 297 posts
  • LocationOhio

Posted 04 February 2013 - 04:29 PM

I have been asked to update are software we are running I have been able to get the new versions update running but am having issues with SESSION_REGISTER

and declaring session variables. can someone just point me in the right direction. I have seem sessions_reg goes away in php 5.6 so any help to switch now would be great.
If you understand everything you know nothing!

http://rcchjr.awardspace.com/

#2 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 04 February 2013 - 04:34 PM

As you noticed session_register () is indeed deprecated, but the solution is quite easy. Just save the values to the $_SESSION superglobal instead, and it will automatically be saved to the session file by the PHP parser.
As shown in the PHP manual.

Example:
// Assuming we have this variable.
$username = "test";

// Instead of this.
session_register ("username");

// Do this.
$_SESSION['username'] = $username;

Keeping it simple.

#3 jvrothjr

jvrothjr

    Advanced Member

  • Members
  • PipPipPip
  • 297 posts
  • LocationOhio

Posted 05 February 2013 - 08:40 AM

so replace


if (substr($_SERVER['HTTP_REFERER'],-10) <> "header.php") {$_SESSION[referer] = $_SERVER['HTTP_REFERER'];}

with


if (substr($_SERVER['HTTP_REFERER'],-10) <> "header.php") {
$referer = $_SERVER['HTTP_REFERER'];
$_SESSION[referer] = $referer;
}
If you understand everything you know nothing!

http://rcchjr.awardspace.com/

#4 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 05 February 2013 - 08:48 AM

You don't need the interim $referer variable there, just set it directly from $_SERVER['HTTP_HEADER']. So the first line is indeed correct.

You also need to have quotes around the index in the $_SESSION array, otherwise PHP will think that you're attempting to use a constant and not a string.
As a little nit-picking, you should be using != to test for inequality. As that's what's expected. I know that <> works in MySQL, but not sure if it does in PHP (never tested).
Keeping it simple.

#5 jvrothjr

jvrothjr

    Advanced Member

  • Members
  • PipPipPip
  • 297 posts
  • LocationOhio

Posted 05 February 2013 - 09:09 AM

ok used but still getting error


if (substr($_SERVER['HTTP_REFERER'],-10) != "header.php") {$_SESSION[referer] = $_SERVER['HTTP_REFERER'];}


Notice: Use of undefined constant referer - assumed 'referer' in C:\wamp\apps\testrequest\includes\pconvar.inc on line 2
If you understand everything you know nothing!

http://rcchjr.awardspace.com/

#6 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 05 February 2013 - 09:12 AM

See the first sentence of the second paragraph in my last post.
Keeping it simple.

#7 jvrothjr

jvrothjr

    Advanced Member

  • Members
  • PipPipPip
  • 297 posts
  • LocationOhio

Posted 05 February 2013 - 09:17 AM

fixed it right after I posted sorry

Next issue

Notice: Undefined index: cmd in C:\wamp\apps\testrequest\index.php on line 253

switch($_REQUEST['cmd']){
If you understand everything you know nothing!

http://rcchjr.awardspace.com/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com