Ok, I've trawled through all the relevent posts on this forum and I'm still stuck.
I keep getting the following error:
Warning: Supplied argument is not a valid MySQL result resource in /var/www/html/dws-support/index.php on line 99
I can't figure out why. Try it 193.122.28.177/index.php
login:bill password:gates
The code is attached below. and line 99 reads:
if (mysql_num_rows($verify_user) > 0) {
If anyone could help I would be grateful.
I've put * in the code where the db user and password go, but they are correct.
Thanks,
Nick Gushlow.
---oOo---
<head>
<title>[Dynamic Web Support] User Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="css/main.css">
<script language="JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v3.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function setFocus() { document.login.username.focus(); }
// -->
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="setFocus();MM_preloadImages('im/splash_signup_over.gif','im/splash_forgotpwd_over.gif')">
<?
// initialise variables
$sys_dbhost='localhost'; // MySQK Host Name
$sys_dbuser='**'; // MySQL Username
$sys_dbpasswd=''; // MySQL User Password
$sys_dbname='dws_support'; // MySQL Database
$verify_user = mysql_query("SELECT FROM user
WHERE username = '$username'");
// secret hash variable
$dws_var = 'citrus';
// create the hash
$hash = md5($passwd+$dws_var);
$verify_hash = mysql_query("SELECT * FROM user
WHERE username = '$username'
AND hash = '$hash'");
$access = mysql_query("SELECT access FROM user
WHERE username = '$username'
AND hash = '$hash'");
// login error?
$error_result = 0;
// ------- MAIN PROCEDURE ------- //
mysql_connect($sys_dbhost,$sys_dbuser,$sys_dbpasswd);
mysql_select_db ($sys_dbname);
if ($submit_x) {
echo $verify_user."<br>";
echo $verify_hash."<br>";
echo $access."<br>";
// process form
// Check to see if the user exists in the database
if (mysql_num_rows($verify_user) > 0) {
// check to see if the password is correct
if (mysql_num_rows($verify_hash) > 0) {
// check the access level of the user
if ($access == 1) {
// start the session
session_start();
/
// log session
$time_in = time();
mysql_db_query("INSERT INTO sessions
(sess_id,username,time_in)
VALUES
('$PHPSESSID','username','$time_in')
");
/
/
echo " just performed insert (allegedly)<br>";
echo $PHPSESSID;
echo $data[0];
echo $time_in;
/
echo "<script language=\"JavaScript\"> ";
echo "location=\'debug.php\';";
echo "</script>";
} else {
$error_result = 3;
}
} else {
// error result = wrong password
$error_result = 2;
}
} else {
// error result = user does not exist
$error_result = 1;
}
$error_number = mysql_errno();
$error_msg = mysql_error();
echo "MySQL error ".mysql_errno().": ".mysql_error()."<br>";
echo $username." <br>";
switch ($error_result) {
case 0:
echo "<br> There has been an internal error. <br>";
echo " Please contact the";
echo " <a href=mailto:technical@dynamicweb.co.uk>technical team</a>";
echo " at Dynamic Web Solutions. <br>";
exit;
case 1:
echo "<br> No such user (".$username.") exists. <br>";
exit;
case 2:
echo "<br> Wrong password. <br>";
exit;
case 3:
echo "<br> You do not have the correct Access Level. <br>";
echo " Please contact the";
echo " <a href=mailto:technical@dynamicweb.co.uk>technical team</a>";
echo " at Dynamic Web Solutions if you feel this is incorrect.";
echo "<br>";
exit;
}
$error_number = mysql_errno();
$error_msg = mysql_error();
echo "MySQL error $error_number: $error_msg";
}
?>
<form method="post" action="<?php echo $PHP_SELF?>" name="login">
<table width="100%" border="0" cellspacing="0" cellpadding="0" vspace="0" hspace="0" height="100%">
<tr>
<td height="50%"> </td>
</tr>
<tr align="center">
<td height="95">
<table width="400" border="0" cellspacing="0" cellpadding="0" height="94" vspace="0" hspace="0" align="center">
<tr>
<td width="301" height="45" valign="bottom"><img src="im/splash_top.gif" width="301" height="45" border="0" vspace="0" hspace="0"></td>
<td rowspan="3" width="99">
<table width="99" border="0" cellspacing="0" cellpadding="0" height="94">
<tr>
<td><a href="signup.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('signup','','im/splash_signup_over.gif',1)"><img src="im/splash_signup.gif" width="99" height="15" border="0" vspace="0" hspace="0" alt="signup for caller support" name="signup"></a></td>
</tr>
<tr>
<td><img src="im/splash_right.gif" width="99" height="79" border="0" vspace="0" hspace="0"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td background="im/splash_mspacer.gif" height="25">
<table width="301" border="0" cellspacing="0" cellpadding="0" height="25">
<tr>
<td width="12"> </td>
<td valign="middle">
<FONT size=-1 point-size="7">
<input type="text" name="username" size="15" class="formInputLogin" value="username">
</font>
</td>
<td valign="middle">
<FONT size=-1 point-size="7">
<input type="text" name="passwd" size="15" class="formInputLogin" value="password">
</font>
</td>
<td valign="middle" width="49">
<input type="image" border="0" name="submit" src="im/splash_login.gif" alt="login" width="49" height="10">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="301" height="24" valign="bottom" background="im/splash_bspacer.gif" align="right"><a href="forgotpass.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('forgotpwd','','im/splash_forgotpwd_over.gif',1)"><img name="forgotpwd" border="0" src="im/splash_forgotpwd.gif" width="194" height="18"></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="50%"> </td>
</tr>
</table>
</form>
<?php
?>
</body>