broj1 356 Humble servant Featured Poster

See explanation in comments:

$common_words = array("van", "der", "de");

// initialize an array for removed words
$removedWords = array();

// save string to array
$achternaamArray = explode(' ', $achternaam);

// cycle through the array
foreach($achternaamArray as $key => $namePart) {

    // check if current word is in common words array
    // or is empty string (after trimming)
    if(in_array($namePart, $common_words) || trim($namePart) == '') {

        // if yes, add it to the removed words array
        // and remove it from the main array
        $removedWords[] = $namePart; 
        unset($achternaamArray[$key]);    
    }
}

// now you have only unremoved words in the $achternaamArray
// implode it to string (and capitalize first letter)
echo  ucfirst(implode(' ', $achternaamArray)) . '<br>';

// display the removed words
echo 'Removed words: ' . implode(', ', $removedWords);
broj1 356 Humble servant Featured Poster

Try with curl and see this article if it helps.

broj1 356 Humble servant Featured Poster

The $achternaam variable contains spaces before the actual name and the first space gets capitalized by ucfirst function. Use trim to get rid of the spaces:

echo ucfirst( strtolower( trim($achternaam) ) );
broj1 356 Humble servant Featured Poster

OK. Please mark this thread as solved.

broj1 356 Humble servant Featured Poster

Is the total field declared as NOT NULL in your table? If it has to have a value you have to make sure the value exists in the query.

You can also check the query if you insert this temporary debug code on line 8:

die($insertSQL);

This will display the constructed query and stop the script. You can examine the query or copy it to phpmyadmin and test it there.

broj1 356 Humble servant Featured Poster

If I got it right your script works fine on local PC but does not work when on online server? But what does not work - inserting into the database or redirection to another page?

If insertion does not work you have to make sure the connection to the database on the online server has been successfuly established. You are checking for errors already on line 9 but I will suggest you insert some debug code like this:

mysql_select_db($database_marketbase, $marketbase);
// *** DEBUG CODE 1
$res = mysql_query("SHOW TABLES");
while($row = mysql_fetch_row($res)) {
    echo $row[0] . "<br>";
}
// *** the above debug code should display all the tables in your database
// *** if not, something is wrong with the connection

If redirection does not work you should check the path you get generated. Do something like this between lines 15 and 16:

// *** DEBUG CODE 2
die($insertGoTo);
// *** the above code will print out the path for redirection and stop the script
// *** check the path if it is correct

header(sprintf("Location: %s", $insertGoTo));
broj1 356 Humble servant Featured Poster

This topic has been already marked as solved but I would like to add useful information that deserves to be added, and this is OWASP top 10 list of vulnerabilities of web apps and guides on how to minimize them. It might be a slightly more complex reading but it is worth it if you do a serious web development.

broj1 356 Humble servant Featured Poster

Do you want to start a war? <= [just kiddin]

Seriously, this is a question you won't get a definite answer to. I think both are good. PHP for me is better since I know it :-) (or at least I think I do). As far as I know PHP has more installations worldwide. An not to forget, PHP is open source.

broj1 356 Humble servant Featured Poster

You declared $pass variable but used $password in the query. And also you should check for existence of the data sent from the form and only if it exist query the database.

In additon to that you should use quotes when queryinig for strings.

And in addition to that you should clean the strings before sending them to the database to avoid injection attacks. So:

if(isset($_POST['email']) && isset($_POST['password'])) {
    $email = mysql_real_escape_string($_POST['email']);
    $password = mysql_real_escape_string($_POST['password']);

    ...

    $result = mysql_query("SELECT id FROM users WHERE email = '$email' AND password = '$password'");
}

And if I may add: you are using the almost obsolete mysql_* functions which are going to be kicked out of php soon. I strongly suggest you switch to mysqli API or PDO.

broj1 356 Humble servant Featured Poster

In the above code you can do it just before the inclusion of the files (first line).

