Jump to content

[SOLVED] Code works, but doesn't.


TutorMe

Recommended Posts

I have a script that generates an image dynamically from information in a mysql database.  It works on my test server (mamp, php5, mysql5), but not on my actual server which is at one and one.  Does anyone have any ideas as to why this would happen?  I have changed the connection information to match my real server, but that's it.

 

Any help is appreciated.

Link to comment
https://forums.phpfreaks.com/topic/76634-solved-code-works-but-doesnt/
Share on other sites

<?php

header("Content-type: image/png");
require_once('config.php');
mysql_select_db("bdays", $con);
$result = mysql_query("SELECT * FROM January
Union
SELECT * FROM February
Union
SELECT * FROM March
Union
SELECT * FROM April
Union
SELECT * FROM May
Union
SELECT * FROM June
Union
SELECT * FROM July
Union
SELECT * FROM August
Union
SELECT * FROM September
Union
SELECT * FROM October
Union
SELECT * FROM November
Union
SELECT * FROM December");
while($row = mysql_fetch_array($result))
  {
  if ($row['day'] == date('d') && ($row['month'] == date('F')))
$list = $row['username'] . " ";
  else
  	$list = "Nobody has a birthday today.";
  }
mysql_close($con);


$string = $list;
$im     = imagecreatefrompng("bg.png");
$orange = imagecolorallocate($im, 89, 89, 89);
$px     = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, 9, $string, $orange);
imagepng($im);
imagedestroy($im);

?>

 

Here's where it is on my actual server: http://pschost.com/bdays/av.png/copy.php

I'm having a problem seeing how it works on any server.

 

Suppose you have 100 records and the first 99 match but the last one doesn't.

 

On that last one, $list becomes "Nobody has a birthday today." no matter what was in there before.

<?php
while($row = mysql_fetch_array($result))
  {
  if ($row['day'] == date('d') && ($row['month'] == date('F')))
$list .= $row['username'] . " ";
  }

if ($list == '') $list = "Nobody has a birthday today.";

 

 

PS Why 12 tables?

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.