Hostinger error, Strict Standards Only variables should be passed by reference - php

<section class="vbox">
<header class="bg-dark lt header navbar navbar-fixed-top-xs">
<?php $uri = end( explode("/",$_SERVER['REQUEST_URI'])); ?>
<div class="navbar-header bg-dark aside-md"> <a class="btn btn-link visible-xs" data-toggle="class:nav-off-screen,open" data-target="#nav,html"> <i class="fa fa-bars"></i> </a> <img src="./files/logo.png" class="m-r-xs">ResidenConce <a class="btn btn-link visible-xs" data-toggle="dropdown" data-target=".nav-user"> <i class="fa fa-cog"></i> </a> </div>
<ul class="nav navbar-nav navbar-right nav-user m-n hidden-xs">
<li class="hidden-xs"> <i class="fa fa-bell"></i>
<section class="dropdown-menu aside-xl">
<section class="panel bg-white">
<header class="panel-heading b-light bg-light"> <strong>Tienes <span class="count">0</span> notificaciones</strong> </header>
</section>
</section>
</li>
<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <span class="thumb-sm avatar pull-left"> <img src="./files/avatar.jpg"> </span> <?php if($_SESSION['logged_in']) { ?>
<?php echo $_SESSION['first_name']; ?> <b class="caret"></b> </a>
<ul class="dropdown-menu animated fadeInRight">
<span class="arrow top"></span>
<li> Ajustes </li>
<li class="divider"></li>
<li> Cerrar Sesión </li>
</ul>
</li>
</ul>
<?php } ?>
</header>
<section>
...
Gives me error in this line
<?php $uri = end( explode("/",$_SERVER['REQUEST_URI'])); ?>
In localhost it works, but in Hostinger it's the error
please any solution, thanks ind advance guys

end requires an array, not an expression resolved to array.
So:
<?php $uri = end( explode("/",$_SERVER['REQUEST_URI'])); ?>
should be:
<?php
$requestUriArray = explode("/",$_SERVER['REQUEST_URI'])
$uri = end($requestUriArray);
?>

end function has a parameter that passed by reference. So only need to use a variable to send this parameter:
$request_uri = explode("/",$_SERVER['REQUEST_URI']);
$uri = end($request_uri);

Related

How to create a link to a page in a WordPress theme

I am building a WordPress theme with two pages (home & contact) but when I click on the contact, it doesn't show me the page... Maybe there is a problem in my path defining how can I give it a right path
<li>
CONTACT
</li>
<nav class="topnavbar navbar-default topnav">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed toggle-costume" data-toggle="collapse" data-target="#upmenu" aria-expanded="false">
<span class="sr-only"> Toggle navigaion</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand logo" href="#"><img src="<?php bloginfo('template_directory');?>/image/logo1.png" alt="logo"></a>
</div>
</div>
<div class="collapse navbar-collapse" id="upmenu">
<ul class="nav navbar-nav" id="navbarontop">
<li class="active">HOME </li>
<li class="dropdown">
CATEGORIES <span class="caret"></span>
<ul class="dropdown-menu dropdowncostume">
<li>Sport</li>
<li>Old</li>
<li>New</li>
</ul>
</li>
<li class="dropdown">
DEALERS <span class="caret"></span>
<ul class="dropdown-menu dropdowncostume">
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</li>
<li>
CONTACT
</li>
<button><span class="postnewcar">POST NEW CAR</span></button>
</ul>
</div>
</nav>
</div>

Content added after PHP "included" files not positioning correctly

