Undefined variable in FPDF. help me. mysqli - pdf

why Notice: Undefined variable: datanya?
can you fixed? this is my code:
how do i fix it.
require("fpdf.php");
$konek=mysqli_connect("localhost","root","","rollab");
$kode=$_GET['kode'];
$query=mysqli_query($konek,"select*from wp_jadwal where id_jadwal='.$kode.'");
$datanya =mysqli_fetch_assoc($query);
class myPDF extends FPDF{
function headerPro(){
$this->Ln(13);
$this->Cell(40,5,$datanya["tanggalpemutaran"],0,0,'L');
$this->Ln();
}
}

You should check out this FAQ of FPDF. It's for the default Header/Footer methods but it's the same issue:
5. I try to display a variable in the Header method but nothing prints.
You have to use the global keyword to access global variables, for example:
function Header()
{
global $title;
$this->SetFont('Arial', 'B', 15);
$this->Cell(0, 10, $title, 1, 1, 'C');
}
$title = 'My title';
Alternatively, you can use an object property:
function Header()
{
$this->SetFont('Arial', 'B', 15);
$this->Cell(0, 10, $this->title, 1, 1, 'C');
}
$pdf->title = 'My title';

Related

Kotlin/JS Invalid property id when adding cursor pointer style to span

Here is the code:
h.span {
css {
cursor = Cursor.pointer
}
+"∄"
...
}
When compiled, it produces the following error:
> Task :browser:processDceKotlinJs FAILED
error: at /.../build/js/packages/kjs-browser/kotlin/kjs-browser.js (1193, 185): invalid property id
Examining the location of the error, we see it's at the $receiver_0.cursor line, below, and it indicates the entry default (at position 185):
function RecordList$lambda$lambda$lambda$lambda$lambda$lambda$lambda(closure$id, closure$updateList) {
return function ($receiver) {
var $receiver_0 = {};
$receiver_0.cursor = (/*union*/{alias: 'alias', allScroll: 'all-scroll', cell: 'cell', colResize: 'col-resize', contextMenu: 'context-menu', copy: 'copy', crosshair: 'crosshair', default: 'default', eResize: 'e-resize', ewResize: 'ew-resize', grab: 'grab', grabbing: 'grabbing', help: 'help', move: 'move', nResize: 'n-resize', neResize: 'ne-resize', neswResize: 'nesw-resize', noDrop: 'no-drop', notAllowed: 'not-allowed', nsResize: 'ns-resize', nwResize: 'nw-resize', nwseResize: 'nwse-resize', pointer: 'pointer', progress: 'progress', rowResize: 'row-resize', sResize: 's-resize', seResize: 'se-resize', swResize: 'sw-resize', text: 'text', verticalText: 'vertical-text', wResize: 'w-resize', wait: 'wait', zoomIn: 'zoom-in', zoomOut: 'zoom-out'}/*union*/).pointer;
$receiver.className = css($receiver_0);
$receiver.unaryPlus_pdl1vz$('\u2204');
$receiver.onClick = preventDefault(RecordList$lambda$lambda$lambda$lambda$lambda$lambda$lambda$lambda(closure$id, closure$updateList));
return Unit;
};
}
By removing the css block that sets the pointer style, the error disappears.
As an interesting side note, the code runs just fine in development mode (browserDevelopmentRun).

NameError, variable is undefined

Today I'm start to learn Less and use this site https://lesstester.com/ to compile , and when I trying type this piece of code I have an error:
#var = "Some text";
#var1 = "var";
div:before {
content: ##var1;
}
It might be replaced #var1 to #var, but not working. What I do wrong?
The variables in Less should be assigned using ::
#var: "Some text";
#var1: "var";
div:before {
content: ##var1;
}
More info: http://lesscss.org/#variables

fix footer image in tcpdf

$path = Yii::app()->basePath;
require_once($path . '/extensions/tcpdf/tcpdf.php');
$pdf = new TCPDF();
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(true);
$pdf->SetAutoPageBreak(TRUE, 0);
$pdf->AddPage();
$pdf->SetLineWidth(0.1);
$pdf->SetFont('times', '', 10);
$pdf->SetMargins(20, 20, 20, true);
$footer_image_file = Yii::app()->request->baseUrl.'/images/logo.jpg';
$content = '<div> $content </div>';
$pdf->writeHTML($content, true, false, true, false, '');
ob_end_clean();
$pdf->Output("Reports.pdf", "D");
I want to add image in fooder for every new pages.. please anyone help me...
Simply put the code displaying the image within the Footer() base method. This base method is called for any new page by either the AddPage() method and Close().
Important : The Footer method should not be called directly.
This method is supposed to be implemented in your class, so override it like this :
function Footer()
{
.... /* Put your code here (see a working example below) */
$logoX = 186; // 186mm. The logo will be displayed on the right side close to the border of the page
$logoFileName = "/images/myLogo.jpg";
$logoWidth = 15; // 15mm
$logo = $this->PageNo() . ' | '. $this->Image($logoFileName, $logoX, $this->GetY()+2, $logoWidth);
$this->SetX($this->w - $this->documentRightMargin - $logoWidth); // documentRightMargin = 18
$this->Cell(10,10, $logo, 0, 0, 'R');
}
I hope this helps and I've well understood your question.
function Footer()
{
.... /* Put your code here (see a working example below) */
$logoX = 40; //
$logoFileName = "/images/myLogo.jpg";
$logoWidth = 130; // 15mm
$logoY = 280;
$logo = $this->PageNo() . ' | '. $this->Image($logoFileName, $logoX, $logoY, $logoWidth);
$this->SetX($this->w - $this->documentRightMargin - $logoWidth); // documentRightMargin = 18
$this->Cell(10,10, $logo, 0, 0, 'C');
}
This codes are perfectly placed a image in the center of page footer.Thanks a lot pti_jul.:-)))))

