implode(): Invalid arguments passed - laravel

This is my Controller code
if($university == "")
{
$university = "-";
}else if($university[0] == ""){
$university = "-";
}else if(isset($university[0])){
$university = implode(",",$university);
}else{
$university = $university;
}
How to pass argument in implode() ?

You passed implode argument is ok but your second argument is not an array.
if($university == "")
{
$university = "-";
}else if($university[0] == ""){
$university = "-";
}else if(isset($university[0])){
$university = implode(",",$university); //<-- This argument is not an array
}else{
$university = $university;
}

Related

Calling existing method to create new instances

Need direction on how to code for the three instances to then assign values to the variables using isWarmBlooded method ..
```Animal.prototype.isWarmBlooded = function(species){
if(this.species === "Fish"){
return this.species = false;
}
if(this.species === "Monkey" || this.species === "Bird"){
return this.species = true;
}
if(this.species !== "Fish" || this.species !== "Monkey" || this.species !== "Bird"){
return "Could not determine if warm-blooded";
}
};
//Call the isWarmBlooded method on three Animal instances
//and assign the values to each variable below.
var warmBloodedAnimal = Animal.prototype.isWarmBlooded("Monkey");
var coldBloodedAnimal;
var notWarmOrColdAnimal;```
var Animal = function (species){
this.species = species;
};
Animal.prototype.isWarmBlooded = function(species){
if (this.species === "Fish"){
return false;
}
else if(this.species === "Monkey" || this.species === "Bird"){
return true;
}
else{
return "Could not determine if warm-blooded";
}
};
var warmBloodedAnimal = new Animal("Monkey");
console.log(warmBloodedAnimal.isWarmBlooded());

fatal error call to undefined function

i've wrote this code,
<?php
class fizzbuzz{
function mod3($angka)
{
$a = $angka % 3;
if($a==0) return true;
else return false;
}
function mod5($angka)
{
$b = $angka % 5;
if($b==0) return true;
else return false;
}
function index(){
for ($i=1; $i < 101; $i++) {
if(mod3($i) == true && mod5($i) == true){
echo "fizzbuzz, ";
}else if(mod3($i) == true){
echo "fizz, ";
}else if(mod5($i) == true){
echo "buzz, ";
}else echo $i.", ";
}
}
}
$show = new fizzbuzz;
$show->index();
?>
and then it came up with this error
Fatal error: Call to undefined function mod3() in C:\xampp\htdocs\tes-bimasakti\fizzbuzz.php on line 19
please help me with this error..
You forgot $this->:
if($this->mod3($i) == true && $this->mod5($i) == true){
^^^^^^^--- here ^^^^^^^---here
without $this->, php is looking for a top-level global function. It will NOT look for a method in your object.
use this keyword
function index(){
for ($i=1; $i < 101; $i++) {
if($this->mod3($i) == true && $this->mod5($i) == true){
echo "fizzbuzz, ";
}else if($this->mod3($i) == true){
echo "fizz, ";
}else if($this->mod5($i) == true){
echo "buzz, ";
}else echo $i.", ";
}
}

if cell modified data on col1 by appscript?

I want,
If B1 edited/Not empty, put TimeStamp on A1. here is my script-
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Sheet1" ) { //checks that we're on the correct sheet
var r = s.getActiveCell();
if( r.getColumn() == 2 ) { //checks the column
var nextCell = s.getRange(r, 1);
if( nextCell.getValue() !== '' ) //is not empty
nextCell.setValue(new Date());
}
}
}
Problem is, getRange(r, 1) which should be getRange(r, -1) as colB=0, colC=1 colA=-1
But putting -1 is not working. How to fix that??
try this...
if(r.getColumn() == 2){
var prevCellValue = r.offset(0,-1).getValue;
if(prevCellValue() !== ''){
r.offset(0,-1).setValue(new Date());
}
}

PHP Page Session Error

