4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 20, 2018, 03:03:53 PM

Login with username, password and session length
Search:     Advanced search
You're looking for some 4images templates and styles? Then visit this thread to show websites with 4images templates to download.
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  General / Allgemeines
| |-+  Programming
| | |-+  trim() expects parameter 1 to be string, array given in
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
This topic has not yet been rated!
Author Topic: trim() expects parameter 1 to be string, array given in  (Read 3527 times)
.Infecto
Newbie
*
Offline Offline

Posts: 48

Thank You
-Given: 10
-Receive: 0


View Profile
« on: April 20, 2015, 12:50:22 AM »

Hallo zusammen,

ich habe folgenden Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# --- Variabeln Initialisieren --> 'register_globals' -------------------- #
if ((bool) @ini_get('register_globals')) {
    
$superglobals = array($_ENV$_GET$_POST$_COOKIE$_FILES$_SERVER);
   
    if (isset(
$_SESSION)) {
        
array_unshift($superglobals$_SESSION);
    }
   
    
$knownglobals = array(
    
# --> Bekannte Superglobals und reservierte Variabeln
    
'_ENV',     'HTTP_ENV_VARS',
    
'_GET',     'HTTP_GET_VARS',
    
'_POST',    'HTTP_POST_VARS',
    
'_COOKIE',  'HTTP_COOKIE_VARS',
    
'_FILES',   'HTTP_FILES_VARS',
    
'_SERVER',  'HTTP_SERVER_VARS',
    
'_SESSION''HTTP_SESSION_VARS',
    
'_REQUEST',
   
    
# --> Variabeln, die hier verwendet werden
    
'superglobals',
    
'knownglobals',
    
'superglobal',
    
'global',
    
'void'
    
);
   
    foreach (
$superglobals as $superglobal) {
       
        foreach (
$superglobal as $global => $void) {
           
            if (!
in_array($global$knownglobals)) {
               
                unset(
$GLOBALS[$global]);
            }
        }
    }
}


#####################################

function check_mg_vars($val)
{
    if (isset(
$val))
    {
        
$val trim($val);
        
$val strip_tags(htmlspecialchars($val));
        return 
$val;
    }
}

######################################

foreach ($_GET as $key => $element) {    ${$key} = check_mg_vars($element); }
foreach (
$_POST as $key => $element) {    ${$key} = check_mg_vars($element); }

#####################################

So kann ich Übergaben einfach ausgeben wie z.B

1
echo $upl_titel.'<br />';

Jetzt habe ich eine Mehrfachauswahl eingeügt:

  <div class="section">
  <label class="field select-multiple">
  <select name="upl_language[]" id="upl_language" multiple>
  <option value="DE">Deutsch</option>
  <option value="EN">Englisch </option>
  <option value="FR">Französisch</option>
  <option value="SP">Spanisch</option>
  <option value="CH">Chinesisch</option>
  <option value="JP">Japanisch</option>
  <option value="MULTi-2">MULTi-2</option>
  <option value="MULTi-3">MULTi-3</option>
  <option value="MULTi-4">MULTi-4</option>
  <option value="MULTi-5">MULTi-5</option>
  <option value="MULTi-6">MULTi-6</option>
  <option value="MULTi-7">MULTi-7</option>
  <option value="MULTi-8">MULTi-8</option>
  <option value="MULTi-9">MULTi-9</option>
  <option value="MULTi-10">MULTi-10</option>
  <option value="MULTi-11">MULTi-11</option>
  <option value="MULTi-12">MULTi-12</option>
  <option value="MULTi-13">MULTi-13</option>
  <option value="MULTi-14">MULTi-14</option>
  <option value="MULTi-15">MULTi-15</option>
  <option value="MULTi-16">MULTi-16</option>
  <option value="MULTi-17">MULTi-17</option>
  <option value="MULTi-18">MULTi-18</option>
  <option value="MULTi-19">MULTi-19</option>
  <option value="MULTi-20">MULTi-20</option>
  <option value="MULTi-21">MULTi-21</option>
  <option value="MULTi-22">MULTi-2</option>
  <option value="MULTi-23">MULTi-23</option>
  <option value="MULTi-24">MULTi-24</option>
  <option value="MULTi-25">MULTi-25</option>
  </select>   
  </label>   
  </div><!-- end  section -->

1
echo $upl_language;

Wenn ich nun das Formular abschicke, bekomme ich folgende Fehlermeldung:
Quote  [Expand]
trim() expects parameter 1 to be string, array given in

Wie kann ich das umgehen?
Gibt es da einen Trick?
Logged
Rembrandt
4images Moderator
4images Guru
*****
Offline Offline

Posts: 4187

Thank You
-Given: 116
-Receive: 899

Vienna


View Profile WWW
« Reply #1 on: April 20, 2015, 05:17:28 AM »

Hi!

Steh eigentlich eh schon in der Fehlermeldung, du übergibst ein Array ,"Trim" kann aber nur auf einen "String" angewendet werden.

http://php.net/manual/de/function.trim.php

mfg Andi
Logged

Meine 4Images Modifikationen  Now over 100 Modification Online!    Meine 4images Demo Seite


Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.038 seconds with 19 queries.