broj1 356 Humble servant Featured Poster

This is where the session stops.

What do you mean by that? Do you get any error messages?

init.php included at first line, includes the session_start()

In this case it is important that you post the code of the included file.

On line 61 you have:

header('Location: edit.php?success');

This will not work since you output html before (i.e line 23). Use output buffering or save strings to a variable and output them after line 61.

broj1 356 Humble servant Featured Poster

Examine the constructed query to spot possible errors. Add the following temporary debug code to the register_user function:

function register_user($register_data) {
    array_walk($register_data, 'array_sanitize');
    $fields = '`' . implode('`, `', array_keys($register_data)) . '`';
    $data = '\'' . implode('\', \'', $register_data) . '\'';

    // temporary debug code
    die("INSERT INTO `sikeres` ($fields) VALUES ($data)");

    mysql_query("INSERT INTO `sikeres` ($fields) VALUES ($data)");
}

This will display the query as it is constructed, and stop the script. Please post the displayed query here.

Also the function should return some feedback about the success. I would add some error checking and use the return value of the mysql_query function:

function register_user($register_data) {
    array_walk($register_data, 'array_sanitize');
    $fields = '`' . implode('`, `', array_keys($register_data)) . '`';
    $data = '\'' . implode('\', \'', $register_data) . '\'';


    if(mysql_query("INSERT INTO `sikeres` ($fields) VALUES ($data)")) {
        return true;
    } else {
        return false;
    }
}

And last but not least: mysql_* functions are dinosaurs. They are on the verge of extinction. They are going to be dropped from PHP very soon. If you like yourself replace them with PDO or at least mysqli_* functionas.

broj1 356 Humble servant Featured Poster

You could try with INSERT ... ON DUPLICATE KEY UPDATE provided that you have a unique index or primary key defined (you could use email for that or first_name+last_name).

broj1 356 Humble servant Featured Poster

You will get better answers if you provide the code and data structures you have so far but in general:

You should use javascript (or better jquery) to read which teacher was selected in the first select element and remove of disable that option in the second select element. The javascript (jquery) code could be controlled by php. The data should be pulled from the database.

broj1 356 Humble servant Featured Poster

You should use javascript (or better jquery) to read which teacher was selected in the first select element and remove of disable that option in the second select element. The javascript (jquery) code could be controlled by php. The data should be pulled ftom the database.

broj1 356 Humble servant Featured Poster

but when I enter two variables it crashes

What do you mean by that? Does your computer crash? Or you just get an error message instead of expected outoput? If there is an error message, please post it. If it isn't enable reporting and display of error messages.

If user submits an empty form (no fields are filled-in) then none of the variables might exist at all. I would do a more thorough check in the if statements:

if(isset($CFHL_A) && !empty($CFHL_A) ) 
{
    ...
}
broj1 356 Humble servant Featured Poster

You have to initialize the $error_message to empty string frst: $error_message = ''; so in case there are no errors the empty string will be displayed (= nothing will be displayed).

EDIT: Also you can check if error message exists and display it only then:

<?php 
if(isset($error_message) && !empty($error_message)) {
    echo '<p class="error">' . $error_message . '</p>';
}
?>

You might also add a Javascript checking for better user experience. This way you do not submit the data before it is OK (you still check it on the server, though).

A couple of other issues:

  • since the data entered in the form will be inserted into html you have to sanitize it using htmlspecialchars() function. This way all dangerous characters entered wont do any harm (i.e. <script>)
  • in the code where you use dollar sign as a currency you should use single quotes like $list_price_formatted = '$'.number_format($list_price, 2); or escape the $ sign. Otherwise php might expect a variable name following it.
  • before using any element of the $_POST array you better check if it exists (using isset() function).
broj1 356 Humble servant Featured Poster

Just to add to above. This problem is easily solved using PHP. You first read the oldest row for a particular ID, select it's custom_id and update the cust_type to 'new'. Then just update the other rows with this id to 'recurring'.

