Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-24-2006, 04:09 PM Unknown Error
pipers dragon's Avatar
Extreme Talker

Posts: 190
Trades: 0
Im thinking this is an SQL query error or something ,but I really have no idea because I dont know much about the program. In this script Im trying to learn, there is the fallowing code to make a table, and I dont know what is going wrong.

PHP Code:
<?php

require 'db_connect.php';

$table "CREATE TABLE users (
id int(10) DEFAULT '0' NOT NULL auto_increment, 
username varchar(40),
password varchar(50), 
regdate varchar(20),
email varchar(100),
website varchar(150),
location varchar(150),
show_email int(2) DEFAULT '0',
last_login varchar(20),
PRIMARY KEY(id))"
;

$create $db_object->query($table);    //perform query

if(DB::isError($create)) {
    die(
$create->getMessage());
} else {
    echo 
'Table created successfully.';

}

$db_object->disconnect();

?>
The error Im getting is this:
Quote:
DB Error: unknown error
Does anyone know what could be causing that problem?
pipers dragon is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-24-2006, 04:44 PM Re: Unknown Error
Defies a Status

Posts: 1,606
Trades: 0
Looks like an install tables script.

You have to create the DB and plug the DB name, username and password into the db_connect.php' file before you can run the install script.

There should be a readme or install.html file that came with the script that will explain all this to you.

Looks like a links script. Which one?
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 03-24-2006, 04:58 PM Re: Unknown Error
pipers dragon's Avatar
Extreme Talker

Posts: 190
Trades: 0
It is actually for a login script. I have a db_connect.php file which has all the htings you said:
PHP Code:
<?php


set_include_path
('/home/resist/public_html/PEAR' PATH_SEPARATOR get_include_path());

require_once(
'DB.php');



$db_engine 'mysql';
$db_user 'resist_data';
$db_pass 'xxxxxx';
$db_host 'localhost';
$db_name 'resist_login';

$datasource $db_engine.'://'.
              
$db_user.':'.
              
$db_pass.'@'.
               
$db_host.'/'.
                
$db_name;


$db_object DB::connect($datasourceTRUE);


if(
DB::isError($db_object)) {
    die(
$db_object->getMessage());
}

$db_object->setFetchMode(DB_FETCHMODE_ASSOC);

include(
'check_login.php');

?>
Do you think Im having a MySQL error connecting?
pipers dragon is offline
Reply With Quote
View Public Profile
 
Old 03-24-2006, 08:13 PM Re: Unknown Error
pipers dragon's Avatar
Extreme Talker

Posts: 190
Trades: 0
okay, I removed the DEFAULT values and it worked, but now Im having a new problem. When trying to use the login script, I get a new error..

PHP Code:
<?
require 'login/db_connect.php';

if (
$logged_in == 1) {
   echo 
'&nbsp;&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;<a href="/tagbox2/" alt="Staff Only Chat" target="main">Staff Chat</a><br>&nbsp;&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;<a href="futureplans.php" alt="Clan Plans" target="main">Clan Plans</a><br>';
} else {
   echo 
'<i>Only staff Can view the following pages. Sorry.<BR><BR> Staff, Login <a href="/login/login.php target="main"></i>';
}
?>
But I get this error:
Quote:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/resist/public_html/elite/index.php:4) in /home/resist/public_html/elite/login/check_login.php on line 5
In check login.php, I have the following code:
PHP Code:
<?php

// next line is line 5
session_start();

if (!isset(
$_SESSION['username']) || !isset($_SESSION['password'])) {
    
$logged_in 0;
    return;
} else {

    if(!
get_magic_quotes_gpc()) {
        
$_SESSION['username'] = addslashes($_SESSION['username']);
    }


    
$pass $db_object->query("SELECT password FROM users WHERE username = '".$_SESSION['username']."'");

    if(
DB::isError($pass) || $pass->numRows() != 1) {
        
$logged_in 0;
        unset(
$_SESSION['username']);
        unset(
$_SESSION['password']);
    }

    
$db_pass $pass->fetchRow();

    
$db_pass['password'] = stripslashes($db_pass['password']);
    
$_SESSION['password'] = stripslashes($_SESSION['password']);


    if(
$_SESSION['password'] == $db_pass['password']) { 
        
$logged_in 1// they have correct info
    
} else {
        
$logged_in 0;
        unset(
$_SESSION['username']);
        unset(
$_SESSION['password']);
    }
}


unset(
$db_pass['password']);

$_SESSION['username'] = stripslashes($_SESSION['username']);

?>
What went wrong?

Last edited by pipers dragon; 03-24-2006 at 08:15 PM..
pipers dragon is offline
Reply With Quote
View Public Profile
 
Old 03-24-2006, 08:43 PM Re: Unknown Error
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
The problem now is in the index.php file, it's sending output to the browser when it shouldn't be. Can you post your index.php file?
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 03-24-2006, 08:55 PM Re: Unknown Error
pipers dragon's Avatar
Extreme Talker

