Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4564534
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:30:53+00:00 2026-05-21T18:30:53+00:00

<?php $filename=vast/Vastopolis_Map.png; $image = imagecreatefrompng($filename); // get properties of the image as an array

  • 0
<?php
$filename="vast/Vastopolis_Map.png";
$image = imagecreatefrompng($filename);

// get properties of the image as an array $size
// $size[0] is the width of the image in pixel
// $size[1] is the height

$size = getimagesize($filename);
$width = $size[0];
$height = $size[1];

// Set the color (red)
$ink_color = imagecolorallocatealpha ($image, 244, 1, 1, 100);
// Set line thickness if needed
// imagesetthickness($image, 5);

// get GPS locations where text meets selection criteria
// Connect to MySQL, assume the database is called vast
$dsn = 'mysql:host=localhost;dbname=vast';
$username = '###';
$passwd = '###';

$db = new PDO($dsn, $username, $passwd);

// Select text that mentions flu or fever
// Option 1: text like '%flu%' or text like '%fever%'
// Option 2: text regexp 'flu|fever'
$sql = "SELECT Location, Text FROM blogs WHERE Text LIKE '%flu%' '";
$results = $db->query($sql);

// Linear transformation to match the coordinates on the map
// The upper left corner of the map: 42.3017, 93.5673
// The lower right corner of the map: 42.1609, 93.1923
$minX = 42.3017;
$maxX = 42.1609;

$minY = 93.5673;
$maxY = 93.1923;
// Linear transformation. What does it do?
$a = $width/($maxX-$minX);
$b = -$minX*$a;

$c = $height/($maxY-$minY);
$d = -$minY*$c;

// Set the color of the markers - red
$color = imagecolorallocatealpha ($image, 250, 10, 10, 50);

// plot each location returned from the query to the database
foreach ($results as $row) {
$location = $row[0];
$pos = preg_split("/\s+/", $location); // why?
$X = $pos[0];
$Y = $pos[1];
$x = $a*$X + $b;
$y = $c*$Y + $d;
imagefilledellipse($image, $x, $y, 10, 10, $color);
}
// serve the image to the client
header ("Content-type: image/png");
imagepng($image);
imagedestroy($image);

?>

it is throwing this disgusting error, anyone??

Warning: Invalid argument supplied for foreach() on line 51

Warning: Cannot modify header information - headers already sent by  on line 61
‰PNG  IHDR` ]×ý{~÷PLTEôú ûûûèæÙãÒìæÓÔÖçæËäÎÑÐêÒÐÑæï®âæšìέéšÈê³ØâšËÔ¯ËËä¼åæ·ËзæË¬ÏÃÆæ®­ã¸‘ä æŽÏ®¯Ð­‰Ç—¬Æ‘Œºãó»ãÒ·Èí±ÒÆË÷˜Èù䫷⚮̭ªÌ‘›Â±šÄŠ¨Ï­­®­²®‹®°Œ’´§¬Ž’§‹‹ÄÅyä­yæ€}ò‘IÌ¥yõYĘpÃ[ùƒ+Ê8®Â{¬¬m¤¥Z±i®„X‰¬q™¢Y‹“nŽP¨¢;¤‚<‘ >„ˆ;„å}Är¦É}ƒ{ͤ|¤§v¦\¡©VŒ–v¤mX¨…\…‘2‡çppð`^ç\bêPQÔpqÊnVÒ]bÔQRíy%þjë@>ìZÌr'ÒiØA>ÍX ð=CÔ>Bë34ñ!þ"ý   Õ67Å:̧rn¥yQ¢\f«RSnm‘mLŠYo†YL£v;´e«\+±XŽf:ƒm†Y5ŒT®=F†2m„:L‚m­/1®'¾‰2+‚'Ž ƒ rÀúT¤ázª¤|¢{ˆ¢s“‰P¥¥U¨‰O‡¯[ˆƒ“þ-ƒ¸-‘¶……z£ix¡[qllŽT[¡n_ C[ƒrZ…Lxƒ:iƒU…:Sƒ2‡m4„W‚w…N2ƒg`Õsk³qsˆdZ´tU†Jx©[iƒUK±UMŽC;Ùj0‡d‡E9¬H8\ {È&mŸ$á3)®3'—&®&”­‘mmpltPmRnqQNVpmToLSUkOONqn6~jrO0kHNm5Z}NT0NNfde:.f:p#~R4/N0L-C8kf-lG8Kf4PN~~lDJ~GH*g7&~2R-/Md8sU-G63c25M#}5Jtéã°ER¶ÁSÆ3tŸwC×ëx<ñ“ÏɼøÇvæßžpvü0#V>¶[û]oGÿÏÓc{ÚhEõlóï‡1g çFû|‡Úà®–\¿^o×ö~mÏãO?ÿô`Åè^<ë®òe{öØÓ>°ý~×§ íøszŠè꾪nz¤>â<äø°^÷:̶óu;ö]…:þtÜöUÍ’«6QvKn|@ÉÖL¸ëoêk8|`ítSû9«°\Ú³Ï'BÆ•¥5ڪ㎨_tû «¬tøíúív½¶;ÿÝow>»À›íÃÃÑÊÓuµýò𪪶Gœ€Õvª?”è”;Ee§`þm{az`Ÿ­åzÄyí1"‹žÝÑÎ÷ÓqTÓXÕvÖKí÷

Not sure if this is a db error, or something with php. Completely lost why its doing this or what its talking about.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T18:30:54+00:00Added an answer on May 21, 2026 at 6:30 pm

    You have an stray ‘ in your query, which makes it invalid

    $sql = "SELECT Location, Text FROM blogs WHERE Text LIKE '%flu%' '";
    

    should be

    $sql = "SELECT Location, Text FROM blogs WHERE Text LIKE '%flu%'";
    

    A malformed query will make $results an error code instead of an array of results. Since there are no results in $results, you can’t use foreach on it without errors, as foreach can only be used on arrays.

    Since the foreach causes an error, which prints and send to the user, it will generate the “headers already sent” error. Which the cause, and the effect will be solved too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I check that the php script works? I'm using php -f filename.php
A PHP Error was encountered Severity: Notice Message: Uninitialized string offset: 0 Filename: index.php
I have this code in userpage.php: <script langauge=JavaScript><!-- function newWindow(fileName,windowName) { msgWindow=window.open(fileName,windowName); } //--></script>
I have an upload box... <form action=upload_file.php method=post enctype=multipart/form-data><BR> <label for=file>Filename:</label><BR> <input type=file name=file
In PHP, is it possible to get the file name of the script that
PHP - Access MSSQL datetime column from the returned array Array ( [0] =>
I'm trying to change all http://www.mysite.com/filename.php files to show as http://www.mysite.com/filename/ using mod_rewrite, but
Is this just a stylistic difference, or does using require_once('filename.php') vs require_once 'filename.php' have
$ps = ps_new(); ps_open_file($ps,$filename); ps_begin_page($ps,$size,$size); ps_set_parameter($ps, 'SearchPath' , '/usr/share/texmf-texlive/fonts/afm/bluesky/cm'); $psfont = ps_findfont($ps, cmr10, ,
Should I use cache to store arrays that are saved in included files? include(filename.php);..

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.