I know there are many posts on this subject, however after reading them I am still not seeing what the problem is in my code.

I have run the SQL Query in phpmyadmin and it works fine, calling up the correct entry from the database.

The error is being raised in the function "process_login()" at the line that reads

$Result = mysql_query ($Query, $Connection) or die("Query failed : " . mysql_error($Connection));

Here is the code I pulled together from 3 different files (2 includes) to try and debug it all in one file.

// set_include_path("./inc");
// require_once "sqlFunctions.php";
// require_once "loginBox.php";
$Connection = false;



function connectToDatabase(){
  global $hostname, $username, $password, $database, $DeBug;
	if($Connection){return (1);}
		mysql_select_db ($database, $Connection) or die('Database connection error: ' . mysql_error($Connection));
		return (1);
  }else{return (0);}  // handle error elsewhere

function disconnect(){
	global $Connection;
	if($Connection != NULL){mysql_close($Connection);}

function process_login(){
	global $UserData,$Connection,$LoginErrorMsg,$database,$DeBug;
 	if($Connection == NULL){$connectionStatus = connectToDatabase();}
// if(!$connectionStatus){myErrorHandeler("No server connection");}
	$Query = "SELECT * FROM logins WHERE login = '$_POST[LoginName]' AND pwd = password('$_POST[LoginPassword]')";
	$Result = mysql_query ($Query, $Connection) or die("Query failed : " . mysql_error($Connection));
		$UserData = mysql_fetch_array($Result);
		return 1;
    $LoginErrorMsg='<br>Login Name<br>and/or password<br>is invalid.';
		return 0;

function print_login_box(){
	global $UserData,$LoginErrorMsg;
	<form action="<?php echo $ConfigData{'scriptname'}?>" method="POST">
<?php if($_SESSION[UserId] == 0){ ?>
  Name:<input type="text" size="16" maxlength="16" name="LoginName" value="<?php echo $_POST[LoginName] ?>"><br>
  Password:<input type="password" size="16" maxlength="16" name="LoginPassword" value="<?php echo $_POST[loginPassword] ?>"><br>
	<input type="submit" name="mode" value="LogIn"><br>
	<font color="#D8D8D8"><?php echo $LoginErrorMsg; ?></font>
	<input type="hidden" name="Currentpage" value="<?php echo $_SESSION[Currentpage] ?>">
<?php }else{ ?>
	<input type="hidden" name="Currentpage" value="<?php echo $_SESSION[Currentpage] ?>">
  <font color="#D8D8D8">Welcome back,<br>
	<?php echo $_SESSION[UserFname];if($_SESSION[Verified]!=1){echo "*";} ?></font>
	<input type="submit" name="mode" value="Log Out">
<?php } ?>
<?php } ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Welcome to <? print $host; ?></title>
<link rel="stylesheet" type="text/css" href="./inc/Vstyle.css" />
<div id="container">
  <Table class="ex" width=100%>
		<td colspan=2 width =85%><img src="./images/StandardBanner.jpg"></td>
    <td align=right valign=top width=15% border=1><?php print_login_box();?></td>
    <td width=15%>Blah blah blah</td>
    <td width=70%>Lots of Blah blah blah</td>
    <td width=15%>Blah blah blah</td>


you didn't set the $connection variable as global in the connection function.

if for some reason that doesn't work, try removing $connection from the mysql_query

Thank you.

it was way too easy,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.