-1

Guys i read all the questions asked in site but there is no answer for me, please forgive me to ask new question. I need to fetch mysqli db. I did it but it has 18k rows and i'm using each row in a bot. It takes so long time and i took error for execution time. I need to do this in short time. Here is my solution for this problem but it didnt work any.

<?php
    include "baglan2.php";

    $q   = mysqli_query($baglanti, "SELECT bolumlink FROM bolumler WHERE  id=?");
    $row = mysqli_fetch_assoc($q);
    $r   = $row['bolumlink'];

    for($a=1; $a<=count($r); $a++){
        for($b=1; $b<=count($r); $b+300) {
            $statement = $baglanti->prepare($query);
            $statement->bind_param("i", $id);
            $statement->execute(); 
            $statement->bind_result($bolumlink);
            $statement->fetch();

            $link_array($a) = array(); 

            if ($query) { 
                while ($row = mysqli_fetch_assoc($query)) { 
                    $link_array($a)[] = $row['bolumlink'];
                }
            }
        }
        $statement->close();
    }
?>

this codes receipt is:

Fatal error: Can't use function return value in write context in C:\xampp\htdocs\xampp\dizipub\playerbaglan.php on line 15

i tried to delete ($a) on link_array s then it gives error:

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\xampp\dizipub\playerbaglan.php on line 5

Notice: Undefined variable: link_array1 in C:\xampp\htdocs\xampp\dizipub\playerlinkler.php on line 8

Warning: file_get_contents(): Filename cannot be empty in C:\xampp\htdocs\xampp\dizipub\playerlinkler.php on line 8

<html>
<p><font face=Arial color=Black size=2>
<?php
    include "baglan.php";
    include "playerbaglan.php";

    $parcala = '@<iframe width="100%" height="300" src="(.*?)" frameborder="0"    allowfullscreen></iframe></span></div><div id="2">@si';
    $bot2ara = file_get_contents($link_array1);

    preg_match_all($parcala,$bot2ara,$playerlar); 

    for($a=0; $a<count($playerlar[0]); $a++) {
        foreach (array($playerlar[0][$a]) as $playerlar2);
            $playerlar3 = explode('"', $playerlar2,-5);
            echo "<pre/>"; print_r($playerlar3[5]);
        }
    }
?>
</font></p>
</html>

i'm trying to explode link_array cause file_get_contents cant work with 18k rows. I tried to share this 18k rows to 60 variables by using $a and for. but every method i tried is not working. I tried making 60 php for 60 variable also but it didnt work too and it is kind of a stupidity :)

Please help me guys :)

Community
  • 1
  • 1
Tarık Baysal
  • 41
  • 1
  • 5
  • A tip for your sake, try to write your code with order and readability – phaberest Oct 11 '16 at 19:00
  • 1
    See http://stackoverflow.com/questions/3888376/cant-use-function-return-value-in-write-context-error-in-php – Jon Oct 11 '16 at 19:01
  • @phaberest thanks. monly00 that post is a bit hard to understand for me as a newbie in php :) im trying that to undersand thanks :) – Tarık Baysal Oct 11 '16 at 19:47

1 Answers1

-1

It appears to be a typo.

Your $link_array uses parenthesis instead of square brackets.

I'd suggest you to initialize it as an empty array before the for loops.

include "baglan2.php";

$q   = mysqli_query($baglanti, "SELECT bolumlink FROM bolumler WHERE  id=?");
$row = mysqli_fetch_assoc($q);
$r   = $row['bolumlink'];

$link_array = [];

for ($a=1; $a<=count($r); $a++) {
    for ($b=1; $b<=count($r); $b+300) {
        $statement = $baglanti->prepare($query);
        $statement->bind_param("i", $id);
        $statement->execute(); 
        $statement->bind_result($bolumlink);
        $statement->fetch();

        $link_array[$a] = array(); 

        if ($query) { 
            while ($row = mysqli_fetch_assoc($query)) { 
                $link_array[$a][] = $row['bolumlink'];
            }
        }
    }
    $statement->close();
}

Beware, also, that $link_array1 does not exist. Maybe you meant $link_array[1]?

phaberest
  • 3,140
  • 3
  • 32
  • 40
  • could you delete my last two comments i cant do it ? i cant edit my comments so i did it three times sorry :) but this problem didnt solved my problem that is: Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\xampp\dizipub\playerbaglan.php on line 5 there is no boolean on mysqli_fetch_assoc but receive this error ? – Tarık Baysal Oct 11 '16 at 19:52
  • You should check what is returning from your `$q` with a `die(var_dump($q))` just after its line. Beware that you are using a question mark in your query, but it's not a prepare statement so it is probably what causes the issue. – phaberest Oct 11 '16 at 20:01