jaylimo Posted August 1, 2004 Posted August 1, 2004 Hello! looking for some "urgent help". Php is so easy to set up Have it installed on my local dev machine for 5 months now. Thought i'd test the pilot app on TCH. Well lots of unpleasant surprises. I'm using the SmartTemplate engine or Smarty (nothing more than a folder location)..... lots of errors e.g. Warning: session_destroy(): Trying to destroy uninitialized session in x.php on line 8 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at libs.inc.php:25) in x.php on line 9 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at libs.inc.php:25) in x.php on line 9 Warning: Cannot modify header information - headers already sent by (output started at libs.inc.php:25) in x.php on line 35 Please Help! The setup on my dev machine was very easy and i did not need to do any changes with the php.ini file at all. Thanks, Jay Quote
vengavenga Posted August 1, 2004 Posted August 1, 2004 Hi Jay, I'm no expert on this, so I've no doubt someone more knowledgeable than I will come along shortly and either confirm what I'm saying or give you a "real" answer, but I think you'll find that PHP is already "setup" on your hosting account - there's no need for you to mess around with any of that side of things (php.ini files etc) as TCH take care of all that for you It sounds like you're in a hurry to get this sorted out though, so it might be best if you submit a ticket (there's a link to the Help Desk at the top left of this page) Hope that helps Ali. Quote
borfast Posted August 1, 2004 Posted August 1, 2004 (edited) First of all, welcome to the family forums, Jay! Second, I'm moving this to a more appropriate forum. Now, about your question... (By the way, Ali, I believe Jay meant "configure", not "installing" but yes, PHP is already installed on every server ) I'm using smarty on many of my own sites and never had any problems. Besides, those errors you're getting have nothing to do with Smarty, they're session related. Actually, those are not "errors", that's one single warning, which is causing the other three. Basically, there's an error in your session code, which is causing PHP to output that first warning and after that, it cannot send any HTTP headers, because HTTP headers need to be sent *before* any other output, so PHP spits out those three other warnings. If you get rid of the first warning (the session warning), you'll get rid of the other three - assuming there's nothing else wrong with your code after the session stuff. You have to keep in mind that the configuration of your machine and TCH's servers can be very different. You should take a look at the output of the phpinfo() function both on your local machine and the TCH server and compare them. Lastly, it would be easier for someone to help you if you could show us the piece of the code that's causing the warning. I'd say you're not calling session_start() before calling session_destroy() (typicall error, which would result in the output you're getting) but I can't be sure without looking at the code. Edited August 1, 2004 by TCH-Raul Quote
vengavenga Posted August 1, 2004 Posted August 1, 2004 My lack of knowledge is a dangerous thing Ali. Quote
jaylimo Posted August 1, 2004 Author Posted August 1, 2004 Raul, Will look into it, Something that will save me a lot of time as well if you can answer it. how do i set up the database connection user and password for the mysql database e.g. dbgpx that i have set up i have set up user a with password b with all priveleges for dbgpx. the user gets setup as a_a ( being the login which i use for CPanel) Now what is the username and password that i should use from php.... ihave tried all combos.... please advise Quote
borfast Posted August 1, 2004 Posted August 1, 2004 Jay, you're probably using the wrong database name, not the wrong user/pass. The database name is in the form <cpanel username>_<database name>. So if you created your database as "dbgpx" and your cpanel username is a_a, the database name you'll need to use when connecting to it from PHP is "a_a_dbgpx". Try it and let us know if it works Quote
jaylimo Posted August 1, 2004 Author Posted August 1, 2004 Raul, Thanks for the info: Have the site sort of partially working Here's something that is causing it to break.... my $_SESSION[pid] are not working...... anything that you need to turn on at the tCH end?? googled for info on this and this is the core of the problem now, any workarounds? Thanks, Jay Quote
jaylimo Posted August 1, 2004 Author Posted August 1, 2004 Raul, Take a look Can you set register_globals=on in php.ini ??? Thanks, Jay http://www.php-forum.com/p/viewtopic.php?t=1483 would like to address a problem that I have seen time and time again by newcomers that are posting for answers to why thier form does not post. register_globals=on is your enemy. Starting with PHP version 4.2 the php.ini is set to off. What this means is that any book or tutorial that has been published before 4.2 was released is probably telling you a big lie on how to handle POST, GET, SYSTEM, SESSION, COOKIES. I know this is the case if you are using the book published by sams titles "PHP and MySQL Web Development" I know. I own the book. It does give you a good overview of the php/mysql language, but some of it is incorrect. There is a blurb in there stating that the way they are teaching you is wrong. They even reference to you that by turning register_globals=off in the php.ini is the correct way. Why they did that I don't know. The point of my post is to be a possible reference to those wondering why they do not see thier variables after they hit the submit button. I will try and give some examples so that you will overcome your teachings of miss-information. 1. Sessions Sessions are your friend. They allow you to preserve certain data across subsequent accesses. Which means you can transfer information from page to page. How this works is by using the session_start() function that is built into PHP. What this does is create a unique id that is sent to the clients computer in either the form of a cookie or through the URL. Please note that there has been talk of removing the method to set it from the URL. If you are somewhat firmilar with sessions and are using session_register() this is not the best way to do it. Not only is there more code involved it also may confuse the living s@!$% out of you. There is a much easier way to do this. Introduced into PHP 4.1 are Predefined Variables. These are a set of reserved variables that have made working with sessions and other functions as easy as simple arrays. Using this method to set a session variable all you have to do is use the $_SESSION super global. Code: <?php session_start(); $_SESSION['new_variable'] = 1; ?> This will create a session variable that will remain untill you use session_destroy(), the user closes the browser, or the time you have specified times out. The information that is set within the $_SESSION[] can be accessed from page to page. This is good when using a shopping cart, restricting access to different pages, or even making sure that your webpage counter doesn't keep increasing when they hit the refresh button. Quote
jaylimo Posted August 1, 2004 Author Posted August 1, 2004 ok got it running. after some tweaks Thanks, and ignore earlier posts Quote
TCH-Rick Posted August 1, 2004 Posted August 1, 2004 We cannot modify php.ini for an individual account. This configuration file contains the server-wide settiings and register_globals is set to on. You can try adding 'php_flag register_globals off' to your .htaccess file to turn it off for your scripts if you wish. Quote
borfast Posted August 1, 2004 Posted August 1, 2004 Jay, as Rick said, the PHP configuration can't be changed for an individual account. But you shouldn't need register_globals to be ON for the $_SESSION variable to work, because it's a "super global", as they call it in the manual, meaning it's always accessible from anywhere in your script. Besides, register_globals is already turned on on TCH's servers Quote
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.