petr.pavel 19 Junior Poster

I'm sorry I assumed that you are running Windows on your development box and that would be why GD doesn't find the font in Windows font folder.

I'm quite sure that you don't have to configure GD library in any way so let's look for other reasons that imagettfbbox() fails.
Are you are absolute sure that monofont.ttf exists in the path you specified, user that runs the web server can read it? Try something along these lines:

if (!file_get_contents('/absolute/path/monofont.ttf')) die('cannot read');

If on Windows try double back slashes instead of forward slashes - or vice versa.
Where is monofont.ttf stored and what syntax did you use when trying the absolute path?

Try downloading the latest version of GD library for your operating system (what is your operating system, by the way?). Did you compile it or got a binary? If compiled then try to get a package with binary instead.

I found that people reported problems if the file name contained a hyphen. Doesn't seem to be your problem though. Could be somewhere in the path?

petr.pavel 19 Junior Poster

Hi, first let me suggest that you should think of some less complicated way of displaying the data. I guess you could achieve the same result with just about twenty lines of code.

But to answer you questions:

  • The main problem probably is that you have echo '<tr>... inside of all your three loops. So it prints a row of all seven days for each day and term - which isn't what you want. There's no simple solution for this. I suggest you rewrite it into a single query for all days using SQL construct week_day IN (0,1,2,3,4,5,6) and then convert the results into two-dimmensional array: $data[$orderNumber][$row->weekDay] . Then traverse $data in two loops: one for each row of the array and second for each day of the week.
  • for($wk_day =0; $wk_day < count($all_avail_days); and foreach($all_avail_days as $key => $avail) does the same only using a different construct. So you are basically looping the same thing twice.
  • maybe you're referencing the array items wrongly - use $all_avail_days["$wk_day"][$key]["start_time"] instead of $all_avail_days[$wk_day][$key][start_time] Reasoning: $all_avail_days["1"] is something else than $all_avail_days[1].
  • $type_start_time7 -like variables aren't cleared after being used so you may be printing old values from previous loops. You should have else for each if($day == ...) where you clear the variables: $time_id7 = $type_start_time7 = $type_end_time7 = $colour7 = NULL; Or you can get rid of them completely and use the directly $all_avail_days["$wk_day"][$key]["start_time"] stuff with printf()
  • You may also want to use ORDER BY in …
nav33n commented: Good point. +6
petr.pavel 19 Junior Poster

check for viruses:

  • your hosting must be allowed to execute files (which I seriously doubt)
  • you have to know where the antivirus program is and what parameters it expects
  • then use exec() to run it

ftp:

  • your script can use FTP if PHP has been compiled with FTP support - but that's likely
  • but it wouldn't solve your problem - you would need your users to use FTP instead of HTTP upload

To let your users upload files via FTP safely (safely for you, not for them), you need this:

  • set up a separate FTP user with access only to a specified directory (so that he cannot mess with your scripts)
  • this directory must not be allowed to run PHP scripts (best if it's outside httpdocs) otherwise someone will misuse it to run a spam-bot
Scottmandoo commented: For continuously helping me out, thanks heaps +1
petr.pavel 19 Junior Poster

All right, I can see that you know what you're doing :-)

Since your hacking it anyway, we won't mind using eval(), will we? (yuck!)

$string = "level1.level2a.level3=10";

list($combinedKey, $value) = split('=', $string);
$keys = split('\.', $combinedKey);

$command = '$config["'.join('"]["', $keys).'"] = $value;';
eval($command);

var_dump($config);
JRSofty commented: Very helpful. +1
petr.pavel 19 Junior Poster

Hi Dave,
you're not giving us the whole script, are you?
$sendmail should be defined somewhere. That's where your path to sendmail goes.

BTW: This method of sending e-mails is bad, read something about e-mail injection:
http://en.wikipedia.org/wiki/Email_injection

If you you're still having problems with sending through sendmail (it could be that -t is forbidden, for instance) and you cannot use built-in mail() function (the easiest way ever, although even there you have to care about e-mail injections) I recommend using XPertMailer library:
http://xpertmailer.sourceforge.net/

It may be a bit of a hard nut for you to crack at first as you are probably a PHP beginner, but the reward is worth it. You can for instance, send HTML e-mails with it like a breeze, or send e-mails using the recipient's mailserver (read from MX query).

hbmarar commented: nice +3
petr.pavel 19 Junior Poster

I agree with forzadraco: don't do this.
An attacker could simply call your page with:
page.php?string=;DELETE * FROM yourtable
and you're dead.

However, to answer your question, the function you're looking for is urlencode().