Jump to content

Recommended Posts

Hi Guys,

 

So first time beginner coder and I have been doing a lot of tutorials. I tend to be the kinda person to Google stuff before I post and I really couldnt find help with my issue. So first, my code (Please disregard the comments in the code as its for my own use later so I know what I did)

 

 

session_start(); // Deals with login sections

$path = dirname(__FILE__); // Is the entire path up on this script

include("{$path}/register.inc.php");
include("{$path}/login.inc.php");

mysql_connect ("localhost","root","");
mysql_select_db ("coding");

//Scrint name is path from root directory. anything after .com of a site Explode function takes a character and it breaks up a string to decide where space is. - 4 means it takes off .php to give you init.inc for logging in
$page_name = substr(end(explode("/", $_SERVER['SCRIPT_NAME'])), 0, -4);

 

So when I run the above, on my page I get Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\coding\inc\init.inc.php on line 24

 

 

I am following this tutorialand it happens around 13:10 in the video.

 

Really appreciate any help here as its driving me up the walls.

 

Thanks in advance

Edited by richanderson
Link to comment
https://forums.phpfreaks.com/topic/274610-strict-standards/
Share on other sites

http://www.php.net/manual/en/function.end.php

 

See how end expects a variable passed by reference?

 

I personally haven't encountered this but I wonder if doing it this way will resolve the error:

$arr = explode("/", $_SERVER['SCRIPT_NAME']);
$page_name = substr(end($arr), 0, -4);

 

Edit: Actually I'm 99% sure that would fix it.

"The array. This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference." From the manual.

Edited by Jessica
Link to comment
https://forums.phpfreaks.com/topic/274610-strict-standards/#findComment-1413045
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.