// you have an ID
$id = 1141;

// find the oldest entry for this ID
$query = "SELECT cutom_id FROM <whatever_the_table> WHERE id='$id' ORDER BY date_of_trans ASC LIMIT 1";
... 

// upon querying the database you get oldest custom_id
$oldest_custom_id = <some_value>;

// now update the oldest row
$query = "UPDATE <whatever_the_table> SET cust_type='new' WHERE id='$id' AND custom_id='$oldest_custom_id'";

// now update the other rows of the same id
$query = "UPDATE <whatever_the_table> SET cust_type='recurring' WHERE id='$id' AND custom_id!='$oldest_custom_id'";

On the other hand you could use a stored procedure and an mysql event scheduler.

broj1 356 Humble servant Featured Poster

OK, I had a closer look at it This is what mysql manual says about updating the same table that is used in a subquery:

In MySQL, you cannot modify a table and select from the same table in a subquery. This applies to statements such as DELETE, INSERT, REPLACE, UPDATE

See: http://dev.mysql.com/doc/refman/5.5/en/subqueries.html

I am not an expert on this stuff, maybe someone else might help (I will keep trying). And I do not know how JOIN might help here.

One question though: why do not enter the new/recurring at the time of inserting the record (i.e. using a trigger)?

broj1 356 Humble servant Featured Poster

You can do two things but it is not guaranted that any of them leads to the solution.

  1. you can post the common.php script so we can check whether it might be sending some output
  2. you can post the structure and a few rows of representational data of the rentsum table so the code can be tested. I personally can test it only in mysql, maybe someone else can test it in oracle.

If you chose to post anything, make sure you remove any possible confidential data.

broj1 356 Humble servant Featured Poster

I do not want to speak on behalf of ruhestorer, it just seems to me that id_code is the particular selected id you are updating the table for. Like, you can read all the unique IDs in an array and the loop through array and run the above SQL statement. And it would probably be enough to just insert into the rows that have the new value (to run just the first query) and leave the others empty or NULL.

Anyway, I still have a feeling that there might be a sloution without using the redundant cust_type field :-)

broj1 356 Humble servant Featured Poster

What database are you using? ruhestorer's example is nice only that I am not sure if GO is supported in mysql. I think semicolon ; might work the same.

broj1 356 Humble servant Featured Poster

It will, when you correct a couple of mistakes:

  1. the ?> end tag goes before the <form> tag
  2. the if (isset($_POST['pay'])) should be changed to if (isset($_POST['print']))

I would (personaly) put the whole form processing in another file and cahnge the action attribute of the form to point to that file. Just my approach.

broj1 356 Humble servant Featured Poster

The simplest solution: move the html part (the form) to the end. This way no HTML will be output before the pdf.

<?php
if (isset($_POST['print']))
{
        require('fpdf/fpdf.php');
        class PDF extends FPDF
        {
        // Page header
            function Header()
            {
                $this->SetFont('Arial','B',14);
                $this->Cell(30,10,'Negros Oriental High School','C');
                $this->Ln();
                $this->SetFont('Arial','',12);
                $this->Cell(0,0,'Dumaguete City');
                $this->Ln();
                $this->SetFont('Arial','',14);
                $this->Cell(0,20,'OFFICIAL RECEIPT');
                $this->Ln();
            }


        }
// Instanciation of inherited class
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->Output();
}
?>
<form method="POST" action="">
    <input type="submit" name="print"value="PRINT">
</form>
broj1 356 Humble servant Featured Poster

In my opininion you do not need the cust_type field since it is redundant which is against the database normalization rules. You can always get the oldest one with:

SELECT id FROM thetable ORDER BY date_of_trans ASC LIMIT 1
broj1 356 Humble servant Featured Poster

Post the code you have so far. It is easier to built on existing code than make up everything from scratch.

