0
mysql_connect('localhost','root','');
mysql_select_db('db_enrollment');

<?php
require('fpdf.php');

class PDF extends FPDF
{
// Page header
function Header()
{
// Logo
//$this->Image('logo.jpg',22,10,160);
// Arial bold 15
$this->SetFont('Arial','B',15);
// Move to the right
$this->Cell(80);

// Line break
$this->Ln(20);

}

$result=mysql_query("select * from omr_result");




// Page footer
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);

}
}

$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->Output();



?>

i have a code to export mysql table as a pdf but there is a error in line 24

4
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by diafol
0

@biddut.hossain.75

i have a code to export mysql table as a pdf but there is a error in line 24

Read this

http://php.net/manual/en/function.mysql-query.php

mysql_query() function doesn't work anymore you need to used either

mysqli_query()
PDO::query()

Try to used this function:

From this:

$result=mysql_query("select * from omr_result");

To this:

$result=mysqli_query("select * from omr_result");

Test the query to see whether you are connected to the database.

0

Your problem is on this line:

$result=mysql_query("select * from omr_result");

You cannot declare, or, set variables inside the class this way. You shoud consider trying to implement this inside a function:

public function query()
{
    $connect = mysql_query("SELECT * FROM something");

}
0
mysql_connect('localhost','root','');
mysql_select_db('db_enrollment');
<?php
require('fpdf.php');

should be

<?php
mysql_connect('localhost','root','');
mysql_select_db('db_enrollment');
require('fpdf.php');

mysql_* can't be used if you don't have a connection. Your code shows mysql_connect and mysql_select_db outside the php tags.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.