some help please!! Warning: mysql_fetch_array(): suppl
Posted: Wed Jul 26, 2006 12:25 pm
Everah | Please use
Look forward to the answer!!!
Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
OK
I am quite new to all this php/MySql stuff, though I feel I have managed well up until this point.
I keep receiving: "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in...."
and I do not know how to solve the problem.
What I am trying to create is a simple login page.
I have ruled out the possiblility of the query not being recognised in MySql by running the line through MySQL itself.
I've put a few line breaks in so you can spot the problematic code
Ladies and gentlemen, i present to you the problem ....Code: Select all
<?php
if(isset($_POST['submit'])) {
require_once('../conn.php');
function escape_data ($data) {
global $dbc;
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string($data, $dbc);
}
$message = NULL;
//check userName
if (empty($_POST['username'])) {
$un = FALSE;
$message .= '<p>You forgot to enter your username!</p>';
}else{
$un = escape_data($_POST['username']);
}
//Check password
if (empty($_POST['password'])) {
$pw = FALSE;
$message .= ' <p>You forgot to enter your password!</p>';
}else{
$pw = escape_data($_POST['password']);
}
if ($un && $pw) {
$sql = "SELECT userID FROM tblRegister WHERE userName='$un' AND password=PASSWORD('$pw')";
$result = mysql_query ($sql);
$row = mysql_fetch_array ($result);
if ($row) {
session_name('Your visit ID');
session_set_cookie_params (900, 'modulecb154.php');
session_start();
$_SESSION['userID'] = $row[1];
header ("Location: http//" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) .
"/cb154.php");
exit();
}else{
$message = '<p>Your username/password is incorrect.</p>';
}
mysql_close();
}else{
$mesage .= '<p>Pleas try again.</p>';
}
}
$page_title = 'login.php';
include('header.inc');
if (isset($message)) {
echo '<font color = "red">' , $message, '</font>';
}
?>
<div id="login">
<form method="post" action"login.php">
<h1>Login</h1>
<span class="formstyle">Username</span>
<input type="text" name="username" value="<?php if(isset($_POST['userName'])) echo $_POST['userName']; ?>" />
<br>
<br>
<span class="formstyle">Password</span>
<input type="password" name="password" />
<br><Br>
<input type="submit" name="submit" value="LOGIN" class="button"/></span>
</form>
</div>
<div id="regmenu"><table width="200" border="0" cellspacing="1" cellpadding="1">
<tr>
<td><a href="register.php">Register</a></td>
<td><a href="passwordreminder.php">Forgot Password</a></td>
</tr>
</table>
</div>
<?php
include ('footer.inc');
?>Look forward to the answer!!!
Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]