Posts: 190
Trades: 0
Its very long... here it is. It is in another directory on my site though, the login directory is a sub-directory to this main one.

Code:
<html>
<head>
<title>The Elite - Hogwarts Live Clan</title>
<style type="text/css">
body {
	background: #000000 url(TEbg.jpg);
	margin: 0px;
    background-repeat: repeat-y;
    font-family: verdana, arial, helvetica, sans-serif;
    font-size: 12px;
    line-height: 12px;
    color: #092816;
    margin: 0;
}	

U {
  border-bottom: #24253A dashed 2px;
  text-decoration: none;
}

#name {
postion: absolute; 
top: 470px; 
left: 265px;
}

H1 {
  font: bold 11px arial; 
  color: #092816; 
  background: #E4D5B4; 
  border-bottom: solid 1px #E9D8AA;
  margin: 0px;
  margin-bottom: 1px;
  text-align: left;
  letter-spacing: 2px;
}
H2 {
  font: normal 9px trebuchet ms; 
  color: #AB8F58; 
  background: #E9DCBF; 
  border-bottom: solid 1px #E9D8AA;
  margin: 0px;
  margin-bottom: 1px;
  text-align: right;
  letter-spacing: 2px;
}
H3 {
  font: bold 10px arial; 
  color: #AB8F58; 
  background: #E4D5B4; 
  border-bottom: solid 1px #E9D8AA;
  margin: 0px;
  margin-bottom: 1px;
  text-align: left;
  letter-spacing: 2px;
}

.tf1link {
  color: #333F4B; 
  font-weight:bold;
}

.hover2 {
  color: #627289;
  cursor: crosshair;
  border-top-width: 1px;
  border-bottom-width: 1px;
  border-color: #627289;
  text-decoration: underline;
}


a:Link, a:Visited, a:Active {  
  color: #1B491B; 
  font-weight:bold;
  border-bottom: #092816 dashed 2px;
  line-height: 13px;
}

a:hover {
  color: #000000;
  cursor: crosshair;
  border-bottom: #23512D dashed 2px;
  text-decoration: underline;
}

td {
  line-height: 12px;
  margin: 0px;
}
	
.tf
{color:#072813;
font-family:arial;
font-size:8pt;
text-align:justify;
background:#234E33;}

.tf2
{color:#072813;
font-family:arial;
font-size:8pt;
text-align:justify;
background:#234E33;

.tf3
{color:#627289;
font-family:arial;
font-size: 8pt;
text-align:justify;
background:transparent;
}
		
#contentheader h1 {
  font-size:14px;
  padding:10px;
  margin:0px;
}
	
#contentright p { 
  font-size:10px;
}

a:Link, a:Visited, a:Active {  
  color: #1B491B; 
  font-weight:bold;
  border-bottom: #092816 dashed 2px;
}

a:hover {
  color: #333F4B;
  cursor: crosshair;
  border-top-width: 1px;
  border-bottom-width: 1px;
  border-color: #627289;
  text-decoration: underline;
}

.button {
  border: 1px solid #000;
}

.text {
  border: 1px solid #627289;
  color: #627289;
  background-color: transparent;
  font-family: verdana, arial, helvetica, sans-serif;
  font-size: 8pt;
}

textarea, input {color:#627289;
font-family:arial;
font-size:8pt;
text-align:justify;
background:transparent;
}

table.calendar {
  margin-left: 10px;
}

