Jump to content

Recommended Posts

I'm trying to create a pdf from a form where the user selects a machine_id and that pulls out a pdf based on the variable being passed. I'm pretty sure it is the query where i am doing something wrong. Can someone help. Much appreciated.

<?php
require('mysql_table.php');
$q=$_GET["q"];

class PDF extends PDF_MySQL_Table
{
function Header()
{
//Title
$this->SetFont('Arial','',18);
$this->Cell(0,6,'Machine Details',0,1,'C');
$this->Ln(10);
//Ensure table header is output
parent::Header();
}
}




//Connect to database
mysql_connect('localhost','bla','bla');
mysql_select_db('bla');

$pdf=new PDF();
$pdf->AddPage();
//First table: put all columns automatically
$this->Cell(0,6,'Repair History',0,1,'C');
$pdf->Table('SELECT * FROM repairs WHERE machine_number = $q');
$pdf->Output();

?>

 

Link to comment
https://forums.phpfreaks.com/topic/219471-sql-query/
Share on other sites

You've still forgotten to describe the problem.

 

Describe the problem.  Don't say "it doesn't work."  What doesn't work?  Does it email your grandmother?  Does it launch nuclear weapons?  Does it format your hard drive?

 

-Dan

 

PS - You cannot interpolate variables inside single quotes.  Had you debugged this and echoed the query, you would have seen '$q' instead of the contents of $_GET['q'].

Link to comment
https://forums.phpfreaks.com/topic/219471-sql-query/#findComment-1137977
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.