I'm using PHP's "include" function to display static elements on all my pages, but the end result is not displaying as it should.
index code:
<?php
require '../../views/sidebar.php';
require '../../views/navbar.php';
?>
<div class="card">
<div class="card-header">
Test
</div>
<div class="card-body">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">Home</li>
<li class="breadcrumb-item active" aria-current="page">Library</li>
</ol>
</nav>
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
Go somewhere
</div>
</div>
sidebar code:
<nav class="side-navbar">
<div class="side-navbar-wrapper">
<div class="sidenav-header d-flex align-items-center justify-content-center">
<div class="sidenav-header-inner text-center"><img src="../../views/img/logo.jpg" alt="menulogo" class="img-fluid rounded-circle">
<h2 class="h5">Test</h2><span>Dashboard</span>
</div>
<div class="sidenav-header-logo"> <strong>B</strong><strong class="text-primary">D</strong></div>
</div>
<div class="main-menu">
<h5 class="sidenav-heading">Main</h5>
<ul id="side-main-menu" class="side-menu list-unstyled">
<li> <i class="icon-home"></i>Home </li>
<li> <i class="icon-form"></i>Forms </li>
<li> <i class="fa fa-bar-chart"></i>Charts </li>
<li> <i class="icon-grid"></i>Tables </li>
<li> <i class="icon-interface-windows"></i>Example dropdown
<ul id="exampledropdownDropdown" class="collapse list-unstyled ">
<li>Page</li>
<li>Page</li>
<li>Page</li>
</ul>
</li>
<li> <i class="icon-interface-windows"></i>Login page</li>
<li> <a href="#"> <i class="icon-mail"></i>Demo
<div class="badge badge-warning">6 New</div></a></li>
</ul>
</div>
<div class="admin-menu">
<h5 class="sidenav-heading">Second menu</h5>
<ul id="side-admin-menu" class="side-menu list-unstyled">
<li> <i class="icon-screen"> </i>Demo</li>
<li> <a href="#"> <i class="icon-flask"> </i>Demo
<div class="badge badge-info">Special</div></a></li>
<li> <i class="icon-flask"> </i>Demo</li>
<li> <i class="icon-picture"> </i>Demo</li>
</ul>
</div>
</div>
</nav>
this is a snippet from a bootstrapious template I'm using for learning purposes, and the css is both bootstrap and the template's, untouched.

Link directory being doubled

I have directory like this "localhost/site/folder1/file.php", I need to access file.php from "site" directory this way
href = "folder1/file.php"
unfortunately it takes me to
href = "folder1/folder1/file.php"
and when I access "index.php" file located in "site" directory from "folder1", this way
href = "../index.php"
it takes me to root directory in c: I mean this way
href = "localhost/index.php".
I have stacked with this problem for two days now, please any one to help me get out this.
Note: I am using bootstrap framework
More edit...
here is the full code.
<section>
<section class="hbox stretch">
<!-- .aside -->
<aside class="bg-black dk nav-xs aside hidden-print" id="nav">
<section class="vbox">
<section class="w-f-md scrollable">
<div class="slim-scroll" data-height="auto" data-disable-fade-out="true" data-distance="0" data-size="10px" data-railOpacity="0.2">
<!-- nav -->
<nav class="nav-primary hidden-xs">
<ul class="nav bg clearfix" data-ride="collapse">
<!--<li class="hidden-nav-xs padder m-t m-b-sm text-xs text-muted">
Discover
</li>-->
<li>
<a href= "../index.php">
<i class="icon-home icon text-success"></i>
<span class="font-bold">Home</span>
</a>
</li>
<li>
<a href="#" class="auto">
<span class="pull-right text-muted">
<i class="fa fa-angle-left text"></i>
<i class="fa fa-angle-down text-active"></i>
</span>
<i class="icon-music-tone-alt icon text-info"></i>
<span class="font-bold">Audios</span>
</a>
<ul class="nav dk text-sm">
<li >
<a href="../general.php" class="auto">
<i class="fa fa-angle-right text-xs"></i>
<span>Speaches</span>
</a>
</li>
<li >
<a href="../general.php" class="auto">
<i class="fa fa-angle-right text-xs"></i>
<span>Preaches</span>
</a>
</li>
<li >
<a href="../general.php" class="auto">
<i class="fa fa-angle-right text-xs"></i>
<span>Interviews</span>
</a>
</li>
<li >
<a href="../general.php" class="auto">
<i class="fa fa-angle-right text-xs"></i>
<span>Songs</span>
</a>
</li>
</ul>
</li>
<li>
<a href="#" class="auto">
<span class="pull-right text-muted">
<i class="fa fa-angle-left text"></i>
<i class="fa fa-angle-down text-active"></i>
</span>
<i class="icon-book-open icon text-primary-lter"></i>
<span class="font-bold">Writtings</span>
</a>
<ul class="nav dk text-sm">
<li >
<a href="../general.php" class="auto">
<i class="fa fa-angle-right text-xs"></i>
<span>Books</span>
</a>
</li>
<li >
<a href="../general.php" class="auto">
<i class="fa fa-angle-right text-xs"></i>
<span>Jounals</span>
</a>
</li>
</ul>
</li>
<li>
<a href="#">
<i class="icon-users icon text-primary-lter"></i>
<span class="font-bold">Artists</span>
</a>
</li>
<li>
<a href="#">
<i class="icon-film icon text-info-dker"></i>
<span class="font-bold">Albums</span>
</a>
</li>
<li class="m-b hidden-nav-xs"></li>
</ul>
<ul class="nav" data-ride="collapse">
<li class="hidden-nav-xs padder m-t m-b-sm text-xs text-muted">
User Account
</li>
<li>
<?php
if(!isset ($_SESSION['email'])){
echo "
<a href='../signin.php' class='auto'>
<i class='icon-login icon'>
</i>
<span>Signin</span>
</a>
</li>
<li >
<a href='../signup.php' class='auto'>
<i class='fa fa-smile-o'>
</i>
<span>Signup</span>
</a>
</li>
";
}else{
echo "
<a href='../signout.php' class='auto'>
<i class='icon-logout icon'>
</i>
<span>SignOut</span>
</a>
</li>";
if (!isset($_SESSION['admin_name'])) {
echo "
<li >
<a href='profile.php' class='auto'>
<i class='fa fa-smile-o'>
</i>
<span>My profile</span>
</a>
</li>
";
}else{
echo "
<li >
<a href='MembersManagement.php' class='auto'>
<i class='fa fa-edit'>
</i>
<span>Manage Member</span>
</a>
</li>
<li >
<a href='admin.php' class='auto'>
<i class='fa fa-edit'>
</i>
<span>My Dashboard</span>
</a>
</li>
";
}
}
?>
</ul>
</nav>
<!-- / nav ---->
</div>
</section>
And the problem is on this line
<nav class="nav-primary hidden-xs">
When I remove "nav-primary" everything is doing fine with the anchors () but it changes the appearance and arrangements in the section, what should I do, I am new to bootstrap frameworks.
If you are having problem with relative urls, you can try doing with absolute urls like :
href = "localhost/site/folder1/file.php".
and for the other one you can do same:
href = "localhost/site/index.php
Maybe this helps.

How to retrieve the firstname from database using session

I want to display the firstname from database who login in my website - not the username of the user.
Here's a picture of my database so I already tried query but always complains about an undefined index
This is the navbar attendance only there's a another navbar too but I only example the attendance
navbar_attendance.php
<div class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><i class="icon-home icon-large"></i> Home</li>
<li><i class="icon-home icon-large"></i> Attendance Info</li>
<li><i class="icon-user icon-large"></i> Users</li>
<?php
include('dropdown.php');
?>
<li><i class="icon-book icon-large"></i> Books</li>
<li><i class="icon-group icon-large"></i> Member</li>
<li ><i class="icon-list-alt icon-large"></i> Archive</li>
<li><i class="icon-cog icon-large"></i> Utilities</li>
<li><i class="icon-signout icon-large"></i> Logout</li>
</ul>
<div class="pull-right">
<div class="admin">Welcome: <?php
if(isset($_SESSION['id'])){
// dont know what put in here
}
?></div>
</div>
</div>
</div>
</div>
</div>
<?php include('search_form.php'); ?>
session.php
<?php if(!isset($_SESSION)){
session_start();
} ?>
<?php
if (!isset($_SESSION['id']) || (trim($_SESSION['id']) == '')) {
?> <script>window.location='index.php';</script> <?php
exit();
}
$session_id=$_SESSION['id'];
?>
Hi you need to put this query at the place where you want to show the first name.
<?php if(!isset($_SESSION)){
session_start();
} ?>
<div class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><i class="icon-home icon-large"></i> Home</li>
<li><i class="icon-home icon-large"></i> Attendance Info</li>
<li><i class="icon-user icon-large"></i> Users</li>
<?php
include('dropdown.php');
?>
<li><i class="icon-book icon-large"></i> Books</li>
<li><i class="icon-group icon-large"></i> Member</li>
<li ><i class="icon-list-alt icon-large"></i> Archive</li>
<li><i class="icon-cog icon-large"></i> Utilities</li>
<li><i class="icon-signout icon-large"></i> Logout</li>
</ul>
<div class="pull-right">
<div class="admin">Welcome: <?php
if(isset($_SESSION['id'])){
$sql="SELECT firstname FROM TABLENAME WHERE user_id='$session_id'";
$result=mysqli_query($link,$sql);
if(mysqli_num_rows($result)>0)
{
while($row= mysqli_fetch_assoc($result)){
echo $row['firstname'];
}
}
}
?></div>
</div>
</div>
</div>
</div>
</div>
<?php include('search_form.php'); ?>`

Navbar won't collapse Bootstrap v4.0.0-alpha.5

I'm working on a site with php header & footer in the html version works like a charmin but in the php the navbar don't return.
Here is my code header:
<div class="container">
<div class="row">
<div class="col-sm-3">
<div id="logo" class="float-xs-left">
<a class="navbar-brand" href="xxxxxxx/"><img src="img/logo-white.png" /></a>
</div>
</div>
<!--div class="col-sm-6" -->
<div class="float-xs-right">
<!--/div> -->
<!--cols:12 -->
<!--cols:12 -->
<div class="offcanvas">
<div class="navbar yamm col-lg-8 col-md-8 col-sm-6 ">
<div class="navbar-header">
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target=".offcanvas.menu">
<i class="fa fa-bars"></i>
<div class="line line-1"></div>
<div class="line line-2"></div>
<div class="line line-3"></div>
</button>
</div>
<!-- outside -->
<div class="offcanvas menu right">
<div class="navbar-collapse collapse">
<button data-target=".offcanvas.menu" data-toggle="collapse" class="navbar-toggle" type="button">
</button>
<div class="nav navbar-nav">
<div class="list-group">
<!-- li><span class="home">⌂</span></li -->
<img class="logo-img" src="img/logo-full.png" class="img-responsive" />
INICIO
home <b class="fa fa-chevron-down"></b>
<div class="collapse" id="p5">
<a href="page-1.php" class="list-group-item">
Espresso </a>
<a href="page-2.php" class="list-group-item">
Clásico </a>
<a href="page-3.php" class="list-group-item">
Orgánico </a>
<a href="page-4.php" class="list-group-item">
Descafeinado </a>
<a href="page-5.php" class="list-group-item">
Toscana </a>
</div>
<b class="fa fa-chevron-down"></b>
<div class="collapse" id="p6">
<a href="page-11.php" class="list-group-item">
</a>
</div>
<b class="fa fa-chevron-down"></b>
<div class="collapse" id="p4">
<a href="page-13.php" class="list-group-item">
item </a>
<a href="#c1" class="list-group-item" data-toggle="collapse">
another one<b class="fa fa-chevron-down"></b> <span class="cat_url" onclick="location.href='other.php'"><i class="fa fa-mail-forward"></i></span> </a>
<div class="collapse" id="c1">
name
name
name
name
name
</div>
<a href="#" class="list-group-item">
other page </a>
<a href="#" class="list-group-item">
other page </a>
<a href="#" class="list-group-item">
other page </a>
<a href="page-15.php" class="list-group-item">
other name </a>
<a href="page.php" class="list-group-item">
name </a>
<a href="page.php" class="list-group-item">
name </a>
<a href="#" class="list-group-item">
name </a>
</div>
page title <b class="fa fa-chevron-down"></b>
<div class="collapse" id="p7">
<a href="page-16.php" class="list-group-item">
Name </a>
<a href="page-17.php" class="list-group-item">
name </a>
</div>
page
</div>
<br/>
</div>
</div>
</div>
<!-- /.navbar-collapse -->
</div>
<div class="pusher"></div>
<!-- end outside -->
</div>
</div>
</div>
<!--cols:12 -->
<div class="navbar yamm ">
<div class="navbar-header hidden-lg-up">
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-toggleable-md collapse">
<ul class="nav navbar-nav">
<!-- li><span class="home">⌂</span></li -->
<li class="nav-item ">
<a href="contacto.php" >Contáctanos</a>
</li>
<li class="nav-item ">
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
</div>
</div>
</div>
</header>
In the console get this error:
document.querySelector( "#nav-toggle" )
.addEventListener( "click", function() {
this.classList.toggle( "active" );
});
Does anybody know what the problem is and how I can fix it?
Solved
The issue was in the footer header and pages calling the same file so when the function is called the state doesn't return because repeat the action 3 times
Finally resolve the issue, there was a triple script sentence in the header, footer and index, was erased in the header and the footer and that's it.

Categories