By murph on
I need to connect to a central db (a different one to the drupal site runs on), but when i insert the code before anything else (ie) in index.php, i get this error:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/*******/public_html/index.php:18) in /home/*******/public_html/includes/session.inc on line 10
I am literally just doing a connect and 1 query...
How can i avoid this error?
Comments
PHP headers in body?
Without looking into detail, this is what comes to mind.
PHP will not allow you to send certain information within the page content because that information is expected in the header (before the page code begins). If this is the cause of your error, then you can change your php.ini settings (if you own the server or if you can arm-twist the host) to allow caching of headers so that they do not only have to be sent before anything else
Just to check: I hope that the DB that you are trying to connect to allows connections from places other than itself (localhost) - a common security config. - although this normally gives a clear mySQL centric error
Please remember to postt he solution when you find it so that we can all learn from it.
-----
iDonny - Web Content Management System Design, Development. & CRM
Thx
The central db is on the same server, so thats no problem. I can look into the php.ini as i have a dedicated :)
built-in
Drupal has functions for dealing with other databases (http://api.drupal.org/api/4.7/group/database), so you could put your code into your template files, and all should be well.
- Corey
4.6
Hi, does this relate to 4.6 as well? I notice the link you gave refers to 4.7...
Sorry
Sorry, my mistake.
http://api.drupal.org/api/4.6/group/database
- Corey
Check the <?php tag at the
Check the
<?phptag at the start of index.php . Is it on the first line of the script?eg:
www.jws.co.za/we_install_modify_and_maintain_drupal_web_sites
yep
...it is :)
Error/mistake in index.php
I guess there's an error / mistake in the code, or the way you inserted it. Please post the resulting file index.php between <code> or <?php tags.
--
The Manual | Troubleshooting FAQ | Tips for posting | Make Backups! | Consider creating a Test site.
Here is my main index.php
I originally had the following code just after my php code in the main root index.php file above (and gave me error in 1st post)...but i realised that i was putting the html outside of the page itself by doing that, so i added the following code to the theme template instead...(page.tpl.php):
But that throws up a php error and stops the page loading...i guess you can't do that! (BTW i realise i shouldn't use mysql_query...i just want to get it to work first and then i'll replace with db_query :)
Guess
Guess you have whitespace / an error in the included file.
Not sure why you do it this way though. Even apart from not using the drupal db_functions, why not make a small module and use something like:
--
The Manual | Troubleshooting FAQ | Tips for posting | Make Backups! | Consider creating a Test site.