OK up until now I considered myself a decent coder.. Apparently I was wrong. Am I missing something here? Why is the following switch code giving me an error: Parse error: parse error, expecting `':'' or `';'' in /my/server/dir/myfile.php on line 23 (Note: line 23 is actually the line 23 in the code below) switch ($filetype) { ## -------------------------------------------------- ## case "image/gif": copy ($_FILES['gameicon']['tmp_name'], "gameicons/".$_FILES['gameicon']['name']); break; ## -------------------------------------------------- ## ## -------------------------------------------------- ## case "image/jpg": copy ($_FILES['gameicon']['tmp_name'], "gameicons/".$_FILES['gameicon']['name']); break; ## -------------------------------------------------- ## ## -------------------------------------------------- ## case "image/png": copy ($_FILES['gameicon']['tmp_name'], "gameicons/".$_FILES['gameicon']['name']); break; ## -------------------------------------------------- ## default $formErrors['gameicon2'] = 'You did not upload a valid image.'; } PHP: What's wrong with this switch??
try using: default; $formErrors['gameicon2'] = 'You did not upload a valid image.'; break; it might work
OK well stab me with a rusty screw driver... that was it. How did I miss that colon. I must have stared at that word default for 5 minutes at least!
Part of the game, who doesn't get that? Bloody annoying isn't it? If you use something like Zend Studio, chances are it would have highlighted the error there and then. One 'debugging' technique I use is to echo random shit from the error line up, every line. echo 'line 22'; etc. So you get to see exactly where it last executed a line. That's where the trouble will be.
Yeaa... I have invented my own version of debugging called... 'BLAH Debugging' . I put this code right from in a place echo 'blah';exit; PHP: If it says 'blah', I move it further down. Sometimes I use blah1 and blah2 at the same time . Really helps to remove some stupid errors. Thomas