PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
This is really strange actually, I'm not sure if my header is working. It does but it doesn't. It contains
<?php
session_start();
?>
<html>
<body>
<?php //connection junk:(
$con = mysql_connect("localhost:3306","colwell_user","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("colwell_db", $con);
//connection junk:)
echo "The header is here!!";
?>
and it connects to the database and identifies the code as html but won't display the echoed bit and I don't think it is starting the session. I include it on the required pages using
include("header.php");
Last edited by Colwell on Sun Nov 08, 2009 3:44 pm, edited 1 time in total.
session_start();
/* Html stuff */
$connection = mysql_connect("localhost", "user", "pass") or die(mysql_error());
$select_db = mysql_select_db("Database") or die(mysql_error());
echo "Works.";
Btw the second argument to mysql_select_db is optional. The code above works perfectly, it's basically the same as yours though a little cleaner. You can check if the session started or not by going to your browser's options and checking the cookies.(in FF's case is "remove individual cookies"). Search for localhost.