Okay guys so I have this error coming up in my server errors and its being caused by Google Graph I have displayed on one of the pages of my site. After some time with the graph loaded on the page this loops out of control and the server runs out of memory and i get major I/O errors on my cPanel.
[22-Oct-2014 19:14:23 UTC] PHP Warning: fgets() expects parameter 1 to be resource, boolean given in /home/gift3dsaint/public_html/graph.php on line 44
[22-Oct-2014 19:14:23 UTC] PHP Warning: feof() expects parameter 1 to be resource, boolean given in /home/gift3dsaint/public_html/graph.php on line 42
[22-Oct-2014 19:14:23 UTC] PHP Warning: fgets() expects parameter 1 to be resource, boolean given in /home/gift3dsaint/public_html/graph.php on line 44
[22-Oct-2014 19:14:23 UTC] PHP Warning: feof() expects parameter 1 to be resource, boolean given in /home/gift3dsaint/public_html/graph.php on line 42
[22-Oct-2014 19:14:23 UTC] PHP Warning: fgets() expects parameter 1 to be resource, boolean given in /home/gift3dsaint/public_html/graph.php on line 44
[22-Oct-2014 19:14:23 UTC] PHP Warning: feof() expects parameter 1 to be resource, boolean given in /home/gift3dsaint/public_html/graph.php on line 42
The code I have referencing to the graph is this PHP:
$lines=array();
$fp = fopen($file, "r");
while(!feof($fp)) {
$line = fgets($fp, 4096);
array_push($lines, $line);
}
fclose($fp);
Related
I am trying to install a new theme. After copying it to the themes folder and entering the themes admin panel to activate the theme I get 3 warning error:
Warning: fopen(C:\wamp\www\wordpress/wp-content/themes/idealdevelopments/style.css) [function.fopen]: failed to open stream: Permission denied in C:\wamp\www\wordpress\wp-includes\functions.php on line 4782
Warning: fread() expects parameter 1 to be resource, boolean given in C:\wamp\www\wordpress\wp-includes\functions.php on line 4785
Warning: fclose() expects parameter 1 to be resource, boolean given in C:\wamp\www\wordpress\wp-includes\functions.php on line 4788
Change your folder permissions.
I am trying to install php code sniffer. I have manage to get to a point where after running
php /Users/ryanfernandes/pear/bin/phpcs --version it display the info. but when I try to run code sniffer by
php /Users/username/pear/bin/phpcs /Users/username/development/htdocs/test.php
PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 155
Warning: fwrite() expects parameter 1 to be resource, boolean given in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 155
PHP Warning: stream_get_meta_data() expects parameter 1 to be resource, boolean given in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 206
Warning: stream_get_meta_data() expects parameter 1 to be resource, boolean given in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 206
PHP Warning: file_get_contents(): Filename cannot be empty in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 208
Warning: file_get_contents(): Filename cannot be empty in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 208
PHP Warning: fclose() expects parameter 1 to be resource, boolean given in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 209
Warning: fclose() expects parameter 1 to be resource, boolean given in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 209
Any help would be really appreciated.
Thanks
From the error messages, it looks like you are using PHP_CodeSniffer version 1.5.4. PHP_CodeSniffer uses the tmpfile() function to create a temporary file. The directory that it is created in can be found by running:
php -r 'echo sys_get_temp_dir().PHP_EOL;'
Make sure you are allowed to write to that directory because the tmpfile() method is obviously returning FALSE, which most commonly happens if the directory is not writable.
I've installed unixodbc, freetds, php on Ubuntu 12.04.4 LTS (GNU/Linux 3.8.0-44-generic i686) and I get my query works fine with:
php /var/www/connect.php
but when access to localhost/connect.php I get:
Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /var/www/connect.php on line 8 Warning: odbc_exec() expects parameter 1 to be resource, boolean given in /var/www/connect.php on line 10 Warning: odbc_fetch_row() expects parameter 1 to be resource, null given in /var/www/connect.php on line 11 Warning: odbc_close() expects parameter 1 to be resource, boolean given in /var/www/connect.php on line 15
I think is about permissions.
I've installed restler using composer. I've set up a virtual host for it. I'm able to go to my localhost in my browser and it shows some informational pages but as soon as I try one of the APIs I get a server 500 error.
My PHP logs say:
Function main
Error Type E_ERROR
Source File /public/examples/_001_helloworld/index.php : 18
Error String Class 'Luracast\Restler\Restler' not found
I'm using the example code straight out of the project. It looks like it has the require_once '../../../vendor/restler.php' and it seems to still have 500 errors.
I'm using PHP 5.4.16 on a Mac.
Update
Here are all of my logs:
[05-Sep-2013 17:05:09 America/Denver] PHP Warning: include(/Users/ChrisLondon/composer/autoload_classmap.php): failed to open stream: No such file or directory in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 432
[05-Sep-2013 17:05:09 America/Denver] PHP Warning: include(): Failed opening '/Users/ChrisLondon/composer/autoload_classmap.php' for inclusion (include_path='.:/usr/local/zend/share/ZendFramework/library:/usr/local/zend/share/pear:/opt/local/lib/php') in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 432
[05-Sep-2013 17:05:09 America/Denver] PHP Warning: include(/Users/ChrisLondon/composer/autoload_namespaces.php): failed to open stream: No such file or directory in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 432
[05-Sep-2013 17:05:09 America/Denver] PHP Warning: include(): Failed opening '/Users/ChrisLondon/composer/autoload_namespaces.php' for inclusion (include_path='.:/usr/local/zend/share/ZendFramework/library:/usr/local/zend/share/pear:/opt/local/lib/php') in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 432
[05-Sep-2013 17:05:09 America/Denver] PHP Warning: array_values() expects parameter 1 to be array, boolean given in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 154
[05-Sep-2013 17:05:09 America/Denver] PHP Warning: array_merge(): Argument #2 is not an array in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 155
[05-Sep-2013 17:05:09 America/Denver] PHP Warning: array_merge(): Argument #1 is not an array in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 155
[05-Sep-2013 17:05:09 America/Denver] PHP Warning: array_map(): Argument #2 should be an array in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 166
[05-Sep-2013 17:05:09 America/Denver] PHP Warning: array_filter() expects parameter 1 to be array, null given in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 166
[05-Sep-2013 17:05:09 America/Denver] PHP Warning: natsort() expects parameter 1 to be array, null given in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 167
[05-Sep-2013 17:05:09 America/Denver] PHP Warning: array_unique() expects parameter 1 to be array, null given in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 170
[05-Sep-2013 17:05:09 America/Denver] PHP Warning: implode(): Invalid arguments passed in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 170
[05-Sep-2013 17:05:09 America/Denver] PHP Fatal error: Class 'Luracast\Restler\Restler' not found in /Users/ChrisLondon/personal/SuperfyMe/public/examples/_001_helloworld/index.php on line 19
It seems like it's trying to find the autoload class here: /Users/ChrisLondon/composer/autoload_classmap.php but the file is actually here: /Users/ChrisLondon/personal/SuperfyMe/vendor/composer/autoload_classmap.php
Solved my issue.
It turns out because I have a folder named composer/ that happens to be two folders up from where the Restler app sits it ruins the Restler autoloader. To solve the issue one needs to do one of the following:
1) Don't have any folder named composer/ two folders up from where the Restler app resides
2) Modify the Restler autoloader to skip the folder (at the time of this post you could comment out line 138 of /vendor/Luracast/Restler/Autoloader.php)
A more elegant solution has been proposed by me on GitHub:
Issue: https://github.com/Luracast/Restler/issues/195
Pull Request: https://github.com/Luracast/Restler/pull/196
By the time someone else finds this post hopefully the issue will be resolved in future versions of Restler.
According to fopen documentation, in some modes it will create the file if it does not exist, but in my situation, I've checked all 'w', 'w+', 'x' and 'x+' modes but it's just throwing warnings at me and it cannot create the file.
It's my code:
$this->handle = fopen($this->log_name, 'w');
and what I get:
Warning: fopen(D:\xampp\htdocs\farid\logs\error.php) [function.fopen]: failed to open stream: No such file or directory in D:\xampp\htdocs\farid\libraries\error\log.php on line 34
Warning: fwrite() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\farid\libraries\error\log.php on line 66
Warning: fclose() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\farid\libraries\error\log.php on line 27
And I'm working in windows environment.
Check if the path to the logfile exists, it creates a file, not a directory.
Also check if the user, which runs xampp, has access to the folder you specified.