Jump to content

php.ini File


rascle

Recommended Posts

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

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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());  
?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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);  

?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.