0

When I try to print variable "$ime", it just prints "Student: " on pdf file. I have tested it on html and it works fine displaying whole thing as is should. Sql result is not empty and it's just one row that displays name and last name. So normal output should be "Student: John Doe"

// Page header
    function Header()
    {
       $db2 = new dbObj();
    $connString2 =  $db2->getConnstring();

    mysqli_set_charset($connString2,'UTF-8');

    $aaa = mysqli_query($connString2, "SELECT s.ime,s.prezime FROM Student s WHERE s.mbr='".$mbr."'") or die("database error:". mysqli_error($connString2));


    $row=mysqli_fetch_row($aaa);

    $ime ="Student: ".$row[0]." ".$row[1];

        // Logo
        $this->Image('img/logo.png', 85, 15, 30, '', 'PNG', '', 'T', false, 300, 'C', false, false, 0, false, false, false);
        $this->SetFont('Arial','B',13);

        // Move to the right
        $this->Cell(80);
        // Title
        $this->SetFont('Arial','B',15);
        $this->Cell(20,80,'Lista polozenih ispita',0,0,'C');
        $this->Ln(10);

        $this->Cell(80);
        $this->SetFont('Arial','B',10);
        $this->Cell(20,80,$ime,0,0,'C');
        // Line break
        $this->Ln(50);
    }

Edit: It's not about variable scoping I have tried but it doesn't affect it in any way.

Kakarot
  • 43
  • 8
  • 1
    where does `$mbr` come from? –  May 20 '19 at 23:59
  • 1
    Possible duplicate of [Reference: What is variable scope, which variables are accessible from where and what are "undefined variable" errors?](https://stackoverflow.com/questions/16959576/reference-what-is-variable-scope-which-variables-are-accessible-from-where-and) –  May 21 '19 at 00:00
  • @tim $mbr is a number that comes from html field, as I have said I tried it on html page and it works fine, even without pdf output variable $ime works just fine with echo – Kakarot May 21 '19 at 00:40
  • 1
    its not defined in the function scope, so that's why it does not work –  May 21 '19 at 00:42
  • Are you certain `$row[]` is populated? – tshimkus May 21 '19 at 00:43
  • @tim are you talking about $mbr? cuz the other stuff I have on $mbr works just fine in another table, also $mbr is global variable – Kakarot May 21 '19 at 00:45
  • @tshimkus one hundred percent sure – Kakarot May 21 '19 at 00:46
  • it's not global in this function. –  May 21 '19 at 00:46
  • @tim it works now I thought I could just use it from other global which was above all functions, might as well mark this question as duplicate like before. – Kakarot May 21 '19 at 00:55

0 Answers0