/    Sign up×
Community /Pin to ProfileBookmark

created login and connection page in dreamweaver. all works fine locally. uploaded files and db to go daddy hosting account, changed connection page to their specifics and now i get errors.

when i go to the login page, i get the following errors:

[CODE]Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by (output started at /home/content/k/i/n/kingevil/html/yips/smoking/Connections/connection.php:21) in /home/content/k/i/n/kingevil/html/yips/smoking/login.php on line 35

Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/content/k/i/n/kingevil/html/yips/smoking/Connections/connection.php:21) in /home/content/k/i/n/kingevil/html/yips/smoking/login.php on line 35[/CODE]

then when i try to login, i get these errors:

[CODE]Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/content/k/i/n/kingevil/html/yips/smoking/login.php on line 50

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/content/k/i/n/kingevil/html/yips/smoking/login.php on line 55
Table ‘smoking.$usertable’ doesn’t exist[/CODE]

here are the lines the errors are referring to:

login.php on line 35:

[CODE]session_start();[/CODE]

login.php on line 50:

[CODE]mysql_select_db($database_connection, $connection);[/CODE]

login.php on line 55:

[CODE]$LoginRS = mysql_query($LoginRS__query, $connection) or die(mysql_error());[/CODE]

i’m sure this has to do with local vs live. i’m just not sure what to change.

also, when i imported the db into go daddy, they gave me a new ‘connections’ page to upload. it contained a line and i wasn’t sure what to change it to:

[CODE]$yourfield = ‘your_field’;[/CODE]

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@Hen_AsrafDec 21.2008 — For the session part, you can't start the session after you have text on the source HTML. So if <html> tag is used, you're done on that part, you have to use session_start before there's any output on the browser.

As for the MySQL error, what does $database_connection refer to?
Copy linkTweet thisAlerts:
@King_EvilauthorDec 21.2008 — For the session part, you can't start the session after you have text on the source HTML. So if <html> tag is used, you're done on that part, you have to use session_start before there's any output on the browser.

As for the MySQL error, what does $database_connection refer to?[/QUOTE]


i have no idea what you're talking about. here's the full code:

[CODE]<?php require_once('Connections/connection.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;

case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['userid'])) {
$loginUsername=$_POST['userid'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "youths.php";
$MM_redirectLoginFailed = "nope.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_connection, $connection);

$LoginRS__query=sprintf("SELECT username, password FROM smoking WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $connection) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>[/CODE]
Copy linkTweet thisAlerts:
@Hen_AsrafDec 21.2008 — The file /home/content/k/i/n/kingevil/html/yips/smoking/Connections/connection.php makes text appear, and that happens in line 21. Go find out what's on there. That's for the seesion.
[code=php] mysql_select_db($database_connection, $connection);[/code]
And that line above ^ is pointing at the variable $database_connection. Can you tell me what that variable is?
Copy linkTweet thisAlerts:
@King_EvilauthorDec 21.2008 — here's connection.php:

[CODE]<?php
//Connect To Database
$hostname='smoking.db.3360910.hostedresource.com';
$username='xxxx';
$password='xxxx';
$dbname='smoking';
$usertable='smoking';
$yourfield = 'your_field';

mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db($dbname);

$query = 'SELECT * FROM $usertable';
$result = mysql_query($query);
if($result) {
while($row = mysql_fetch_array($result)){
$name = $row['$yourfield'];
echo 'Name: '.$name;
}
}
?> [/CODE]
Copy linkTweet thisAlerts:
@King_EvilauthorDec 21.2008 — i just deleted line 35: [CODE]session_start();
[/CODE]


and it seemed to have made the first 2 errors go away. i still have the other 2, however. help?????
Copy linkTweet thisAlerts:
@King_EvilauthorDec 21.2008 — ok, i think i figured it out. i used the connection.php code supplied by dreamweaver, and just changed the login name, password, db, etc, instead of pasting the code go daddy gave me. it seems to work now - no more errors!
×

Success!

Help @King_Evil spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...