Here is an example of using a jquery click event and checked selector:
http://api.jquery.com/checked-selector/ You can use this for showing/hiding a textarea.

broj1 356 Humble servant Featured Poster

I try to stick to php.net's reccomendations:

http://php.net/manual/en/faq.passwords.php

broj1 356 Humble servant Featured Poster

The error message is pretty clear: there has been some data output before the PDF is assembled and output. Now, the only candidate I see is an error message that might be produced due to a unsuccessful query. Have you doublechecked that the query is OK (when you echo the query you can paste it into the database client you use and test it)?

broj1 356 Humble servant Featured Poster

The condition for granting a login is incorrect:

if($result)
{
    echo "Login granted. <br>";
    ...

The fact is that whatever you get with the select query yields a result (even empty resultset). The $result variable is not your result yet, but just a special type - a mysqli_result object that will help you retrieve row(s). So the code

$row=mysqli_fetch_array($result);

retrieves the actual data. You have to compare it to the data entered into the form to confirm the login or at least check (count) if the $row array exist. So something like this:

require("C:\wamp\www\Onex\connect_db.php");
if(isset($_POST['login']) && !empty($_POST['login'])) {
    $uname = mysqli_real_escape_string($_POST['uname']);
    $pass = mysqli_real_escape_string($_POST['pass']);
    $login_query="select * from register where username='$uname' and password='$pass'";
    $result = mysqli_query($con,$login_query);
    if($result)
    {
        $row=mysqli_fetch_array($result);

        if(
            isset($row["username"]) && 
            isset($row["password"]) && 
            $row["username"] == $uname && // this is not strictly necessary
            $row["password"] == $pass // this is not strictly necessary
        ) {
            echo "Login granted. <br>";
            echo " Username: ".$row["username"]." and Password: ". $row["password"];
        } else {
            echo "Incorrect login. Please try again.";
        }
    } else {
        echo "Incorrect login. Please try again.";
    }
}
mysqli_free_result($result);
mysqli_close($con);
broj1 356 Humble servant Featured Poster

OK, but does the problem persist (and if yes, can you describe it)?

broj1 356 Humble servant Featured Poster

"Select query returns a result set upon success, whereas Insert query returns a true value upon success"

This just means that INSERT query returns true if it succeeds to insert the data into database. On the contrary the SELECT query return rows. If query is unsuccessful it returns false in both cases. It is good idea if you check for this (as IIM suggested).

But query within is getting fired up for wrong credentials

What exactly is happening? What do you get?

Do tell me if i need to add snaps ?

Are you talking about spirit that Germans lovingly call snaps? If yes it might help, but do not overdose :-) Just kidin. Yes if you have snapshots that might help.

Other issues with your code:

  • check first if the username posted from the form conforms to basic rules (min and max length, allowed characters etc); if not return the user to the login page
  • escape the strings before sending them to the database!!!!!!!!!!! (you can use mysqli_real_escape_string function)
  • hash the password, do not store the plaintext of it in the database
  • count the rows read from the database. if 0 - no match, if 1 - perfect match, if > 1 - something went wrong (same user saved many times)
  • do not let the user know what went wrong so instead of "No such user registered." echo "Wrong credentials, please try again.". No need to help the potential attackers.
broj1 356 Humble servant Featured Poster

What is the error?

broj1 356 Humble servant Featured Poster

I took some time to have a closer look at the jquery code as well. I changed it a bit to make it clear and working. See the comments in the code and consider the following:

  • I made the template containing the filter (the three select elements within a div) hidden: <div id="template" style="display:none;">; this template is only used for clonning when user clicks +. This is neccessary to get the filter clonned before it gets chained (otherwise you can not clone select elements with all the possible values)
  • the template is within the div with id=template, while the added filters are within the div with id=filters
  • upon clonning the id of the clonned div has to be changed from the 'template' to filter + somesequentalnumber
  • upon clonning also the id and name attributes of the select elements have to be changed (just by adding same somesequentalnumber to them)
  • after that the select elements have to be chained
  • on page load the first set of select elements is cloned, added and chained so you have the first filter (the template filter remains hidden)
  • when you process the $_POST array you first unset (remove) the elements that you actually do not need (the submit button and the values of the three template select elements)

