•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 423,122 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,143 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 3603 | Replies: 7
•
•
Join Date: Apr 2007
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
I keep getting some weird errors in this script:
errors:
and the script:
whats the problem?
thanks!
errors:
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/www/ikhelper.freehostia.com/globinc/loginfunc.php on line 86 Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/www/ikhelper.freehostia.com/globinc/loginfunc.php on line 87 Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/www/ikhelper.freehostia.com/globinc/loginfunc.php on line 90 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/ikhelper.freehostia.com/globinc/loginfunc.php on line 92 Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/www/ikhelper.freehostia.com/globinc/loginfunc.php on line 149 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/ikhelper.freehostia.com/globinc/loginfunc.php on line 150
<?php
function show_login_form($username,$password,$regcode)
{
?>
<h1>Login</h1>
<p>
Login by typing your username and password into
the boxes below and clicking on the 'Login' button.
Your username must match your IK account username <b>exactly</b>
and the password <b>must be different</b>.
</p>
<form action="login.php" method="post">
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td align="right">Username:
<Input type=text name=username value="<?echo stripslashes($username)?>" class=textinput>
</td>
</tr>
<tr>
<td align="right">Password:
<Input type=password name=password value="" class=textinput>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align="right">
<input type=submit name=submit value="Login">
</td>
</tr>
</table>
<p>
If you do not have an account, please click <a href="register.php">here</a>
to register an account, or if you have a registration code, enter it here:
<input type=text name=regcode size=5 value="<?echo stripslashes($regcode);?>" class=textinput>.
</p>
</form>
<?
}
function prepare_failed_alert($failedattempts)
{
if ($failedattempts == 1)
{
$string = "Warning, there has been a failed attempt ";
}
else
{
$string = "Warning, there have been $failedattempts failed attempts ";
}
$string .= "to log into your account.";
$_SESSION['head_message'] .= $string;
}
function process_groups()
{
// now we'll get the group memberships
$groups="groupfileeveryone";
// set the session variables for the groups you want to check. If found it will
// contain a positive number, if not, it will contain FALSE and the existance of
// it can be checked with:
//
// if ($_SESSION["variable"])
//
$_SESSION['group_all']=strpos($groups,"everyone");
}
function authenticate($username,$password,$regcode)
{
require_once ("usersql.php");
$loginwhere=$_SERVER['REMOTE_ADDR'];
$loginwhen=date("Y/m/d H:i:s",time());
$loginconn=mysql_connect($userhost,$useruser,$userpass);
mysql_select_db($userdb,$loginconn);
$query="SELECT * FROM $usertable WHERE username='$username' AND password='$password'";
$result=mysql_query($query,$loginconn);
if(mysql_num_rows($result))
{
$loginrow=mysql_fetch_array($result);
$failedattempts=$loginrow['failedattempts'];
$dbregcode=$loginrow['userreqcode'];
if ($dbregcode=="")
{
$query="UPDATE $usertable SET lastloginwhere='$loginwhere', failedattempts='0',
lastloginwhen='$loginwhen' WHERE username='$username'";
$result=mysql_query($query,$loginconn);
$_SESSION['username']=$myrow['username'];
process_groups();
if ($failedattempts > 0)
{
prepare_failed_alert($failedattempts);
}
if ($regcode != "")
{
$_SESSION['alert'] .= "You don't need to enter the registration code any more";
}
return true;
} // end if dbregcode is empty
else
{
if ($dbregcode == $regcode)
{
$query="UPDATE $usertable SET userreqcode='', lastloginwhere='$loginwhere',
active='1', useractivated='$loginwhen', failedattempts='0',
lastloginwhen='$loginwhen' WHERE username='$username'";
$result=mysql_query($query,$loginconn);
if ($failedattempts > 0)
{
prepare_failed_alert($failedattempts);
} // end failed attempts
$_SESSION['username']=$myrow['username'];
process_groups();
return true;
} // end if the regcode matched
else
{
$_SESSION['alert'] = "You need to enter the registration code as well";
return false;
} // end if the regcode didn't match
} // end else not empty
}
else
{
// let's see if the username was valid
$query="SELECT * FROM $usertable WHERE username='$username'";
$result=mysql_query($query,$loginconn);
if(mysql_num_rows($result))
{
$loginrow=mysql_fetch_array($result);
$failedattempts=$loginrow['failedattempts'];
$failedattempts++;
$query="UPDATE $usertable SET failedattempts='$failedattempts'
WHERE username='$username'";
$result=mysql_query($query,$loginconn);
} // end if we found a valid username
$_SESSION['alert'] = "Invalid Username and Password, please try again";
return false;
}
}
?>whats the problem?
thanks!
Last edited by tomf : Apr 29th, 2007 at 4:47 pm.
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result (PHP)
- mysql_fetch_array(): supplied argument is not a valid MySQL (PHP)
- Supplied argument is not a valid MySQL result resource (MySQL)
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
- Error message (MySQL)
Other Threads in the PHP Forum
- Previous Thread: Getting Info. for specific record?
- Next Thread: Generate Email script



Threaded Mode