I have a page with a session on it. When I access the page from another page within the same session it throws this error:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/cooperat/public_html/admin/applyforloan.php:4) in /home/cooperat/public_html/admin/applyforloan.php on line 7
Below is the code for the page:
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "appbye.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "101";
$MM_donotCheckaccess = "false";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "apploginfail.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"];
mysql_select_db($database_moneymanager, $moneymanager);
$query_members = "SELECT * FROM members";
$members = mysql_query($query_members, $moneymanager) or die(mysql_error());
$row_members = mysql_fetch_assoc($members);
$colname_members = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_members = $_SESSION['MM_Username'];
}
$username = $_SESSION['MM_Username'];
mysql_select_db($database_moneymanager, $moneymanager);
$query_members = sprintf("SELECT * FROM members WHERE username = %s", GetSQLValueString($colname_members, "text"));
$members = mysql_query($query_members, $moneymanager) or die(mysql_error());
$row_members = mysql_fetch_assoc($members);
$totalRows_members = mysql_num_rows($members);
mysql_select_db($database_moneymanager, $moneymanager);
$query_names = "SELECT First_name, last_name, memberid FROM members WHERE memberid != '2' AND username != '$username' ORDER BY memberid ASC";
$names = mysql_query($query_names, $moneymanager) or die(mysql_error());
$row_names = mysql_fetch_assoc($names);
$totalRows_names = mysql_num_rows($names);
$colname_loanername = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_loanername = $_SESSION['MM_Username'];
}
mysql_select_db($database_moneymanager, $moneymanager);
$query_loanername = sprintf("SELECT * FROM members WHERE username = %s", GetSQLValueString($colname_loanername, "text"));
$loanername = mysql_query($query_loanername, $moneymanager) or die(mysql_error());
$row_loanername = mysql_fetch_assoc($loanername);
$totalRows_loanername = mysql_num_rows($loanername);
mysql_select_db($database_moneymanager, $moneymanager);
$query_client = "SELECT * FROM customize";
$client = mysql_query($query_client, $moneymanager) or die(mysql_error());
$row_client = mysql_fetch_assoc($client);
$totalRows_client = mysql_num_rows($client);
$maxRows_contributions = 10;
$pageNum_contributions = 0;
if (isset($_GET['pageNum_contributions'])) {
$pageNum_contributions = $_GET['pageNum_contributions'];
}
$startRow_contributions = $pageNum_contributions * $maxRows_contributions;
$name = $_POST ['membername'];
$maxRows_contributions = 10;
$pageNum_contributions = 0;
if (isset($_GET['pageNum_contributions'])) {
$pageNum_contributions = $_GET['pageNum_contributions'];
}
$startRow_contributions = $pageNum_contributions * $maxRows_contributions;
$colname_contributions = "-1";
if (isset($_GET['year'])) {
$colname_contributions = $_GET['year'];
}
$colname2_contributions = "-1";
if (isset($_GET['memberid'])) {
$colname2_contributions = $_GET['memberid'];
}
$mid = $_POST['memberid'];
$year2 = $_POST['year2'];
$month2 = $_POST['month'];
$queryString_contributions = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_contributions") == false &&
stristr($param, "totalRows_contributions") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_contributions = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_contributions = sprintf("&totalRows_contributions=%d%s", $totalRows_contributions, $queryString_contributions);
$row = $startRow_contributions + 1;
?>
I am working with dreamweaver. Please what do you think has gone wrong?
It seems that you have started a session elsewhere make sure that session_start(); is called once on your page including the included php files.
I'm assuming that applyforloan.php is being included.

jQuery Validate plugin. How to check if any of fields is filled in

How to check if any of 4 fields I have is filled in? If any of them is filled in, then it's fine, if not, it's not.
$("#sendMsg").click(function(){
var name = $("#name").val();
var email = $("#email").val();
var subject = $("#subject").val();
var message = $("#message").val();
if(name == ""){
$("#errorMsg").show();
return false;
}
if(email == ""){
$("#errorMsg").show();
return false;
}
if(subject == ""){
$("#errorMsg2").show();
return false;
}
if(message == ""){
$("#errorMsg3").show();
return false;
}
});
if (document.getElementById("idfield1") === undefined)
{
// do noting
}
else
{
// do something
}

Resources