PHP - Headers Allready Sent - Newbie Problem
I got this code
<?php // Check if session is not registered, redirect back to main page. // Put this code in first line of web page. session_start(); if (!isset($_COOKIE["user"])) { header("location:login.php"); } include 'connection.php'; ?> <html> <head> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="HandheldFriendly" content="true"> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>EBS Service Skjema</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <?php include 'menu.php'; echo "<div class=\"bluebox\">"; if (isset($_GET['sted'])) { require_once('graph/jpgraph.php'); require_once('graph/jpgraph_line.php'); include 'connection.php'; // data $sql = mysqli_query($con, "SELECT * FROM diesel WHERE sted = '".$_GET['sted']."' GROUP BY WEEK(dato)"); $ydata = array(); $ydate = array(); while($row = mysqli_fetch_array($sql)) { $ydata[]=$row['krl']; $ydate[]=$row['dato']; } // Create the graph. These two calls are always required $graph = new Graph(600,250); $graph->SetScale('textlin'); $graph->title->Set('Pris Historikk'); $graph->xaxis->title->Set("Dato"); $graph->yaxis->title->Set("Pris"); $graph->xaxis->SetTickLabels($ydate); // Create the linear plot $lineplot=new LinePlot($ydata); $lineplot->SetColor('blue'); //$lineplot->SetFillColor('orange@0.5'); // Add the plot to the graph $graph->Add($lineplot); // Display the graph $graph->Stroke(); } else { echo "Du får ikke tilgang på denne måten."; } echo "</div>"; ?> </body> </html>but I get headers allready sent. I was earlier told to learn and code or make my apps different, but I'm totaly stuck cause I need to make a page with those stats. Not sure how I can make all my code be processed first then put into the html area. Is a function the way to go here ? Thanks for reading and hope someone can enlighten me Similar Tutorialshey guys, i need some help with my php/mysql iplogger. My code: <?php //finds out ip $ip = $_SERVER['REMOTE_ADDR']; //conects to the mysql server $connection = mysql_connect('localhost', 'root', ''); //sellects the database mysql_select_db('iplog', $connection); //looks for duplacute ips $dup = mysql_query("SELECT COUNT(number) FROM logged_ips WHERE ip_address = '$ip'",$connection); $count = mysql_result($dup, 0); //checks to see if there is a duplecate name if ($count == 0){ //inserts the ip in to the database $string = 'INSERT INTO `logged_ips` (`aid`, `ip_address`, `ip_visits`) VALUES (\'' . null . '\', \'' . $ip . '\', \'0\')'; mysql_query($string, $connection); }else{ //adds a visit to the database $string2 = "UPDATE `logged_ips` SET `ip_visits` = '++1' WHERE `ip_address` = $ip LIMIT 0,1"; mysql_query($string2, $connection); } //outputs the ip echo $ip; ?> error: Warning: mysql_result() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\randoms\logger\test.php on line 11 127.0.0.1 It also doesnt put anything in to the mysql database. Please help. Thanks jragon I'm adding a login page to my website. When I go to the login page, and try to login, I keep getting the error "Warning: Cannot modify header information - headers already sent by (output started at C:\Users\me\Desktop\xampp\htdocs\site\login.php:7) in C:\Users\me\Desktop\xampp\htdocs\site\login.php on line 38" and I don't know why. I've looked into it, and from what I can tell its something to do with white spaces, but I cant find them. <?php include "./dbconnect.php"; ?> <?php forum_connect(); ?> <?php if(isset($_COOKIE['ID_forum'])) { $username = $_COOKIE['ID_forum']; $pass = $_COOKIE['Key_forum']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else { header("Location: main.php"); } } } if (isset($_POST['submit'])) { if(!$_POST['username'] | !$_POST['pass']) { die(' <h2> You did not fill in all of the fields</h2> <p<a href="login.php">Return to login page</a> '); } if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error()); $check2 = mysql_num_rows($check); if ($check2 == 0) { die(' <h2> That user does not exist in our database.<br/> </h2> <p<a href="login.php">Return to login page</a> '); } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); if ($_POST['pass'] != $info['password']) { die(' <h2> Incorrect password, please try again</h2> <p<a href="login.php">Return to login page</a> '); } else { $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_forum, $_POST['username'], $hour); setcookie(Key_forum, $_POST['pass'], $hour); header("Location: main.php"); } } } else { ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <tr><td colspan=2><h1>Login</h1></td></tr> <tr><td><h2>Username:</h2></td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td><h2>Password:</h2></td><td> <input type="password" name="pass" maxlength="50"> </h2> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr> </table> </form> <?php } ?> Any help would be great Thanks Good day dear community. I need to build a function which parses the domain from a url. I have used various ways to parse html sources. But this one is is a bit tricky! See the target i want to parse - it has some invaild Markup: http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=644.0013008534253&SchulAdresseMapDO=194190 well what do you think - can i apply this code here <?php require_once('config.php'); // call config.php for db connection $filename = "url.txt"; // Include the txt file which have urls $each_line = file($filename); foreach($each_line as $line_num => $line) { $line = trim($line); $content = file_get_contents($line); //echo ($content)."<br>"; $pattern = '/<td>(.*?)<\/td>/si'; preg_match_all($pattern,$content,$matches); foreach ($matches[1] as $match) { $match = strip_tags($match); $match = trim($match); //var_dump($match); $sql = mysqli_query("insert into tablename(contents) values ('$match')"); //echo $match; } } ?> well i have to rework the parser-part of this script. I need to parse somway different - since i have other site here. Can anybody help me here to get a better regex - or a better way to parse this site ... Any and all help will be greatly apprecaited. regards db1 Hi all, I wrote a download script for some protected files a little while back. And on the whole, its works pretty well but occasionally, zip files will not completely download and will end up corrupted. It happens more with bigger files but that i'm guessing is due to the fact it takes longer to download them? I've searched intensively on Google for the past few days and implemented a few new ideas, which hasn't made a difference. Its annoying, in the fact you can try the same file a few times over and it'll download 8 out of 10 times no problem. I even added in the apachesentenv after a recommendation, as the rest of my site is gzip php'd. But that hasn't worked either. Part of the code as follows: apache_setenv('no-gzip', '1'); // if file exists and user access granted: // define the path to your download folder plus assign the file name $path .= $filename; // check that file exists and is readable if (file_exists($path) && is_readable($path)) { // get the file size and send the http headers $size = filesize($path); // required for IE, otherwise Content-disposition is ignored if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off'); //content type switch(strtolower(substr(strrchr($filename,'.'),1))) { case "pdf": $mime="application/pdf"; break; case "mp3": $mime="audio/x-mp3"; break; case "zip": $mime="application/zip"; break; case "rar": $mime="application/zip"; break; case "tar": $mime="application/zip"; break; case "sit": $mime="application/zip"; break; case "doc": $mime="application/msword"; break; case "xls": $mime="application/vnd.ms-excel"; break; case "ppt": $mime="application/vnd.ms-powerpoint"; break; case "gif": $mime="image/gif"; break; case "png": $mime="image/png"; break; case "jpeg":$mime="image/jpg"; break; case "jpg": $mime="image/jpg"; break; default: $mime="application/force-download"; } header("Cache-Control: public"); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Description: File Transfer"); header("Content-Type: " .$mime); header("Content-Disposition: attachment; filename=\"{$filename}\""); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($path)); readfile("$path"); if($logging == 1){ $status = "Granted"; include('logit.php'); } exit; } Live http Headers in Firefox displays the following upon clicking a download: http://www.website.com/filedownload.php?file=12 GET /filedownload.php?file=12 HTTP/1.1 Host: www.website.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729) Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-gb,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive Referer: http://www.website.com/downloads.php Cookie: __utma=100661891.2064943237.1286446219.1290502952.1290505322.70; __utmz=100661891.1290502952.69.8.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=lighthouse%20cjpro; __utmc=100661891; __utmb=100661891.43.10.1290505322; PHPSESSID=8aadcc17930b9e146f103f180f30f470 HTTP/1.1 200 OK Date: Tue, 23 Nov 2010 11:22:13 GMT Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.12 X-Powered-By: PHP/5.2.12 Expires: 0 Cache-Control: must-revalidate, post-check=0, pre-check=0 Pragma: public Content-Description: File Transfer Content-Disposition: attachment; filename="Version_5_Software.zip" Content-Transfer-Encoding: binary Content-Length: 62654423 Keep-Alive: timeout=2, max=100 Connection: Keep-Alive Content-Type: application/zip ---------------------------------------------------------- Are my headers wrong? or in the incorrect order? If not, any ideas? I'm a bit stumped! Thanks for taking the time to read my query. I have a strange problem with my headers in my mail function.
This is how it looks like in my code:
$to = 'someone@email.com'; $subject = 'Question from website'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html;charset=UTF-8' . "\r\n"; $headers .= 'From: ' . $email . "\r\n";When i send this i got the following message in my mailbox: Content-type: text/html;charset=UTF-8 From: web@somecompany.com Message-Id: <20140620142808.93D11A147@apache11.hostbasket.com> Date: Fri, 20 Jun 2014 16:28:08 +0200 (CEST) <html><head><title>Question from web</title><style type="text/css">body {background-color: #ffffff; font-family: verdana;}hr {color: #333;}div {width: 800px; margin: 25px auto;}h1 {color: #FFC421; font-size: 17px;}p {color: 2a2a2a; font-size: 15px;}</style></head><body><div><p><img src="imgs/tsc-logo.png"/></p><hr /><h2 style="color: #FFC421;">This customer asked a question</h2><br /><table style="width:800px"><tr><th style="width:250px"><h1>Customer:</h1></th><td></td></tr><tr><th>Name:</th><td>testname</td></tr><tr><th>Firstname:</th><td>testfirstname</td></tr><tr><th>E-mail:</th><td>testperson@company.be</td></tr><tr><th>Bericht:</th><td>This is a test</td></tr></table></div></body></html>I have allready found that the space between "Content-type" and "From" is not normal that indicates that a rule between MIME and Content-type is also present. But in my code there isn't any rule... How can this be possible? Thanks for the help! Hi, Im pretty new to php but im have trouble understanding why my script is doing this. Forgive me for silly mistakes! Im creating a login/register website and once the person has logged in they get a message saying "Successful login, welcome username!" The php checks against a database of users in an if statement to check if the password is correct and then prints out the message. But at the end of the message the echo is printing out a 1. I get that because the echo is in an if statement its return true or 1 but I cant get it to not print out the 1. code snippet is - if ($username==$dbusername&&$password==$dbpassword) { echo "Successful login, welcome!"; } Hope that makes sense. Thanks for the help. Neil I've been searching for a couple of days on google using keywords, trying to figure out why this form sends blank emails. I've found several different ways to write something like this, including what's below, but for the life of me I haven't figured it out. Can anyone help a brother out? <?php $email = $_REQUEST['email']; $message = $_REQUEST['date']; $message .= $_REQUEST['location']; $message .= $_REQUEST['quantitymodel']; mail( "name@email.com", "Email Contact Form", $message, "From: $email" ); header( "Location: thankyou.html" ); ?> I am learning PHP/MySQL and am modifying a tutorial to make a contact database. All I want is to be able to make a web page for each contact(record) and display one record on each webpage. I want to use the URL featu "http://www.mysite.com/script.php?=item1" type of thing Can any help me as I can't get it to work. I get no errors - it just doesnt display the info. I'm sure I cant be far off as I've only modified a working script ever so slightly. Code: [Select] mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); ?> <? $query="SELECT * FROM contacts WHERE id='$id'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Phone</font></th> <th><font face="Arial, Helvetica, sans-serif">Mobile</font></th> <th><font face="Arial, Helvetica, sans-serif">Fax</font></th> <th><font face="Arial, Helvetica, sans-serif">E-mail</font></th> <th><font face="Arial, Helvetica, sans-serif">Website</font></th> </tr> <? $i=0; while ($i < $num) { $first=mysql_result($result,$i,"first"); $last=mysql_result($result,$i,"last"); $phone=mysql_result($result,$i,"phone"); $mobile=mysql_result($result,$i,"mobile"); $fax=mysql_result($result,$i,"fax"); $email=mysql_result($result,$i,"email"); $web=mysql_result($result,$i,"web"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><? echo "$first $last"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$phone"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$mobile"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$fax"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><a href="mailto:<? echo "$email"; ?>">E-mail</a></font></td> <td><font face="Arial, Helvetica, sans-serif"><a href="<? echo "$web"; ?>">Website</a></font></td> </tr> <? ++$i; } echo "</table>"; ?> HI there, i'm using a flash and php form. The problem lie in the PHP I only seem to get the field titles (Name and telephone) coming through and not the data they contain. Could somebody tell me what i'm doing wrong? <?php $sendTo = "myemail@gmail.com"; $subject = "An enquiry"; $headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $message = "telephone: ".$strtelephone."\r\n"; $message .= "message: ".$strmessage."\r\n"; mail($sendTo, $subject, $message, $headers); ?> thank you Hello I've registered here last March and I'm just lurking around reading threads about php. Yesterday I've started to self studied php and today I've test some basic codes and I'm having difficulties on creating a table rows and columns. Here's my code. Code: [Select] <?php echo "<table width=\"100\" border=\"1\">"; $text = 'php'; $mac_var = 1; $mac_plus = 4; while ($mac_var < $mac_plus) { echo "<tr>"; { while ($mac_var < $mac_plus) { echo "<td>". $text . "</td>"; $mac_var++; } } echo "</tr>"; $mac_var++; } echo "</table>"; ?> what I want is, it should have 3 columns and 3 rows. But I'm getting only 3 columns and 1 row only. I wonder what is the problem? Sorry for my ignorance as I'm on the 1st basic phase of using php codes. TIA! hello, I'm a beginner when it comes to PHP: I'm working on a log in system but i keep on getting the same errors which makes my system unreliable. this is the function I'm trying to use: if(pg_numrows($q) == 1){ echo "<p>Someone took that username</p>"; include "signup.php"; exit; } --> I'm using a postgresql database this is the warning I keep on getting: Code: [Select] Warning: pg_numrows(): supplied argument is not a valid PostgreSQL result resource in /var/ftpdirs/512544/PHP/login/adduser.php on line 13 I have the same problem when I try to look if an username is taken or not... when people try to register this is my adduser.php file: <?php session_start(); include "connectie_db.php"; $User_name = $_POST['user_name'] ; $User_pass = $_POST['user_pass'] ; $User_pass2 = $_POST['user_pass2'] ; $checkUsername= "SELECT user_name from tovanu.users where user_name = '$User_name';"; $q = $db->exec($checkUsername); if(MDB2::isError($q)){ echo "code: ".$q->getUserInfo(); exit(); } if(pg_numrows($q) == 1){ echo "<p>Someone took that username</p>"; include "signup.php"; exit; } If(strlen($User_name > 32)){ echo "<p>The username is too long</p>"; include "signup.php"; exit; } if($User_pass != $User_pass2){ echo "<p>Both passwords must be the same</p>"; include "signup.php"; exit; } $password = md5($User_pass); $add = "INSERT INTO tovanu.users (user_name,user_pass,user_email,user_date,user_level,naam,adres,plaats,postcode) VALUES ('$User_name','$password','email',current_date,1,'jef','jonhstraat','maaseik','3687')"; $execute = $db->exec($add) ; if(MDB2::isError($execute)){ echo "code: ".$q->getUserInfo(); exit(); } $_SESSION['user'] = $username; include "index.php"; ?> any help would be appreciated!!!!!!!!!!! hello, I'm using this code: <?php if (isset($_REQUEST['email'])) { $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $code = $_REQUEST['code'] ; $from = $email; mail("email@email.com", "Winner request id: $name - code: $code", "From:" . $from); } $headers = "From:" . $from; header('Location: index.php?done'); ?> And I'm getting: Code: [Select] Warning: Cannot modify header information - headers already sent by (output started at /home/site/public_html/config.php:10) in /home/site/public_html/send.php on line 13 This worked before. Many thanks I am trying to do a page redirect using the header() function.
I am aware that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.
and also that reading code with include, or require, functions, or another file access function, can create spaces or empty lines that are output before header() is called. thus causing a redirect failure.
I have therefore used this output control function (ob_start(); ob_implicit_flush() right at the top of my page.
I am then creating the redirect like this as part of my login() function:
if($user_role == ADMIN_LEVEL || $user_role == EDITOR_LEVEL) { if (!headers_sent($filename, $linenum)) { return header("Location:http://mysite.com/dashboard.php"); exit; } else { echo "Headers already sent in $filename on line $linenum\n" . "Cannot redirect\n"; exit; } }Unfortunately I am still getting this error: Headers already sent in /home/steveoje/public_html/login.php on line 1 Cannot redirectAnd this is what I have at the top of the login.php page: <?php ob_start(); ob_implicit_flush(); require_once 'includes/config.php'; if(isset($_POST['submit'])) { login($_POST['username'], $_POST['password']); } require_once "includes/header.inc.php" ?> //other html contentSo why would the redirect fail in this instance? Thanks. Edited by terungwa, 28 September 2014 - 05:28 AM. Hi all, It's probably something obvious, but perhaps someone could explain to me what is going on here... I spent a lot of time this afternoon trying to fix what seemed to be a very odd problem, which involved an image being chucked out like so: Code: [Select] <?php header("Content-Type: image/png"); echo file_get_contents("http://www.example.com/some_image.png"); ?> Except the image was coming out as corrupted, ultimately because I had some white space before this snippet (foolish, I know). The reason it took me so long to diagnose the problem was because I wasn't getting PHP errors (even though they were switched on). As far as the script was concerned, it seems I wasn't sending anything before attempting to modify the headers. After solving the problem, I put the following little bit of code together, trying to force a header error... And yet I get nothing. It all works, and I get redirected, when I'm sure I shouldn't be. I've run this on a default install of XAMPP, and a configured CentOS server, and the same thing happens on both. If anyone can explain to me what is going on, I would be most appreciative! There are some inline comments which should help clarify what I mean. Code: [Select] <?php error_reporting(E_ALL); ini_set("display_errors","1"); ?> <p>Hello! The very existence of this text should really have resulted in the headers being sent... Shouldn't it?</p> <p>So I'd expect to see a "Headers already sent" message... Shouldn't I?</p> <?php // Headers sent? echo "<p>"; echo "Headers "; if(!headers_sent()) { echo "not "; // This "not" does echo out. } echo "sent.</p>"; // This WILL start a session (or at least, won't throw an error) session_start(); // This redirect WILL work, and you will never see the above messages. header("Location: redirect.php"); // What?! ?> Thanks! Dave Okay, I've read all the rules for Headers...still can't it to execute properly. At the bottom is my code. I basically want to check the database, see if the user is already registered, and redirect as appropriate (there is no HTML on my page, no info sent to the browser). My server doesn't send any error messages. All I get are white screens. Now, if I do the headers_sent()...it tells me that it's sent right after the initial connection with the database. The ONLY way I can get it to redirect, is if I put <?php header("location:index.php?msg=3"); ?> at hte very top, but then I can't evalute...which doesn't help me much. Here is the code (obviously, I have more...but it's sending headers in these lines) <?php $connection = mysql_connect("localhost","####","#####"); if (!$connection){ echo mysql_errno().": ".mysql_error()."<br/>"; exit; } if(!mysql_select_db("prixaurora")){ echo("Database not found<br>"); } My error: Code: [Select] Warning: Cannot modify header information - headers already sent by (output started at /www/zxq.net/w/e/b/webaskius/htdocs/index.php:7) in /www/zxq.net/w/e/b/webaskius/htdocs/functions.php on line 6 Now, I can't quite figure out why it's doing this. The section of code that is causing this problem is above any HTML tags, at the very beginning of the file. <?php include('functions.php'); ?> <link href="style.css" rel="stylesheet" type="TEXT/CSS"> <img src="logo.png" border="0"> <div id="maincontent"> As you can see, the functions that cause this error are at the VERY beginning of my file. This is where they are called within index.php: if(mysql_num_rows($query_verify_login) > 0) { create_cookie(10000, 'user', $username); redirect('index.php'); } else { echo 'Woops! You\'ve entered in the wrong username and password combination!'; } And finally, my functions: <?php //our cookie creator function function create_cookie($time, $name, $data) { setcookie($name, $data, time()+$time); } function redirect($url) { header('Location: '. $url .''); } function get_replies($id) { //set query to find posts that match our id $query_get_replies = mysql_query("SELECT * FROM replies WHERE to = {$id}"); return mysql_num_rows($query_get_replies); } ?> I have a form as a php include and it's giving me this error: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/altimusw/public_html/www.csmsolution.com/register.php:6) in /home/altimusw/public_html/www.csmsolution.com/core.php on line 17 Here is the main page that includes the php include: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>CSM Solution </title> <style type="text/css"> <!-- #Layer1 { position:absolute; left:100px; top:70px; width:800; height:62px; z-index:1; } .style1 { font-family: Arial, Helvetica, sans-serif; color: #535959; font-size: 12px; } --> </style> </head> <body> <div id="Layer1"> <table width="800" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="97"><img src="images/header.jpg" width="800" height="59" border="0" usemap="#Map" /><br /> <img src="images/navbar.jpg" width="800" height="38" border="0" usemap="#Map2" /> <map name="Map2" id="Map2"> <area shape="rect" coords="506,1,552,26" href="contact.php" /><area shape="rect" coords="459,1,502,26" href="form.php" /><area shape="rect" coords="396,-1,455,25" href="login.php" /> <area shape="rect" coords="357,0,393,26" href="index.php" /> </map> </td> </tr> <tr> <td><img src="images/welcome_img.jpg" width="131" height="21" /></td> </tr> <tr> <td><?php include("form.php"); ?></td> </tr> <tr> <td><img src="images/placeholderclouds_bottem.jpg" width="800" height="60" /></td> </tr> </table> </div> </body> </html> Here is the Core.php the error is referring to: <?php //CSM Solution Core. Rahul Parkar 2010 $_config = array(); $_config['db_type'] = "mysql"; $_config['db_server'] = "localhost"; $_config['db_username'] = "altimusw_csm"; $_config['db_password'] = ']17=rXh7tJ0~'; $_config['db_database'] = "altimusw_csm"; $_config['db_tbl_prefix'] = ''; $_config['user_table'] = "customers"; $_config['user_username'] = "username"; $_config['user_password'] = "password"; $_config['user_active'] = "approved"; $_config['user_role1'] = "prirole"; $_config['user_role2'] = "secrole"; $_config['pass_hash_func'] = "SHA1"; session_start(); function fetch_row($query) { build_connection($db); sql_exec($db, $query, $result); sql_fetchone($result, $row); finish_connection($db); return $row; } function build_connection(&$db) { global $_config; if ($_config['db_type'] == "mysql") { $db = mysql_connect($_config['db_server'], $_config['db_username'], $_config['db_password']) or die(mysql_error()); mysql_select_db($_config['db_database'], $db) or die(mysql_error()); } } function sql_exec(&$db, $query, &$result) { global $_config; if ($_config['db_type'] == "mysql") $result = mysql_query($query, $db) or die(mysql_error() . "/$query"); } function sql_fetchone(&$result, &$row) { global $_config; if ($_config['db_type'] == "mysql") { $row = mysql_fetch_assoc($result); @mysql_free_result($result); } } function sql_do(&$db, $query) { global $_config; sql_exec($db, $query, $noclue); finish_connection($db); } function finish_result(&$result) { global $_config; if ($_config['db_type'] == "mysql") @mysql_free_result($result); } function finish_connection(&$db) { global $_config; if ($_config['db_type'] == 'mysql') mysql_close($db); } function check_auth($username, $password) { global $_config; $row = fetch_row("SELECT `" . $_config['user_active'] . "`, `" . $_config['user_password'] . "`, " . $_config['pass_hash_func'] . "('" . $password . "') AS `passcheck`, `fname`, `lname` FROM `" . $_config['user_table'] . "` WHERE `" . $_config['user_username'] . "`='" . $username . "' LIMIT 1"); if (!$row[$_config['user_active']]) { return -1; } else { if ($row[$_config['user_active']] != 1) { return -2; } else if ($row[$_config['user_password']] == $row['passcheck']) { $_SESSION['username'] = $username; $_SESSION['fname'] = $row['fname']; $_SESSION['lname'] = $row['lname']; return 1; } else { return -1; } } } function load_access() { global $_config; if ($_SESSION['username']) { $row = fetch_row("SELECT `" . $_config['user_role1'] . "` FROM `" . $_config['user_table'] . "` WHERE `" . $_config['user_username'] . "`='" . $_SESSION['username'] . "' LIMIT 1"); $role1 = $row[$_config['user_role1']]; $_SESSION['role1'] = $role1; } else { return -1; } } function has_level() { for ($i = 0; $i < func_num_args(); $i++) { if (func_get_arg($i) == $_SESSION['role1']) { return 1; } } return 0; } ?> Hi I am getting the following php error that is on all my pages and it works fine on the other pages except index.php Code: [Select] <?php session_start(); include 'includes/conn_db.php'; if (isset($_POST['submit'])) { if (empty($_POST['userName'])) { $u = FALSE; $nouser = '<font color="red" size="2" face="arial">You forgot to enter your username!</font>'; } else { $u = $_POST['userName']; } if (empty($_POST['userPassword'])) { $p = FALSE; $nopass = '<font color="red" size="2" face="arial">You forgot to enter your password!</font>'; } else { $p = $_POST['userPassword']; } $errorMessage = $nouser . "<br>" . $nopass; if ($u && $p) { $query = "SELECT * from clients WHERE email = '$u' AND pword = '$p'"; $result = mysql_query($query, $conn); while ($row = mysql_fetch_assoc($result)){ if ($u == $row["email"] && $p == $row["pword"]) { $query_name = "SELECT * FROM clients WHERE email = '$u' AND pword = '$p'"; $result_name = @mysql_query ($query_name); while ($row_name = mysql_fetch_assoc($result_name)){ $client_id_out = $row_name['client_id']; $firstname_out = $row_name['firstname']; $lastname_out = $row_name['lastname']; // Create sessions $_SESSION['client_id'] = $client_id_out; $_SESSION['firstname'] = $firstname_out; $_SESSION['lastname'] = $lastname_out; ob_end_clean(); header ("Location: myaccount.php"); exit(); }} } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <link href="style.css" rel="stylesheet" type="text/css" /> <link href="layout.css" rel="stylesheet" type="text/css" /> <script src="js/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="js/cufon-yui.js" type="text/javascript"></script> <script src="js/cufon-replace.js" type="text/javascript"></script> <script src="js/Futura_Bk_BT_400.font.js" type="text/javascript"></script> <script src="js/Futura_XBlk_BT_400.font.js" type="text/javascript"></script> <!--[if lt IE 7]> <script type="text/javascript" src="js/ie_png.js"></script> <script type="text/javascript"> ie_png.fix('.png'); </script> <![endif]--> </head> Thanks Lional |