Jump to content

Image manipulation error


gabenut

Recommended Posts

Hello,

I have been doing some work on making a survey with PHP and MySQL. I am having a problem displaying the image for the graph. I have been using the imagecreate() function in PHP.

The error displayed is: [b]The image "survey.php" cannot be displayed, because it contains errors.[/b]

Here's the coding:

[code]<?php
session_start();

Header("Content-Type: image/gif");


$query = "SELECT count(question_id) FROM final WHERE QuestionID=1";
$result = mysqli_query ($dbc, $query);
$row = mysqli_fetch_row($result);
$nTotalVotes=$row[0];

$query = "SELECT final.answer_id, answers.answer as tx, count (final.answer_id) as ct FROM final, answers WHERE final.answer_id = answer.answer_id AND final.question_id =1 GROUP BY final.answer_id";

$result = mysqli_query ($dbc, $query);
$xDim = 400;
$yDim = 15+(mysqli_num_rows($result)*15);
$im = ImageCreate($xDim, $yDim);
$backg = ImageColorAllocate($im, 255,255,200);
$blue = ImageColorAllocate($im, 0, 0, 255);
$nY = 0;
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
    $percVote = round(($row['ct']/$nTotalVotes)*100,2);
    $percWidth = ($percVote * $xDim / 100) - 10;
    ImageFilledRectangle($im, 0, $nY+1, $percWidth, $nY+10, $blue);
    ImageString($im,2,$percWidth + 5, $nY+1, $row['tx'] . " " . $percVote . "%", $blue);
    $nY=$nY+15;
}
ImageGIF($im);


?>[/code]

Any help would be greatly appeciated, thank you!

Link to comment
https://forums.phpfreaks.com/topic/7604-image-manipulation-error/
Share on other sites

Thanks very much for your help. The errors I got were these:


Warning: mysqli_fetch_row() expects exactly 1 parameter, 2 given in survey.php on line 10

Warning: mysqli_num_rows() expects exactly 1 parameter, 2 given in survey.php on line 17

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in survey.php on line 22
GIF87a?

I'm not sure what these mean, so again, any help would be much appreciated. Thank you!

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.