Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 29th, 2004, 01:53 PM
Authorized User
 
Join Date: Nov 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to IP076
Default Fetching a value in a SQL result...

Here's what I have:
$conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS)
 or die('Could not connect to MySQL database. ' . mysql_error());
mysql_select_db(SQL_DB,$conn);

$login=$_SESSION['username'];
$password=$_SESSION['userpass'];

$getpass="SELECT login, password, authuser FROM member_login WHERE login='$login' AND password='password'";
$result=mysql_query($getpass) or die (mysql_error());
$row=mysql_fetch_row($result);
$userlevel=$row['authuser'];

What I'm trying to do is get $userlevel to equal to value in the authuser column in my table. For testing purposes I have an echo $userlevel command later to show the user level, just so I know there is a value being stored there. (echo $userlevel;)

Thie echo always shows up blank, which leads me to believe the $userlevel is not getting the info from the SQL statement.

This is my first attemp at password protecting a site using stored values, and I've only been studying PHP for about a week. If someone could point me in the right direction I'd be extremely happy! Thank you for your help!

 
Old November 29th, 2004, 02:21 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default

what could be happening is that your query is not reurning any records.
You have this line:
$getpass="SELECT login, password, authuser FROM member_login WHERE login='$login' AND password='password'";

and you probably meant
$getpass="SELECT login, password, authuser FROM member_login WHERE login='$login' AND password='$password'";



Christian
 
Old November 29th, 2004, 02:26 PM
Authorized User
 
Join Date: Nov 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to IP076
Default

Gotta love the hours spent pulling out hair for some stupid mistyping error!:D

Thanks for pointing out the obvious, works like a charm!






Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Server 2000 data fetching overrideme VB Databases Basics 0 April 21st, 2008 09:05 AM
GridView and SQL More than one result = one result DarkForce ASP.NET 2.0 Basics 0 July 20th, 2007 04:29 AM
How to read SQL Result mrideout BOOK: Beginning ASP.NET 1.0 1 October 20th, 2004 01:10 AM
Paging of Sql Query Result. SubodhKumar SQL Language 4 December 13th, 2003 06:58 PM
getting the result of an SQL INSERT pankaj_daga SQL Server 2000 2 September 30th, 2003 04:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.