rascle Posted May 8, 2010 Share Posted May 8, 2010 Hi I am trying to create a php.ini file on my site under the public_html directory, but when I do so i get these errors on my site: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/b25rasc/public_html/index.php:4) in /home/b25rasc/public_html/headinfo.php on line 12 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/b25rasc/public_html/index.php:4) in /home/b25rasc/public_html/headinfo.php on line 12 Warning: mysql_query() [function.mysql-query]: Access denied for user 'b25rasc'@'localhost' (using password: NO) in /home/b25rasc/public_html/headinfo.php on line 64 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/b25rasc/public_html/headinfo.php on line 64 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/b25rasc/public_html/headinfo.php on line 65 I have not even put any code in the page yet and i was wondering how i was to fix / get rid of these error messages Thanks Rhys Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 8, 2010 Share Posted May 8, 2010 The first set of errors are because output_buffering is apparently turned on in the master php.ini, thereby allowing you to write code that is attempting to output something to the browser before the session_start() statement. The second set of errors mean that you did not have a connection to the database server at the time the mysql_query() statement was executed. Best guess is that your database connection code is using short open tags and is not actually being seen as php code. Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055127 Share on other sites More sharing options...
rascle Posted May 8, 2010 Author Share Posted May 8, 2010 Ok but how do i fix this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055129 Share on other sites More sharing options...
PFMaBiSmAd Posted May 8, 2010 Share Posted May 8, 2010 Both of those things were just guesses because you did not post any of the corresponding code. There are actually several other possible reasons for both of those errors, depending on what your code actually is doing from the start of the index.php file up through the lines where those errors are being reported. Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055132 Share on other sites More sharing options...
rascle Posted May 8, 2010 Author Share Posted May 8, 2010 Here is the code <?php session_start(); ?> <html> <head> <title>Title</title> <!-- EXTERNAL JAVASCRIPT LINKS --> <script type="text/javascript" src="/js/moreinfo.js"></script> <script type="text/javascript" src="/js/changelogin.js"></script> <script type="text/javascript" src="/js/hoveroverinfo.js"></script> <!-- END OF EXTERNAL JAVASCRIPT LINKS TAG --> <!-- FAVICON LINK --> <link rel="shortcut icon" href="/webimages/favicon.ico "> <!-- END OF FAVICON LINK --> <!-- STYLE SHEET --> <link rel="stylesheet" type="text/css" href="darkthemelayout.css" /> <!-- END OF STYLE SHEET TAG --> <!--COPY TO CLIPBOARD TAG --> <script language="JavaScript"> function ClipBoard() { holdtext.innerText = copytext.innerText; Copied = holdtext.createTextRange(); Copied.execCommand("RemoveFormat"); Copied.execCommand("Copy"); } </script> <!-- END OF COPY TO CLIPBOARD TAG --> <!-- HIDE PATIENT TEXT TAG --> <script type="text/javascript"> function complete(){ document.getElementById("warning").style.display="none"; } </script> <!-- END OF HIDE PATIENT TEXT TAG --> <!-- GET USER INFO --> <?php if (isset($_COOKIE["rloginforeveruser"])){ $_SESSION['username'] = $_COOKIE["rloginforeveruser"]; } if (isset($_COOKIE["rloginforeverpass"])){ $_SESSION['password'] = $_COOKIE["rloginforeverpass"]; } $logged = MYSQL_QUERY("SELECT * FROM `members` WHERE `username` = '$_SESSION[username]' AND `password` = '$_SESSION[password]'"); $logged = mysql_fetch_array($logged); ?> <!-- END OF USER INFO TAG --> </head> </html> Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055139 Share on other sites More sharing options...
rascle Posted May 8, 2010 Author Share Posted May 8, 2010 Any Ideas? Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055158 Share on other sites More sharing options...
roopurt18 Posted May 8, 2010 Share Posted May 8, 2010 Do you have white space before the opening PHP tag? You have a lot of pointless comments in your markup. What's the point of a comment saying here's a favicon link or here are my JavaScript links? That stuff is self-documenting. That's not what comments are for. And are you seriously storing user passwords unprotected in the cookie's on their machine? And then not sanitizing this input before feeding it to the database? Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055166 Share on other sites More sharing options...
PFMaBiSmAd Posted May 8, 2010 Share Posted May 8, 2010 The posted code does not correspond to the error messages you posted (line number's don't match, even if we were to assume there were several lines before the first <?php tag), nor does it have any code to make a connection to the database. The code you posted probably never worked, regardless of you putting or not putting a local php.ini on your site. To expand on the errors - The first two errors are because you are outputting something to the browser before the session_start() statement. The error message you are getting for whatever your real code is, tells you where that output is occurring at. You must find and fix whatever is causing that output or you must move the session_start() statement so that it comes before any output is sent to the browser. The second two errors are because you don't have any connection to the database server (at all) in your code. We cannot really help you further, because that is either not your real code or it is not all of your actual code that corresponds to the errors you are getting. Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055190 Share on other sites More sharing options...
roopurt18 Posted May 8, 2010 Share Posted May 8, 2010 The code you posted probably never worked, regardless of you putting or not putting a local php.ini on your site. I was tempted to say the same but held my tongue because a local php.ini could potentially cause a working script to break. Just think about the prepend_script (or whatever it's called) setting. Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055208 Share on other sites More sharing options...
rascle Posted May 9, 2010 Author Share Posted May 9, 2010 The code does what i want it to do without the php.ini file, but with it, it gives those error messages. Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055336 Share on other sites More sharing options...
PFMaBiSmAd Posted May 9, 2010 Share Posted May 9, 2010 What exactly are you putting into the local php.ini and why are you trying to use a local php.ini? Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055348 Share on other sites More sharing options...
rascle Posted May 9, 2010 Author Share Posted May 9, 2010 The head info page is: <?php session_start(); ?> <html> <head> <title>RascleRhys.com - <?php echo $pagename; ?> - Free Online Games </title> <!-- META CODE --> <meta name="description" content="Free Online Games including Action,Arcade,Puzzle,Racing and Sport." /> <meta name="keywords" content="Games, Flash games,online games,forum,action,arcade,puzzle,racing,sport,action games,arcade games, racing games, puzzle games, sport games" /> <!-- END OF META CODE TAG --> <!-- EXTERNAL JAVASCRIPT LINKS --> <script type="text/javascript" src="/js/moreinfo.js"></script> <script type="text/javascript" src="/js/changelogin.js"></script> <script type="text/javascript" src="/js/hoveroverinfo.js"></script> <!-- END OF EXTERNAL JAVASCRIPT LINKS TAG --> <!-- FAVICON LINK --> <link rel="shortcut icon" href="/webimages/favicon.ico "> <!-- END OF FAVICON LINK --> <!-- STYLE SHEET --> <link rel="stylesheet" type="text/css" href="darkthemelayout.css" /> <!-- END OF STYLE SHEET TAG --> <!--COPY TO CLIPBOARD TAG --> <script language="JavaScript"> function ClipBoard() { holdtext.innerText = copytext.innerText; Copied = holdtext.createTextRange(); Copied.execCommand("RemoveFormat"); Copied.execCommand("Copy"); } </script> <!-- END OF COPY TO CLIPBOARD TAG --> <!-- HIDE PATIENT TEXT TAG --> <script type="text/javascript"> function complete(){ document.getElementById("warning").style.display="none"; } </script> <!-- END OF HIDE PATIENT TEXT TAG --> <!-- GET USER INFO --> <?php if (isset($_COOKIE["rloginforeveruser"])){ $_SESSION['username'] = $_COOKIE["rloginforeveruser"]; } if (isset($_COOKIE["rloginforeverpass"])){ $_SESSION['password'] = $_COOKIE["rloginforeverpass"]; } $logged = MYSQL_QUERY("SELECT * FROM `members` WHERE `username` = '$_SESSION[username]' AND `password` = '$_SESSION[password]'"); $logged = mysql_fetch_array($logged); ?> <!-- END OF USER INFO TAG --> </head> </html> and the mysql connect code is on banner.php: <?php $connect = mysql_connect("localhost","b25rasc_b25rasc","rasclewelsh"); mysql_select_db(b25rasc_userlogin) or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055349 Share on other sites More sharing options...
rascle Posted May 9, 2010 Author Share Posted May 9, 2010 I want to change the file_upload settings using: which my server host provided me with. And i am putting using a local php.ini since that is also what they said to do. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055351 Share on other sites More sharing options...
rascle Posted May 9, 2010 Author Share Posted May 9, 2010 sorry the code is: file_uploads = On upload_max_filesize = 10M post_max_size = 10M max_execution_time = 600 Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055352 Share on other sites More sharing options...
PFMaBiSmAd Posted May 9, 2010 Share Posted May 9, 2010 When you put a local php.ini it is apparently only setting the values from the local php.ini and using php's default values for everything else. You will either need to make a local php.ini that has all the necessary values or you will need to correct your code so that it works regardless of the settings. Since you have not shown the index.php code that is including your other code, it is not clear what php setting is causing your database connect code to not work (I previously mentioned which setting is related to the first two error messages.) What are the current error messages? Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055360 Share on other sites More sharing options...
rascle Posted May 9, 2010 Author Share Posted May 9, 2010 Current Error Messages: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/b25rasc/public_html/index.php:4) in /home/b25rasc/public_html/headinfo.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/b25rasc/public_html/index.php:4) in /home/b25rasc/public_html/headinfo.php on line 2 Warning: mysql_query() [function.mysql-query]: Access denied for user 'b25rasc'@'localhost' (using password: NO) in /home/b25rasc/public_html/headinfo.php on line 54 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/b25rasc/public_html/headinfo.php on line 54 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/b25rasc/public_html/headinfo.php on line 55 and index.php mysql connect: <?php $connect = mysql_connect("localhost","b25rasc_b25rasc","rasclewelsh"); mysql_select_db(b25rasc_userlogin) or die(mysql_error()); $data = MYSQL_QUERY("SELECT * FROM `data`"); $data = mysql_fetch_array($data); ?> Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055365 Share on other sites More sharing options...
rascle Posted May 9, 2010 Author Share Posted May 9, 2010 When you put a local php.ini it is apparently only setting the values from the local php.ini and using php's default values for everything else. You will either need to make a local php.ini that has all the necessary values or you will need to correct your code so that it works regardless of the settings. Since you have not shown the index.php code that is including your other code, it is not clear what php setting is causing your database connect code to not work (I previously mentioned which setting is related to the first two error messages.) How do i create a local php.ini, i have been looking on my phpinfo and it says that my php.ini file is under my /usr/local page but i cannot find this directory? Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055373 Share on other sites More sharing options...
rascle Posted May 9, 2010 Author Share Posted May 9, 2010 I contacted my hoster and they managed to sort it thanks. Quote Link to comment https://forums.phpfreaks.com/topic/201118-phpini-file/#findComment-1055438 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.