Search
Left Quote    I have not failed. I've just found 10,000 ways that won't work.
- Thomas Alva Edison    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: Login Error
  This user is offline  confuser
  Subject: "Login Error" Posted: @ 9:14 pm on Jan 02 2008   
Member #: 531
Rank: User - (4)
Since: 01/02/08
Posts: 4

I get the following error when i login
Warning: mysql_fetch_obj ect(): supplied argument is not a valid MySQL result resource in /www/110mb.com/ g/a/m/e/s/g/a/l /gamesgalore/ht docs/login.php on line 24
Login Failure: An error occured, please verify your username and password are correct. in my login.php

Code:
<?
ob_start();
require_once('d b.php');

if(isset($_SESS ION['username'] ) && isset($_SESSION ['password'])) {
//REDIRECT TO USERS PROFILE...
header("Lo cation: http://gamesgal ore.110mb.com&q uot;);
} //end if logged in
//IF SUBMIT BUTTON PRESSED
if(isset($_POST ['submit'])) {

if(!$_POST['use rname']) die("Error : You must enter your username before logging in.");
if(!$_POST['pas sword']) die("Error : You must enter your password before logging in.");

//set cookie if checked
if(!empty($_POS T['stay_in'])) {
$joined =''.$_POST['use rname'].'[]'.md 5($_POST['passw ord']).'';
setcookie('logi n_cookie', $joined, 2147483647, '/', '.gamesgalore.1 10mb.com');
} //end if
//verify user...
$get_user = mysql_query(&qu ot;SELECT * FROM `members` WHERE username = '".$_POST[ 'username'].&qu ot;' AND

user_password = '".md5($_P OST['password'] )."'" );
$q = mysql_fetch_obj ect($get_user);
if(!$q) die("Login Failure: An error occured, please verify your username and password are correct.") ;
//set session variables
$_SESSION['logg ed_in'] = 1;
$_SESSION['user name'] = $_POST['usernam e'];
$_SESSION['pass word'] = $_POST['passwor d'];
session_write_c lose();

header("Lo cation: http://gamesgal ore.110mb.com&q uot;);
} else {
//show login form
?>
<form name="logi n" method="po st" action="&l t;? $_SERVER['PHP_S ELF']; ?>">
<table> <tr>
<td>Usern ame:<input type="text " id="userna me" name="user name">& lt;/td>
</tr>
<tr>
<td>Passw ord:<input type="pass word" id="passwo rd" name="pass word">& lt;/td>
</tr>
<tr>
<td>Submi t: <input type="subm it" value="Sub mit" name="subm it" id="submit "></ td>
</tr>
<tr>
<td>Remem ber? <input type="chec kbox" name="stay _in[]" checked="y es">< ;/td>
</tr>
</table>< br /> </form> <?
}//end else
?>


and i get an error at the top of my index page
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in /www/110mb.com/ g/a/m/e/s/g/a/l /gamesgalore/ht docs/header.php on line 8
header.php=

Code:
<?
ob_start();
require_once('d b.php');
//check cookie
if ($_SESSION['log ged_in'] != 1 && isset($_COOKIE[ 'login_cookie'] )) {
list($user, $pass) = explode('[]', $_COOKIE['login _cookie']);
$qu = mysql_query(&qu ot;SELECT `user_password` FROM `members` WHERE `username` = '".addslas hes($user).&quo t;'");
if (mysql_num_rows ($qu) == 1) {
$passw = mysql_fetch_obj ect($qu);
if ($passw->use r_password == $pass) {
$_SESSION['logg ed_in'] = 1;
$_SESSION['user name'] = $user;
$_SESSION['pass word'] = $pass;
}
}
}
if(!isset($_SES SION['username' ]) && !isset($_SESSIO N['password'])) {
$_SESSION['logg ed_in'] = 0;
$user = "Guest&quo t;;
}

echo'<!DOCTY PE html PUBLIC "-//W3C//D TD XHTML 1.0 Transitional//E N" "http://ww w.w3.org/TR/xht ml1/DTD/xhtml1- transitional.dt d">
<html xmlns="htt p://www.w3.org/ 1999/xhtml" ;>
<head>
<meta http-equiv=&quo t;Content-Type& quot; content="t ext/html; charset=iso-885 9-1" />';
echo"<t itle>$title& lt;/title>&q uot;;
echo'<style type="text /css">< br /> <!--
body {
background-ima ge: url(http://game sgalore.110mb.c om/images/bg.jp g);
background-rep eat: repeat-y;
background-pos ition: center;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>< br /> <link href="http ://gamesgalore. 110mb.com/css.c ss" rel="style sheet" type="text /css" />
<style type="text /css">< br /> <!--
.style2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #FFFFFF;
}
.style26 {color: #FFFFFF}
.style28 {color: #265C78; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; }
.links {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
color: #FFFFFF;
}
a:link {
color: #FFFFFF;
}
a:visited {
color: #FFFFFF;
}
.style29 {font-size: 10px}
-->
</style>< br /> <script type="text /JavaScript&quo t;>
<!--
function MM_openBrWindow (theURL,winName ,features) { //v2.0
window.open(the URL,winName,fea tures);
}
//-->
</script>
</head>';
echo'<body&g t;
<table width="500 " height="63 9" border="00 " align="cen ter" cellpadding=&qu ot;0" cellspacing=&qu ot;0">< br /> <tr>';
echo'<td height="0& quot; colspan="2 "><i mg src="', $sitetitle, 'images/logo_he ad.jpg" alt="" ; width="336 " height="70 " />'; ?><img src="<? echo"$site title"; ?>images/sig nup.jpg" alt="" ; width="164 " height="70 " border="0& quot; onclick="M M_openBrWindow( 'newsletter.htm l','','width=50 0,height=200')& quot; /></td> ;
</tr>
<tr>
<td height="25 " colspan="2 " background=&quo t;<? echo"$site title"; ?>images/bg_ about.jpg" ><table width="500 " border="00 " cellspacing=&qu ot;0" cellpadding=&qu ot;0">< br /> <tr>
<td width="352 ">& nbsp;</td> ;
<td width="148 " class="sty le2">Ab out us | Contact us </td>
</tr>
</table>& lt;/td>
</tr>





    Viewed: 5,319 Times | Reply to This | To top
  This user is offline  misterhaan
  Subject: "re: Login Error" Posted: @ 3:00 pm on Jan 04 2008    

Member #: 5
Rank: User - (213)
Since: 02/11/05
Posts: 148
From: chair

looks like your mysql_query calls are failing. you can try the query in something like phpmyadmin, or put in this code in the lines just after the mysql_query calls:

if(!$q)
echo mysql_error();< br />
(make the $q $qu in header.php)




please note that the above post is likely made up in its entirety.

    Viewed: 5,215 Times | Reply to This | To top
  This user is offline  confuser
  Subject: "re: Login Error" Posted: @ 3:54 pm on Jan 04 2008    
Member #: 531
Rank: User - (4)
Since: 01/02/08
Posts: 4

  misterhaan said...

< i> looks like your mysql_query calls are failing. you can try the query in something like phpmyadmin, or put in this code in the lines just after the mysql_query calls:

if(!$q)
echo mysql_error();

(make the $q $qu in header.php)

thnx i got its working now, problem was that the DB wasnt being selected so i just copied contents of db.php to header.php then the page kept refreshing so i checked login.php and found that the header for if yr logged in kept redirecting to the homepage




    Viewed: 5,212 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank