Fatal error: Uncaught ArgumentCountError: Too few arguments to function galleryClass::listGallery() [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 16 hours ago.
Improve this question
Fatal error: Uncaught ArgumentCountError: Too few arguments to
function galleryClass::listGallery(), 0 passed in
D:\xampp\htdocs\gallery\manage\listGallery.php on line 5 and exactly 1
expected in D:\xampp\htdocs\gallery\manage\gallery\galleryClass.php:16
Stack trace:#0 D:\xampp\htdocs\gallery\manage\listGallery.php(5):
galleryClass->listGallery()#1 {main} thrown in
D:\xampp\htdocs\gallery\manage\gallery\galleryClass.php on line 16
What could be wrong here? I looked through the forum threads with similar titles but the solutions given in them don't fit here. Below I insert the files mentioned in the log.
listGallery.php
<?php
include_once './inc/header.php';
include_once './gallery/galleryClass.php';
$galleryClass=new galleryClass();
$listAlbum=$galleryClass->listGallery();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../../../favicon.ico">
<title>Justified Nav Template for Bootstrap</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
<link href="https://getbootstrap.com/docs/4.0/examples/justified-nav/justified-nav.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="masthead">
<br/>
<h3 class="text-muted">List Album</h3>
<br/>
<?php include_once './inc/navbar.php'; ?>
</div>
<!-- Example row of columns -->
<div class="col-md-6">
<table class="table table-bordered table-striped">
<thead>
<tr><th>Id</th><th>Name</th></tr>
</thead>
<tbody>
<?php
if(count($listAlbum)){
foreach ($listAlbum as $value) {
echo "<tr><td><img src='../galleryImage/$value[ImageName]' width='50px' height='50px'></td><td>$value[AlbumId]</td></tr>";
}
}
?>
</tbody>
</table>
</div>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="../../../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="http://getbootstrap.com/assets/js/vendor/popper.min.js"></script>
<script src="http://getbootstrap.com/dist/js/bootstrap.min.js"></script>
</body>
</html>
galleryClass.php
<?php
require_once ( dirname( __FILE__). '/../functions/connectionClass.php' );
class galleryClass extends connectionClass{
public function uploadGallery($image){
$insert="Insert into gallery (ImageName) values ('$image')";
$result=$this->query($insert);
if($result){
echo "File is uploaded";
}
else
{
echo "File is not uploaded";
}
}
public function listGallery($query){
$select="select * from gallery $query";
$result=$this->query($select);
$count=$result->num_rows;
if($count< 1){
}
else
{
while ($row = $result->fetch_array()) {
$rows[]=$row;
}
return $rows;
}
}
public function addAlbum($name){
$insert="Insert into album (AlbumName) values ('$name')";
$result=$this->query($insert);
if($result){
echo "Album created";
}
else
{
echo "Album not created";
}
}
public function listAlbum(){
$select="select * from album";
$result=$this->query($select);
$count=$result->num_rows;
if($count< 1){
}
else
{
while ($row = $result->fetch_array()) {
$rows[]=$row;
}
return $rows;
}
}
}

Related

Retrieving and displaying logged in info in PHP

I'm trying to retrieve my logged in user data to no avail. Please check my
enter code here private function getUserData($user_name)
{
// if database connection opened
if ($this->databaseConnection()) {
// database query, getting all the info of the selected user
$query_user = $this->db_connection->prepare("SELECT * FROM users WHERE user_name='$_SESSION['user_name']'");
$query_user->bindValue(':user_name', $user_name, PDO::PARAM_STR);
$query_user->execute();
// get result row (as an object)
return $query_user->fetchObject();
} else {
return false;
}
}
Got the way to move about it ,Thanks #ADyson for the response and follow up
code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>YOUR ORDER , We will contact you in a few !!!!</title>
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/css/main.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<?php include 'header.php'; ?>
<section>
<div class="container">
<strong class="title">MY ORDERS</strong>
</div>
<div class="profile-box box-left">
<?php
require('db.php');
// SQL query
$strSQL = "SELECT user_name, phone, firstname, lastname, service, referal,user_registration_datetime FROM users WHERE user_name = '".$_SESSION['user_name']."'";
// Execute the query (the recordset $rs contains the result)
$rs = mysqli_query($myConnection, $strSQL);
// Loop the recordset $rs
// Each row will be made into an array ($row) using mysqli_fetch_array
while($row = mysqli_fetch_array($rs)) {
echo WORDING_PROFILE_PICTURE . '<br/>' . $login->user_gravatar_image_tag;
echo "<div class='info'> <strong>NAME:</strong> <span>".$row['firstname'].", ".$row['lastname']."</span></div>";
echo "<div class='info'><strong>phone No:</strong> <span>".$row['phone']."</span></div>";
echo "<div class='info'><strong>SERVICE:</strong> <span>".$row['service']."</span></div>";
echo "<div class='info'><strong>REFERAL:</strong> <span>".$row['referal']."</span></div>";
echo "<div class='info'><strong>DATE QUERIED:</strong> <span>".$row['user_registration_datetime']."</span></div>";
}
// Close the database connection
mysqli_close($myConnection);
?>
<div class="options">
<a class="btn btn-primary" href="editprofile.php">Edit Profile</a>
<a class="btn btn-success" href="changepassword.php">Change Password</a>
</div>
</div>
</section>
<script src="assets/js/jquery-3.1.1.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>

Warning: Cannot modify header information Cant Fix [duplicate]

This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 5 years ago.
I've already looked at a ton of fixes for this I've tried deleting whitespace but there was none, I've tried using the ob_start(); function but to no avail. Whatever I do it gives me this error.
Warning: Cannot modify header information - headers already sent by
(output started at /home/gener105/public_html/header.php:37) in /home/gener105/public_html/includes/vault_post.inc.php on line 12
It says the output starts on the last line of my header.php file(Fig1) and it has a problem with me calling header(); in the function I need to use. This is because of me using the header(); function on line 12 in vault_post.inc.php(Fig2).
I'm just confused on why its doing this because theres no outputs before the the header is called.
FIG1 (header.php)
<?php
session_start();
include 'includes/dbh.php';
include 'includes/vault_post.inc.php';
date_default_timezone_set('America/New_York');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Generation Diary - Leave Them Something For Later</title>
<!-- Bootstrap Core CSS -->
<link href="lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="lib/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Cabin:700" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">
<!-- Theme CSS -->
<link href="css/grayscale.min.css" rel="stylesheet">
<!-- Temporary navbar container fix until Bootstrap 4 is patched -->
<style>
.navbar-toggler {
z-index: 1;
}
#media (max-width: 576px) {
nav > .container {
width: 100%;
}
}
</style>
</head>
FIG2 (vault_post.inc.php) The first function thats needed in the file
<?php
function setVaultPosts($conn) {
if (isset($_POST['vault_sub'])) {
$uid = $_POST['uid'];
$date = $_POST['date'];
$content = $_POST['content'];
$sql = "INSERT INTO vaults (uid, date0, content) VALUES ('$uid', '$date', '$content')";
$result = mysqli_query($conn, $sql);
header("Location: http://www.generationdiary.com/user_vault.php?success");
}
}
FORM THAT NEEDS THE FUNCTION
<?php include('header.php'); ?>
<div class="container" id="vault_main">
<div class="row row-offcanvas row-offcanvas-right">
<div class="col-12 col-md-9">
<p class="float-right hidden-md-up">
<button type="button" class="btn btn-primary btn-sm" data-toggle="offcanvas">Toggle nav</button>
</p>
<div class="jumbotron">
<h1 class="text-center">
<?php
if (isset($_SESSION['username'])) {
echo $_SESSION['firstname'] . " " . $_SESSION['lastname'] . "'s";
} else {
echo "You are not logged in";
}
?>
</h1>
<h2 class="text-center">Vault</h2> </div>
<?php
if (isset($_SESSION['username'])) {
echo "
<form action='".setVaultPosts($conn)."' method='POST'>
<input type='hidden' name='uid' value='".$_SESSION['username']."'>
<input type='hidden' name='date' value='".date(' Y-m-d ')."'>
<textarea class='ckeditor' name='content'></textarea>
<br>
<button class='btn btn-default btn-lg' type='submit' name='vault_sub'>Submit</button>
";
getVaultPosts($conn);
} else {
echo "log in";
}
?>
</div>
<div class="col-6 col-md-3 sidebar-offcanvas" id="sidebar">
<div class="fixed">
<div class="list-group"> Vault Recipient Settings Account Settings Log Out </div>
</div>
</div>
</div>
</div>
<?php include('footer.php'); ?>
This is entirely obvious. And your code is entirely flawed and this is probably because you are using HTML form submission for the first time.
Your header.php includes HTML text which is sent out immediately. So you want to call your Header() function, you need to make sure nothing is sent out before hand. You are having your session_start() on the first line of your code, this is correct and you need to make sure that this function is the first line of code in any PHP script processing that is using it. You need to be careful that no header info is sent before this function is called.
HTMl form's action attribute is the url path, not the PHP function.
<form action='form_process.php'>. You set the path here the same way you set link's href (relative or absolute path). Your form_process.php will then receive a $_POST global variable for you to handle your form data received. http://php.net/manual/en/reserved.variables.post.php

HTML doesn't load after PHP opening tag

Right now I'm coding this really simple user page but getting one problem that's bugging me and can't find out why it's happening.
When ever I would put <?php HTML will just stop loading from there.
<?php
session_start();
if (!isset($_SESSION["user"])) {
$logged_in = "no";
} else {
$username = $_SESSION["user"];
$logged_in = "yes";
}
include ('global.php');
?>
<head>
<title><?php echo $sitename; ?></title>
<link rel="stylesheet" type="text/css" href="css.css">
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="header">
<div class="header_content">
<div class="middle_logo">
<p><?php echo $sitename; ?></p>
</div>
</div>
</div>
<div class="under_header">
<?php
$id = htmlentites($_GET["id"]);
$get_user_data = mysqli_query ($dconnect, "SELECT * FROM user_data WHERE id='$id'");
if (mysqli_num_rows($get_user_data) < 2) {
header ("Location: index.php");
} else {
while ($row = mysqli_fetch_array($get_user_data)) {
echo $row["username"];
}
}
?>
<h1><?php echo $users_name; ?></h1>
</div>
When I look at the source code it ends at <div class="under_header">
The answer has already been found in the comment :
The line :
$id = htmlentites($_GET["id"]);
Contain an error and should be :
$id = htmlentities($_GET["id"]);
Thanks to #RiggsFolly and #JustOnUnderMillions.
You can now accept an answer and close the question.

Unexpected T_CONSTANT_ENCAPSED_STRING Error in PHP/MySQL

So I'm trying to run a query in PHP and while the query has no errors itself (or so it seems), the editor sees an error in an "echo" statement. The code is this:
<?php
include("include/session.php");
?>
<?php
$db = new PDO('mysql:host=localhost;dbname=cvtool;charset=utf8', 'user', 'pass'); // change these to your own database details
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // later, change ERRMODE_WARNING to ERRMODE_EXCEPTION so users wont see any errors
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$department = isset($_GET['department'])? $_GET['department']: null;
$sql = 'SELECT *
FROM education
WHERE school LIKE ?;
$q = $conn->prepare($sql);
$q->execute(array('%$department%');
$q->setFetchMode(PDO::FETCH_ASSOC);
while ($r = $q->fetch()) {
echo sprintf('%$department', $r['school']);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!--The viewport tag is used in order to scale the page properly inside any screen size -->
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>CV Tool</title>
<link rel="shortcut icon" href="images/favicon.ico" />
<link rel="stylesheet" href="css/main.css"/>
<!--Import JQuery from stored file -->
<script src="js/jquery-1.11.1.min.js"></script>
<!--Import JQuery from Google's Content Delivery Network -->
<!--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">-->
<link href='http://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="js/menu.js"></script>
<script type="text/javascript" src="js/backToTop.js"></script>
</head>
<body>
<!--Big wrapper contains the whole site (header,navigation menu,....,footer-->
<div id="big_wrapper">
<header id="top_header">
<img src="images/cvlogo.png">
</header>
<br>
<nav class="clearfix">
<ul class="clearfix">
<li>Home</li>
<?php
/**
* User has already logged in, so display relavent links, including
* a link to the admin center if the user is an administrator.
*/
if($session->logged_in){
echo "<li>Search</li>"
."<li>My CV(s)</li>"
."<li>My Account</li>"
;
echo "<li>Logout</li>";
}
else
?>
</ul>
Menu
</nav>
<section id="main_section">
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Department</th>
</tr>
</thead>
<tbody>
<?php while ($r = $q->fetch()): ?>
<tr>
<td><?php echo htmlspecialchars($r['school'])?></td>
</tr>
<?php endwhile; ?>
</section>
<footer id="the_footer">
City CV Tool 2014
</footer>
</div>
</body>
</html>
The problem is that no matter how I change it, it still gives me an error. The error is at these specific lines:
while ($r = $q->fetch()) {
echo sprintf('%$department', $r['school']);
}
The error might be just something missing or something extra that I put without realizing it. I know the code is about a very specific case, but still any help is appreciated.
You never close the following string variable :
$sql = 'SELECT *
FROM education
WHERE school LIKE ?;

How to fix:Parse error: syntax error, unexpected ',' in /home/monkeybu/public_html/index.php on line 2 [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Can some one help me fix this?
Parse error: syntax error, unexpected ',' in /home/monkeybu/public_html/index.php on line 2
I am using x10hosting for my host.
Here's my code:
<?php
require_once "lib/steam-condenser.php",
require_once "config.php";
$id = $_GET['sid'];
$getData = SteamId::create($id);
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/main.css" type="text/css" media="screen">
<link rel="stylesheet" href="css/jquery.maximage.css" type="text/css" media="screen" title="CSS" charset="utf-8" />
<script type="text/javascript" src="js/progressbar.js"></script>
</head>
<body>
<section id="downloadInfo">
<div id="progressBarText"><span id="fileName">filename.vmt </span><span id="downloadPresent"><b>0%</b></span></div>
<div id="progressBar"><div></div> </div>
</section>
<section id="playerInfo" style="margin-left: 15%;">
<?php
echo '
<img src="'.$getData->getFullAvatarUrl().'" width="299">
<ul>
<li style="width: 70%;"><h1 id="serverName">serverName</h1></li>
<li style="width: 60%;"><h2>'.$getData->getNickname().'<span class="steamid">['.SteamId::convertCommunityIdToSteamId($id).']</span></h2></li>
<li style="width: 50%;"><h3 id="mapName">mapName</h3></li>
</ul>';
?>
</section>
<?php
if($loadingScreen['backgroundMusic'] != "")
{
$ytLink = explode("v=", $loadingScreen['backgroundMusic']);
echo '<iframe width="1" height="1" src="//www.youtube.com/embed/'.$ytLink[1].'?autoplay=1" frameborder="0" style="opacity: 0;"></iframe>';
}
?>
<div id="maximage">
<?php
$imgDir = scandir("images/backgrounds/");
$picNum = 0;
foreach($imgDir as &$files)
{
$picNum++;
if($picNum >= 3)
{
echo "<img src='images/backgrounds/".$files."' alt='' width='1400' height='1050' />\n";
}
}
?>
</div>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.js'></script>
<script src="js/jquery.cycle.all.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.maximage.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(function(){
jQuery('#maximage').maximage();
});
function GameDetails( servername, serverurl, mapname, maxplayers, steamid, gamemode )
{
document.getElementById("serverName").innerHTML = servername;
document.getElementById("mapName").innerHTML = mapname;
}
function SetFilesTotal( total ) {
var totalFiles = total;
}
function SetFilesNeeded( needed ) {
var filesLeft = needed;
var present = (totalFiles / filesLeft);
document.getElementById("downloadPresent").innerHTML = present + "%";
progressBar(Math.round(present), $('#progressBar'));
}
function DownloadingFile( fileName ) {
document.getElementById("fileName").innerHTML = fileName;
}
</script>
<footer>
</footer>
</body>
</html>
config:
<?php
$loadingScreen['backgroundMusic'] = "http://www.youtube.com/watch?v=0UjsXo9l6I8"; //Only youtube links.. (for now). (if you dont want to play music leave it blank)
?>
steam:
<?php
/**
* This code is free software; you can redistribute it and/or modify it under
* the terms of the new BSD License.
*
* Copyright (c) 2010-2013, Sebastian Staudt
*
* #author Sebastian Staudt
* #license http://www.opensource.org/licenses/bsd-license.php New BSD License
* #package steam-condenser
*/
define('STEAM_CONDENSER_PATH', dirname(__FILE__) . '/');
define('STEAM_CONDENSER_VERSION', '1.3.6');
require_once STEAM_CONDENSER_PATH . 'steam/community/SteamId.php';
This line:
require_once "lib/steam-condenser.php",
//- ^ should be a semi-colon
should have a semi-colon and not a comma
require_once "lib/steam-condenser.php";
Dagon, sorry I saw your comment after I posted this.

Categories