I hope this is what you are after. Also I hope that changing the code did not break your existing project. But this way it is clear how everything works.

This is the changed code:

<?php …
Mukta_2 commented: Thanks a lot for this code! It helped me. Is it possible to calculate the sum of values selected in the third dropdown list of all rows added by user? +0
broj1 356 Humble servant Featured Poster

but even without adding any additional elements, if i print the values using php, I am not getting what I have selected. instead, i am getting the first element in the <option>.

I have had a look at the jquery code. The problem is that you call the $('#clone').click() on line 54 of your last posted code. This function call generates a new set of select elements immediately on page load and this set is hidden. The elements have the same name attributes as the first set that is visible. Upon clicking of a submit button the unchanged values of the second hidden set override the selected values of the first set in the $_POST array.

The solution is to remove the call to the .click() function on line 54 and let the user call it by clicking on + sign (which is how this method should be used).

The problem of same name attributes still remains though. The jquery code should be amended to assign different names to new sets of select elements. I am not an expert in jquery but will have a look at it once I find time.

broj1 356 Humble servant Featured Poster

Have you tried the above hints? Do they not solve the problem? If not where did it stop?

broj1 356 Humble servant Featured Poster

There are two problems:

  1. The new select elements do not get inserted within exiting form tags but outside. Probably the div with the id=filter should be inside the form.
  2. the newly inserted select elements all have the same name which is semester. You have to make up a logic in the js script that will assign a sequential name attribute to each inserted select element.
broj1 356 Humble servant Featured Poster

Select names should not have the [] appended to them (you use this approach for grupped elements like radio button or checkbox groups). So:

<select class="semester" name="semester">

The third select element does not have a name attribute at all, so add it.

And this is how you display the values:

if(isset($_POST['submit'])) {
    foreach($_POST as $value) {
        echo $value;
    }
}

I you do not want to use the 'submit' element, you can skip it:

if(isset($_POST['submit'])) {
    foreach($_POST as $key => $value) {
        if($key != 'submit') {
            echo $value;
        } 
    }
}
broj1 356 Humble servant Featured Poster

The select elements have to have name attributes and be enclosed in form tags containing the action and method attributes in order to properly pass the values to the server. Something like:

<form action="process.php" method="post">
    <select class="pais" name="sel_pais">
        <option value="1">Argentina</option>
        <option value="2">Chile</option>
    </select>
    <select class="provincia" name="sel_provincia>
        <option value="1" class="1">San Juan</option>
        <option value="2" class="1">Mendoza</option>
        <option value="3" class="2">La Serena</option>
        <option value="4" class="2">Santiago</option>
    </select>
    <select class="ciudad" name="sel_ciudad>
        <option value="1" class="1">Rawson</option>
        <option value="2" class="2">Godoy Cruz</option>
        <option value="3" class="3">Coquimbo</option>
        <option value="4" class="4">Chiñihue</option>
    </select>
</form>

The process.php will do the processing (= storing into database) of the data which is stored in the $_POST global array, again just an example:

// initialize an array for possible error messages
$error_array = array();

// check if value for the country exixts and is not empty string
if(isset($_POST['sel_pais']) && !empty($_POST['sel_pais'])) {
    // trim the value and escape it if it goes to the DB
    $pais = mysqli_real_escape_string(trim($_POST['sel_pais']));
} else {
    // if no value add the error to the error_array
    $error_array[] = 'No country selected!';
}

// check if value for the province exixts and is not empty string
if(isset($_POST['sel_provincia']) && !empty($_POST['sel_provincia'])) {
    // trim the value and escape it if it goes to the DB
    $provincia = mysqli_real_escape_string(trim($_POST['sel_provincia']));
} else {
    // if no value add the error to the error_array
    $error_array[] = 'No province selected!';
}

