Four common P H P errors and what they mean
This one is for the newbies
.
- Warning: Invalid argument supplied for foreach() in /www/yourserver/html/script.php on line 36
- Means that the first variable in your foreach statement is not an array. If your statement is
foreach($a as $b),$aneeds to be an array. - Parse error: parse error, unexpected $ in /www/yourserver/html/script.php on line 36
- Check to see if there is a missing curly brace from your for, while or if…else loop.
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /www/yourserver/html/script.php on line 36
- Means that the variable that’s being used in
mysql_fetch_array()is not the variable that is holding the result. If your query was stored in the variable $egg (e.g.:$egg=mysql_query("SELECT * FROM table");), then you would fetch the array like this:mysql_fetch_array($egg); - Warning: Cannot modify header information – headers already sent by (output started at /www/yourserver/html/includedfile.php:4) in /www/yourserver/html/script.php on line 36
- This means that you have some kind of HTML, XML, or white space at the top of your PHP script that was sent to the browser following your server’s response headers. The “output started at …” phrase lets you know which file and line number (in this case, line 4) contains the offending code/whitespace.