Fatal error: Call to a member function query() on a non-obje
Posted: Sun Oct 15, 2006 7:35 pm
feyd | Please use
feyd | 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]
Fatal error: Call to a member function query() on a non-object in ........ /pa_home.php on line 59
why do i keep getting the above error when i try to connect to a database using a "self executable" script and sessions?
Pleeeeeeeeeeeassssseeeeeeee heeeeeelpppppppppp meeeeeeee!!!!!!! im going insane and i WILL fail my university project if i don't get this sorted out soon!Code: Select all
<?php //common.php
function db_connect()
{
$result = new mysqli('www.nl-webspace.co.uk', 'unn_p921847', 'password');
if (!$result)
throw new Exception('Could not connect to database server');
else
return $result;
}
<?php //logon page
//Initiates php script containing functions all common functions
require_once('common.php');
$dbconn = db_connect();
session_start();
//outputs header info to brower with the following title
echo xhtmlheader('Personal Account Registration Form');
//outputs the main navigation bar to the browser
echo topnav_pa();
if (isset($_POST['email']) && isset ($_POST['pwd']))
{
//if the user has just tried to log in
$email = $_POST['email'];
$pwd = $_POST['pwd'];
//$db_conn = new mysqli('localhost', 'webauth', 'webauth', 'auth');
$sql = 'select * from Authourised_User'
."where userEmail='$email'"
." and userPassword='$pwd';";
$result = $dbconn->query($sql);
if ($result->num_rows >0)
{
$_SESSION['valid_user'] = $email;
}
$dbconn->close;
}
?>
<!-- main body of page -->
<div id="main">
<h1>My Pub Crawl Planner</h1>
<?php
if (isset($_SESSION['valid_user']))
{
echo 'You are logged in as: '.$_SESSION['valid_user'].' <br />';
echo '<a href="logout.php">Log out</a><br />';
}
else
{
if (isset($email))
{
// if they've tried and failed to log in
echo 'Could not log you in.<br />';
}
else
{
// they have not tried to log in yet or have logged out
echo 'You are not logged in.<br />';
}
}
?>
<p>Member Login </p>
<form action="index.php<?php echo strip_tags(SID); ?>" method="post" class="login">
<table>
<tr>
<td>E-mail:</td>
<td class="table"> <input type="text"
name="email"
value=""
tabindex="1"/></td>
</tr>
<tr>
<td>Password:</td>
<td class="table"> <input type="text"
name="pwd"
value=""
tabindex="2"/></td>
</tr>
</table>
<!-- submit button -->
<input type="submit"
name="login"
value="Login"
tabindex="7"/>
</form>
<br/>
<br/>
<
</div>
</body>
</html>feyd | 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]