Jump to content

website won't access mysql


jagguy

Recommended Posts

Hi,

 

I have ported my website to this address and used the same login /password for mysql as previous websites on the same host.

 

I am getting a session error which you can't see unless you highlight.

 

It works on my pc but what do i do here?

 

I access my sql with a script like this

..

//connect to the db

        $link = mysql_connect("localhost", "jagguy_root", "")or die("Could not connect: " . mysql_error());

        // select our database

        mysql_select_db("jagguy_formdata") or die(mysql_error());

..

 

 

http://jagguy.ej.am/school/test/home.php

Link to comment
https://forums.phpfreaks.com/topic/59020-website-wont-access-mysql/
Share on other sites

Well highlight it and tell us what it is!

 

I'll save you the trouble:

 

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/jagguy/public_html/school/test/home.php:10) in /home/jagguy/public_html/school/test/home.php on line 17

 

It's nothing to do with the database. It's all to do with output sent to the browser before setting the cookie.

There is no cookie but just sessions.

It works fine on my PC so how can i fix this ?

 

eg

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html >

<head>

<title>Untitled Document</title>

<link rel="stylesheet" type="text/css" href="mystyle2.css"/>

 

 

</head>

 

<body >  <?php include("navigation2.html"); ?>

 

 

 

 

 

<?php

session_start();....

I am just trying to get every page password protected so i use sessions. If someone types in an url without logging in they get redirected.

Now what i did do was simple set the

session_start() at the start of every script then send html headers.

 

I use

<?php session_start(); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html >....

 

What is ob_start?

 

q)Also with my footer I get

 

Notice: Use of undefined constant HTTP_HOST - assumed 'HTTP_HOST' in /home/jagguy/public_html/school/test/footer.php on line 5

 

 

  $urlh = getenv(HTTP_HOST);

  $url = $urlh;

 

What is wrong with this as I don't get an error here on my pc?

 

  $urlh = getenv(HTTP_HOST);

  $url = $urlh;

 

What is wrong with this as I don't get an error here on my pc?

 

 

Different php version, different error reporting levels, different error display settings ... who know why.

 

$urlh = $_SERVER['HTTP_HOST']

try using ob_start() it allows you to send headers throughout the page and for the HTTP_HOST it should be $_SERVER['HTTP_HOST']

hi,

 

 

If I place ob_start at top of each page then is that all I have to do as well as inlclude the session vars as per normal? I checked the function and it looks more involved than that.

 

What is wrong with setting the session at line 1 then add html/php header  stuff?

I am getting this error the line under I access the session variable. I don't get this error on my pc.

 

Notice: Undefined index: all in /home/jagguy/public_html/school/test/teacherupload.php on line 78

 

<?php ob_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="mystyle2.css"/>
<script type="text/javascript">
function validate()
{


var fname=document.getElementById("file1").value;

submitOK="true"

if (fname.length ==0 || ( !fname.match(/\.txt/) && !fname.match(/\.TXT/) &&
     !fname.match(/\.doc/) && !fname.match(/\.DOC/) && !fname.match(/\.xls/) && !fname.match(/\.XLS/)
   && !fname.match(/\.zip/) && !fname.match(/\.ZIP/) && !fname.match(/\.exe/) && !fname.match(/\.EXE/)
     && !fname.match(/\.ppt/)  && !fname.match(/\.PPT/) && !fname.match(/\.jpg/) && !fname.match(/\.gif/)
     && !fname.match(/\.png/)

    ))
{
alert("The name must not be blank and must have lower case .txt, .doc or .xls .ppt .exe .zip .png .jpg .gif filename ending")
submitOK="false"
}


if (submitOK=="false")
{
return false
}
}
</script>

</head>

<body>  <?php include("navigation2.html"); ?>

<div id='tablewrap'>
<span style='color:#d4cd5c'>
<h3> Create a Download</h3>
This form allows you to upload a file and make it available for students to download<br>

<form enctype="multipart/form-data" action="teacherupload2.php" method="post" onsubmit="return validate()">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" >
Choose a file to upload: <input name="uploadedfile" type="file" id="file1"><br >
<input type="submit" value="Click to Upload File " >
</form>
<?php
session_start();
// echo $_SESSION['uid'] ;

if (isset($_SESSION['HTTP_USER_AGENT']))
{
    if ($_SESSION['HTTP_USER_AGENT'] != md5($_SERVER['HTTP_USER_AGENT']))
    {
        /* Prompt for password */
        session_destroy();
        header( "Location: http://localhost/school/test/login.php" );
        exit;

    }
}
else
{
    $_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']);
}
if (!isset($_SESSION['uid']))
  {
     header( "Location: http://localhost/school/test/login.php" );
     exit;
   }

   //view uploaded files
include("dbconnect.php");
$uid=$_SESSION['uid'];
$viewall= $_POST['all'];

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.