Jump to content

sql query


Angelojoseph17

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.