Re: Stumped Newbie: Can't get results in db query eventhough everything checks - what am I missing?

From: Date: Thu, 08 Mar 2001 18:53:58 +0000
Subject: Re: Stumped Newbie: Can't get results in db query eventhough everything checks - what am I missing?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-43061@lists.php.net to get a copy of this message
Thanks Joe - that showed me right away!! all better now -- on to the next step.. Nicole "Joe Sheble (Wizaerd)" wrote: > > I'd start by adding the mysql_error() function in your die() statement... > $result = mysql_query($sql,$connection) or die ("Couldn't get results: " . > mysql_error()); > > it might give more information to help you find the problem... > > At 10:15 AM 3/8/01 -0800, Nicole Lallande wrote: > >Greetings, > > > >I keep getting the message that I cannot get results. I have a simple > >user authentication code that uses a mysql database to authenticate > >from. Initially I had the code working when I had the mysql_connect > >variables in the code itself. When I moved the connection variables to > >an include file and then called them as variables, it was necessary to > >change the variable names in the database (both were initially > >$username, $password). Now, while I have the connection and opening the > >db correct I can't get results. Here is my code: > > > >require("connect.inc.php"); > > > >$connection = > >mysql_connect("$hostname","$username","$password") or die > >("Unable to connect to database."); > >echo "I'm connected.<br>"; > >**__A-OK here > > > >mysql_select_db("dnaUsers") or die ("Unable to select database."); > >echo "I've opened the dnaUsers db.<br>"; > >echo "$ruser, $rpass<br>"; //this is from the html login form > >**__Yup, no problem so far - > > > >// Formulate the query > >$sql = "SELECT rep_name FROM reps WHERE username='$ruser' and > >password='$rpass'"; > >// Execute the query and put the results in $result > >$result = mysql_query($sql,$connection) or die ("Couldn't get > >results."); > > > >**__Here it is - crash and burn - the database name is correct, the > >fields are correct, the username and password are in the db and have > >been input correctly and are even being passed from the form correctly. > > > >I have checked the names of all the fields to ensure they match the > >variables in the query, checked that the values in the fields are > >correct - (yes, I have checked that they match.) > > > >I have searched the archives but the hard thing about the archives is > >formulating the question in a way that will yield an answer. Sorry if > >this has been asked before. > > > >TIA, > > > >Nicole > >-- > >######################## > >Nicole Lallande > >nicole@nmlconsulting.com > >760.753.6766 > >######################## > > > >-- > >PHP General Mailing List (http://www.php.net/) > >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > >For additional commands, e-mail: php-general-help@lists.php.net > >To contact the list administrators, e-mail: php-list-admin@lists.php.net > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- ######################## Nicole Lallande nicole@nmlconsulting.com 760.753.6766 ########################

« previous php.general (#43061) next »