Jim R Posted December 23, 2019 Share Posted December 23, 2019 I'm trying to link think a .php file full of functions to the following stylesheet Quote <link href="/styles/playerProfiles.css" rel="stylesheet" type="text/css"> I have it above the <?php tag. I have tried echoing it inside the <?php and ?>, but it produces the same error. Getting this error: Quote Warning: Cannot modify header information - headers already sent by (output started at /public_html/wp-content/plugins/csi_custom.php:2) in /home2/csi/public_html/wp-includes/functions.php on line 6029 Warning: Cannot modify header information - headers already sent by (output started at /public_html/wp-content/plugins/csi_custom.php:2) in /home2/csi/public_html/wp-admin/includes/misc.php on line 1252 Warning: Cannot modify header information - headers already sent by (output started at /public_html/wp-content/plugins/csi_custom.php:2) in /home2/csi/public_html/wp-admin/admin-header.php on line 9 Quote Link to comment https://forums.phpfreaks.com/topic/309740-getting-header-errors-by-linking-css-to-top-of-php-file/ Share on other sites More sharing options...
requinix Posted December 23, 2019 Share Posted December 23, 2019 Whatever is on lines 6029, 1252, and 9 of those files, that cannot happen if there has been any output. You can't put that <link> where it is. And it probably shouldn't be where it is to begin with. Quote Link to comment https://forums.phpfreaks.com/topic/309740-getting-header-errors-by-linking-css-to-top-of-php-file/#findComment-1572855 Share on other sites More sharing options...
Jim R Posted December 24, 2019 Author Share Posted December 24, 2019 I figured the later, since there was an error. Back to the original question, maybe a little more specific. How to link the .css file without creating the header error? Quote Link to comment https://forums.phpfreaks.com/topic/309740-getting-header-errors-by-linking-css-to-top-of-php-file/#findComment-1572865 Share on other sites More sharing options...
maxxd Posted December 24, 2019 Share Posted December 24, 2019 (edited) 8 hours ago, Jim R said: How to link the .css file without creating the header error? This issue is that the php files have functions that throw an error if there's any output before those functions are run, right? Wouldn't then the solution be to put any output after those functions are run? *Hint* The CSS link in your HTML is output. Edited December 24, 2019 by maxxd Quote Link to comment https://forums.phpfreaks.com/topic/309740-getting-header-errors-by-linking-css-to-top-of-php-file/#findComment-1572870 Share on other sites More sharing options...
Jim R Posted December 24, 2019 Author Share Posted December 24, 2019 (edited) 44 minutes ago, maxxd said: This issue is that the php files have functions that throw an error if there's any output before those functions are run, right? Wouldn't then the solution be to put any output after those functions are run? *Hint* The CSS link in your HTML is output. I've tried this, but it doesn't change the result. I'm not really sure the order has much do with it, unless it's inside a loop or directly passing information along. I've echoed it within the function. I've put it after the ?>. I posted that above in the OP. No matter I've put it, the CSS works, but it creates header errors. I have other PHP files with CSS links above the <?php without these errors. I'm wondering if it's a function issue. What I'm working on at the moment, it worked fine until I tucked it into a function vs. using INCLUDE. I was surprised echoing it in the PHP code triggered the error. Edited December 24, 2019 by Jim R Quote Link to comment https://forums.phpfreaks.com/topic/309740-getting-header-errors-by-linking-css-to-top-of-php-file/#findComment-1572874 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.