garry27 Posted October 15, 2006 Share Posted October 15, 2006 ok so i'm trying to get the following code to verifiy $email and $pwd as part of a login process: <?phpsession_start();// Initiates php script containing functions require_once('common.php'); require_once('user_auth_fs.php'); $email = $_GET['email'];$pwd = $_GET['pwd'];// turn off run-time error notices$old_level = error_reporting(E_ALL & ~E_NOTICE);if ($email && $pwd)// they have just tried logging in{ try { login($email, $pwd); // if they are in the database register the user id $_SESSION['valid_user'] = $email; } catch(Exception $e) { // unsuccessful login echo 'You could not be logged in. You must be logged in to view this page.'; exit; } }?>but i'm not getting anything outputted to my $sql variable. the sql doesn't seem to be working but the db connection is fine.<?php //user_auth_fs.php function login ($email, $pwd) { // check username and password with db // if yes, return true // else throw exception // turn off run-time error notices $old_level = error_reporting(E_ALL & ~E_NOTICE); // connect to db $conn = db_connect(); $sql = $conn->query("SELECT * from members;"); echo $sql;?>please can someone tell me how to fix this? Quote Link to comment Share on other sites More sharing options...
marcus Posted October 15, 2006 Share Posted October 15, 2006 connect like:[code]$connection = mysql_connect(host,dbuser,dbpass);$db = mysql_select_db(dbname,$connection);//then$sql = "SELECT * FROM members";$result = mysql_query($sql);$result2 = mysql_fetch_assoc($result);[code]then whatever you want to echo do[code]echo $result2[user];[/code]just change user to a field in your database[/code][/code] Quote Link to comment Share on other sites More sharing options...
garry27 Posted October 15, 2006 Author Share Posted October 15, 2006 it doesn't work when i use the long hand way of connecting to db- i get:Fatal error: Call to a member function query() on a non-object in /home/unn_p921847/public_html/pa_home.php on line 59...but when i use the short hand method which i copied from a book, it seems to connect ok (or at least doesn't spit back any errors) but then the i get no results with the mysql.im fed up of this. i've spent over a day trying to solve this. i never had a problem connecting before when i was using request. ever since i'm having to use sessions to pass on data, i'm having problems. Quote Link to comment Share on other sites More sharing options...
Stooney Posted October 15, 2006 Share Posted October 15, 2006 try mysql_query() and not query() maybe Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.