FPDI New line after ... characters

I'm creating an FPDI PDF. This is what I do now:
libraries_load('fpdi');
$pdf = new FPDI();
$path = drupal_get_path('theme', 'xmed') . '/docs/verkocht_template.pdf';
$pdf->setSourceFile(realpath($path));
$tplIdx = $pdf->importPage(1, '/MediaBox');
$pdf->addPage();
$pdf->useTemplate($tplIdx, 0, 0, 210);
$path = drupal_get_path('theme', 'xmed') . '/fonts/lato.php';
$pdf->AddFont('lato-light-webfont','','lato-light-webfont.php');
$pdf->SetFont('lato-light-webfont', '', 14);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetXY(47, 71);
$pdf->Write(0, $name);
I'm also placing some other variables on my PDF. This is the result now:
But as you can see the $name variable is to long... . I've tried this:
$naam = wordwrap($naam, 20);
But that gave me this result:
What would be the best solution to fix this?
Simply use MultiCell() instead of Write(). It allows you to define a width (1st parameter) on which the text will be wrapped automatically.

How to make GUI Button activate script (JS or C#) in Unity3d

I really need your help to make my GUI.Button start a JS script (or C#) attached to a GameObject. Here is what I have in my application. A JS script "doRotate.js", that does a rotation on a GameObject.
The rotation starts if the value of "public var doRotation = false" is chanced to "true" by click in the Inspector
#pragma strict
public var doRotation = false;
function Update()
{
if (doRotation)
{
transform.Rotate(new Vector3(0, 50, 0) * Time.deltaTime);
}
}
I also have a JS script that renders some GUI.buttons. I want button 2, once pressed to call (run) the "doRotate.js" script, meaning accessing the boolean "doRotation" and chance its value to "true", as if it is done in the Inspector.
Following is what I've tried so far, but I get this error "Error BCE0020: An instance of type 'doRotate' is required to access non static member 'doRotation'. (BCE0020)".
Here is the code on the GUI.button:
var native_width : float = 480;
var native_height : float = 320;
var addImage : Texture2D;
var btnTexture1 : Texture;
var btnTexture2 : Texture;
function OnGUI ()
{
var rx : float = Screen.width / native_width;
var ry : float = Screen.height / native_height;
GUI.matrix = Matrix4x4.TRS (Vector3(0, 0, 0), Quaternion.identity, Vector3 (rx, ry, 1));
GUI.Box( Rect(20, 200, 429, 129) ,addImage, "");
if (!btnTexture1) {
Debug.LogError("Please assign a texture on the inspector");
return;
}
GUI.Button(Rect(54, 222, 52, 35), btnTexture1);
if (!btnTexture2) {
Debug.LogError("Please assign a texture on the inspector");
return;
}
if(GUI.Button(Rect(118, 222, 52, 35), btnTexture2));
var runScript : GameObject[] =
GameObject.FindGameObjectsWithTag("markerObject");
for(var doRotation : GameObject in runScript) {
var script : doRotate = doRotation.GetComponent(doRotate);
if(script)
doRotate.doRotation(); //Error BCE0020: An instance of type 'doRotate' is required to access non static member 'doRotation'. (BCE0020)
}
What have I done wrong? I've trying for days,to make it work without success. How can I access this variable on the click of the GUI.Button?
Can someone, please help me out?
This error occurs because you are trying to access a nonstatic member of "doRotate" with a class, not with an instance of it.
In this following code:
var script : doRotate = doRotation.GetComponent(doRotate);
if(script)
doRotate.doRotation(); //Error BCE0020: An instance of type 'doRotais required to access non static member 'doRotation'. (BCE0020)
You are setting the instance of doRotate to var script, this var stores a reference of doRotate instance, with this you can access the var "doRotation" and change his value.
Something like this:
var script : doRotate = doRotation.GetComponent(doRotate);
if(script)
script.doRotation = true;