// check if value for the city exixts and is not empty string
if(isset($_POST['sel_ciudad']) && !empty($_POST['sel_ciudad'])) {
    // trim the value and escape it if it goes to the DB …
broj1 356 Humble servant Featured Poster

Use the resize parameter of the image function to scale the image . See the documentation.

Something like:

// set the required parameters
$posX = 100;      // position x of the upper left corner 
$posY = 100;      // position y of the upper left corner 
$newWidth = 400;  // new width that you wish to scale to 
$newHeight = 300; // new height that you wish to scale to
$type = '';       // will be kept default
$link = '';       // will be kept default
$align = '';      // will be kept default
$resize = true;   // this will make the image resize

// add the scaled image
$pdf->image($name, $posX, $posY, $newWidth, $newHeight, $type, $link, $align, $resize);
broj1 356 Humble servant Featured Poster

You are welcome. Please mark the thread as solved. Happy coding.

broj1 356 Humble servant Featured Poster

Yes, it must have been some maintenance going on. I will mark this as solved.

broj1 356 Humble servant Featured Poster

Lines 3 to 9 are a strange way of cycling through paths to find the library. You should know where the library resides, shouldn't you. But if it works and you are happy with it, it is OK with me, too.

TCPDF ERROR: Some data has already been output, can't send PDF file

Make sure that fetching a row does not return an error. Maybe you should change the index to lower case:

$empcode=$result['empcode'];

or even better first check if it exists:

if(isset($result['EMPCODE'])) {
    $empcode=$result['EMPCODE'];
} else {
    $empcode = 'NOT DEFINED';
}

The whole while loop could be shortened, no need to use a $txt variable:

// set some text to print
while($result=oci_fetch_array($sqldata,OCI_BOTH))
{
    if(isset($result['EMPCODE'])) {
        $empcode=$result['EMPCODE'];
    } else {
        $empcode = 'NOT DEFINED';
    }
    //echo $empcode."\r\n";
    $pdf->Write(0, $empcode, '', 0, 'C', true, 0, false, false, 0);
}

and move over i want that this file should create on clint pc not in the same browser like the text file create on clint pc by:-

Use the D parameter for the Output method. It will ask you where to save the document on local PC:

$pdf->Output('example_002.pdf', 'D');
broj1 356 Humble servant Featured Poster

What about savings replys? How i can store in database?

On furm submit save the answers. If second answer is yes, save also the third answer. Do an INSERT query to save to DB. Do not use mysql extension, use PDO or at least mysqli

In addition, i need to generate report by pie chart or something like that..

Use jqplot library or similar javascript library for generating charts

broj1 356 Humble servant Featured Poster

Hi

I have just replied on a post that was posted 43 years ago. My reply was also 43 years ago. I had that feeling that time just flies lately but this might be a little too fast. Or is it just some issue with unix time.

This is the link to the article.
http://www.daniweb.com/web-development/php/threads/461757/feedback-system-phpmysql#post2008638

EDIT: it is back to normal. I was just extremely lucky to whitnes this extraordinary event for a very short time.

broj1 356 Humble servant Featured Poster

One approach:

  1. make a form for your questions
  2. use radio buttons for questions 1 and 2
  3. use a text input or text area for question 3, and enclose it in a hidden element (i.e. a div)
  4. attach a javascript function on the onclick event of the radio buttons for the question 2; the javascript should check which value was clicked: if yes, unhide the div for question 3; if no, hide the div for question 3
broj1 356 Humble servant Featured Poster

What is the path to the TCPDF library? What is the path in the require_once command? Can you post both? And let us know what OS do you use.

broj1 356 Humble servant Featured Poster

The path in the command that includes the library must be correct. If you move the example script change the path in the require_once command.

broj1 356 Humble servant Featured Poster

To add to the above reply: PDF Extension uses PDFlib library which is not free (you have to purchase it). TCPDF and FPDF are free. TCPDF is better maintained and actively developed, while FPDF is being more or less idle (last version from June 2011). They both do their job very good and have plenty of examples.

broj1 356 Humble servant Featured Poster

And the comments and solutions are:

  1. In lines 2 and 3 there is no need to send the header. FPDF will take care of all.
  2. Before line 11 you should use a SetFont() FPDF method to set the font you wish to use
  3. On lines 24 and 25 you used mysql_query function twice, with errors in syntax
  4. On line 28 you used a nonexisting index 1 (only index 0 exists)
  5. Before line 30 you should again use SetFont() FPDF method (I think)
  6. I do not know where the values $row['id'] and $row['name'] come from. I ignored them. Make sure they exist. (credits also to pzuurveen)
  7. Make sure you can write to the current directory or add a parameter to the Output() method (like 'D' for Download)
  8. I do not know what is the point of line 30. Get rid of it. (credits also to pzuurveen)

The code that works for me is (a bit rearranged to be more clear):

<?php
$link=mysql_connect('localhost:3306','root','');
mysql_select_db('uploadimage');-
$query = "SELECT name FROM image1 WHERE id=1";
$result = mysql_query($query);
$row=mysql_fetch_row($result);
$name=$row[0];

require("fpdf.php");
class PDF1 extends FPDF
{
    // Page header
    function Header()
    {
        // Logo
        $this->SetFont('Arial','B',12);
        $this->Cell(0,10,'APPLICATION FORM FOR ADMISSION INTO MEDICAL PG DEGREE/DIPLOMA COURSES',0,0,'C');
        $this->Ln(6);
        $this->Cell(0,10,'UNDER MANAGEMENT QUOTA FOR THE ACADEMIC YEAR 2014-2015',0,0,'C');
        $this->Ln(6);
        $this->Cell(0,10,'-----',0,'C');
        // Line break
        $this->Ln(15);
    }
}

$pdf = new PDF1();
$pdf->AddPage();
$pdf->SetFont('Arial','',16);
$pdf->Image($name);
// $pdf->Cell(0,10,'id'.$row['id'],0,1);
// $pdf->Cell(0,10,'name'.$row['name'],0,1);
$pdf->Cell(0,10,'id',0,1);
$pdf->Cell(0,10,'name',0,1);
$pdf->Output("image.pdf", 'D');
?>

The code works provided that the image is present and the path to it is correct.

broj1 356 Humble servant Featured Poster

OK, I had a look at the files that you sent me. In this post I will post a file that is causing troubles. In next post I will describe the solutions. The troublesome script is:

<?php
header('Content-type: image/jpeg');
header('Content-type: application/pdf');
require("fpdf.php");
class PDF1 extends FPDF
{
    // Page header
    function Header()
    {
        // Logo
        $this->Cell(0,10,'APPLICATION FORM FOR ADMISSION INTO MEDICAL PG DEGREE/DIPLOMA COURSES',0,0,'C');
        $this->Ln(6);
        $this->Cell(0,10,'UNDER MANAGEMENT QUOTA FOR THE ACADEMIC YEAR 2014-2015',0,0,'C');
        $this->Ln(6);
        $this->Cell(0,10,'-----',0,'C');
        // Line break
        $this->Ln(15);
    }
}
$link=mysql_connect('localhost:3306','root','');
mysql_select_db('uploadimage');
$pdf = new PDF1();
$pdf->AddPage();
$query=mysql_query("select name from image1 where id=1");
$result = mysql_query($link, $query);

$row=mysql_fetch_row($result);
$name=$row[1];
$pdf->Image($name);
$pdf->Cell(0,10,'id'.$row['id'],0,1);
$pdf->Cell(0,10,'name'.$row['name'],0,1);
$pdf->Output(".pdf");
header('Location: '. ".pdf");
?>