.hfhfhf {color:#333F4B;
font-family:arial;
font-size:8pt;
text-align:justify;
background:#627289;}

h5 {color:#333F4B;
font-family:arial;
font-size:8pt;
text-align:justify;
background-color:#627289;
}
</style>


</head>
<body>
<div>
<img src="TElayout1.jpg" alt="The Elite" style="postion:absolute; top:0; left:0;">
</div>
<iframe name="main" src="home.php" scrolling="no" allowtransparency="true" frameborder="no" width="378px" height="2000px" style="position: absolute; top: 470; left: 265;"></iframe>


<!-- begin side bar -->
<div style="position:absolute; top:470; left:26; width:185px;">
<table width="193px" class="tf" style="postion: absolute; top: 475px; left: 30px;">
<tr height="0px" align="right" class="tf">
<td align="right" width="100%" class="tf">
<b>T.h.e. C.l.a.n.</b>
</tr></td>
</table><p>
<div align="justify">&nbsp;&nbsp;&nbsp;&nbsp;This website is dedicated to <u>The Elite</u> clan on Hogwarts Live, run by <b>MickeyMantle</b> and <b>Witchywoman</b>.Use the links below to navigate to other parts of the site.


<table width="193px" class="tf" style="postion: absolute; top: 475px; left: 30px;">
<tr height="0px" align="right" class="tf">
<td align="right" width="100%" class="tf">
<b>The Leaders</b>
</tr></td>
</table><p>
<font color="white">
<b><u>Leaders</u></font><p>
MickeyMantle<BR>
Witchy Woman<BR>
Tomkedavara<BR><BR>

<font color="FFFF00"><u>Officers</u></font><p>
MarissaPotter<BR>
Glady<BR>
Kalypso<BR>
Chainer<BR>
EmmaDaBest<BR>
JenniPotter<BR>
nOObKillerX<BR>
RikuSaotome<BR>
EliteLeader</b>
<table width="193px" class="tf" style="postion: absolute; top: 475px; left: 30px;">
<tr height="0px" align="right" class="tf">
<td align="right" width="100%" class="tf">
<b>Clan Information</b>
</tr></td>
</table><p>
&nbsp;&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;<a href="rules.php" target="main">Clan Rules</a><BR>
&nbsp;&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;<a href="contests.php" target="main">Clan Contests</a><BR>
&nbsp;&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;<a href="money.php" target="main">Gold and Gems</a><BR>
&nbsp;&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;<a href="promo.php" target="main">Promotions</a> <font color="red"><b>NEW!</b></font><BR>
&nbsp;&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;<a href="banned.php" target="main">Banned Players</a><BR>
&nbsp;&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;<a href="staff.php" target="main">Clan Staff</a> <BR><BR>

&nbsp;&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;<a href="tagbox/index.php" target="main">Chat</a> <BR><BR>

<table width="193px" class="tf" style="postion: absolute; top: 475px; left: 30px;">
<tr height="0px" align="right" class="tf">
<td align="right" width="100%" class="tf">
<b>Staff Only</b>
</tr></td>
</table><p>

<?
require 'login/db_connect.php';

if ($logged_in == 1) {
   echo '&nbsp;&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;<a href="/tagbox2/" alt="Staff Only Chat" target="main">Staff Chat</a><br>&nbsp;&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;<a href="futureplans.php" alt="Clan Plans" target="main">Clan Plans</a><br>';
} else {
   echo '<i>Only staff Can view the following pages. Sorry.<BR><BR> Staff, Login <a href="/login/login.php target="main"></i>';
}
?> 
</div> 
</body>
</html>
pipers dragon is offline
Reply With Quote
View Public Profile
 
Old 03-25-2006, 05:01 AM Re: Unknown Error
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
really this is a PHP problem
but this

require 'login/db_connect.php';

will need to be above the doctype
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-25-2006, 12:53 PM Re: Unknown Error
pipers dragon's Avatar
Extreme Talker

Posts: 190
Trades: 0
I know it just happened to end up here wehn the other probelm was corrected. Okay, so, If I cdont have a doctype. then where would it go?
pipers dragon is offline
Reply With Quote
View Public Profile
 
Old 03-25-2006, 03:23 PM Re: Unknown Error
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
above where the doctype would be if you had one

top of the page before any output is sent to the browser.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-26-2006, 12:14 AM Re: Unknown Error
pipers dragon's Avatar
Extreme Talker

Posts: 190
Trades: 0
Okay, I got that firgured out, and everything looked to be going well, the right thing was being Echoed, but then when I logged in, I got another Error... *sigh* but on the bright side I am at least learning how to detect and correct php/mysql errors! So here is my new error:


Fatal error: Call to a member function on a non-object in /home/resist/public_html/elite/login/check_login.php on line 20


Code in check_login.php:, lines 19-27:
PHP Code:
    // addslashes to session username before using in a query.
    
$pass $db_object->query("SELECT password FROM users WHERE username = '".$_SESSION['username']."'");

    if(
DB::isError($pass) || $pass->numRows() != 1) {
        
$logged_in 0;
        unset(
$_SESSION['username']);
        unset(
$_SESSION['password']);
        
// kill incorrect session variables.
    

pipers dragon is offline
Reply With Quote
View Public Profile
 
Old 03-26-2006, 02:33 AM Re: Unknown Error
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
sounds like the session isn't being created\started

echo out $_SESSION['username'] to see if there is a value there (or if you get the same error)

if it is blank (or missing) the code to start the session needs to be before the error line.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-26-2006, 12:18 PM Re: Unknown Error
pipers dragon's Avatar
Extreme Talker

Posts: 190
Trades: 0
RikuSaotome <--that is the right thing to output
Fatal error: Call to a member function on a non-object in /home/resist/public_html/elite/login/check_login.php on line 22

That is if I am logged in, but not when logged out. Im seriously stumped..The code works is the line is directly below itl, but it isnt working for one thats 20 lines below it?

EDIT: Also, the echo $_SESSION['username']; code works ANYWHERE above line 22 which was in the error, but doesnt work anywhere below it

Last edited by pipers dragon; 03-26-2006 at 12:23 PM..
pipers dragon is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Unknown Error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.31320 seconds with 12 queries