0

hi I wrote php code

do.php

<?php session_start(); ob_start();
$salladim = $_SESSION['salla'];
$salladin =  isset($_GET['url'])?$_GET['url']:'' ;
 
if(!in_array($salladin,$salladim))
{
    header( 'refresh: 1; url='.$_SERVER['HTTP_REFERER'].'' );
echo '<h2>Hazirlaniyor...</h2>';
    exit();
}

file.php

<?php session_start();
function kodsalla($uzunluk) 
{
$karakterler = "0123456789"."ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$kod = "";
  while(strlen($kod) < $uzunluk) 
  {
    $kod .= substr($karakterler, (rand() % strlen($karakterler)), 1);
  }
  return($kod);
}
$kodsalla = kodsalla(8);

$_SESSION['salla'][] = $kodsalla;

When i run this code, i get the following error :

PHP Warning:  in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in /home/site/public_html/do.php on line 5
3
Contributors
25
Replies
26
Views
6 Years
Discussion Span
Last Post by twiss
1

Its probably because $salladim is not an array (it is set to $_SESSION which might not be an array).

What is $_SESSION set to?

0

$kodsalla; should take the value of $salla

var_dump($_SESSION['salla']);
array(1) {
  [0]=>
  string(8) "4AZWX25C"
}

Edited by codetr: n/a

0

Where did you put this var_dump? In file.php or do.php?

file.php

0

woooow realy big error firefox locked

they appeared on the screen I tried to open the file

PK?>B4h%xd;abKs?r]/أlplLŁ`Ai:rqrrJ:F.7߇u:;tya))7FWz^ <dJ}r;<:g]a3d]%lrtQ5̜nJ-vK+LTkSsiEF8Z,صUj<K&E^c~]2&h06Obߌtq$WoLZ~Z96[bg

url line this

do.php?url=UPXG8UUM

EDIT:

this error from the setting ansi character.. fixed this utf8 without dom. but second-click on the link downloading do.php file not run this refresh function

if(!in_array($salladin,$salladim))
{
header( 'refresh: 1; url='.$_SERVER['HTTP_REFERER'].'' );
echo '<h2>Hazirlaniyor...</h2>';
exit();

Edited by codetr: n/a

0

do.php

<?php session_start(); ob_start();
var_dump($_SESSION['salla']);
$salladim = $_SESSION['salla'];
$salladin =  isset($_GET['url'])?$_GET['url']:'' ;

tray this code but second-click on the link downloading do.php refresh page null line seems

now also gives this error
wrong datatype for second argument in /home/public_html/do.php on line 6

Edited by codetr: n/a

0

yes so <a target="_blank" href="file.php?filename=a.zip">Download a file</a>

0

file.php

<?php session_start();
function kodsalla($uzunluk) 
{
$karakterler = "0123456789"."ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$kod = "";
  while(strlen($kod) < $uzunluk) 
  {
    $kod .= substr($karakterler, (rand() % strlen($karakterler)), 1);
  }
  return($kod);
}
$kodsalla = kodsalla(8);

$_SESSION['salla'][] = $kodsalla;
?>
0

Ah. Perhaps you'd like to include 'do.php'; ?

If not, where is do.php called? Perhaps you could provide a bit more information on what your logic is and how you thought it would work.

0

Which line add including in file.php

Edited by codetr: n/a

0

Well, you tell me, it's your program. But if you want to have it executed 'after' file.php, you could just put it at the end - before line 15.

0

file.php in

include 'do.php';

did not work, refresh the warning came into the loop... yes my script.. simple download php script... but I'm not very good at taking help people learn new..

Edited by codetr: n/a

0

Can't you just replace $salladim with $kodsalla in do.php?

worked :icon_razz: thank you but second click link refresh not work.. waiting for a long time, then coming down the 0 byte file named do.php

0

Be a bit more clear about what you want to happen, how you tried to do that, and what happened instead. I'm not going to write an entire application for you.

0

Be a bit more clear about what you want to happen, how you tried to do that, and what happened instead. I'm not going to write an entire application for you.

of course, my aim is just to learn and get help. I was wrong actually resolved the problem .. I thought the problem was solved within the cache read php I get the same error again

Edited by codetr: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.