Pyro4816 Posted November 25, 2006 Share Posted November 25, 2006 [code]<?phpsession_start(); $user = $_POST['user'];$pass = $_POST['pass'];include('includes/dbconnector.php');$connector = new DbConnector();$query = $connector->query("SELECT user,pass FROM members WHERE user=' $user '");$row = $connector->fetchArray($query);{echo $query;}[/code]OK, I have that code, i use a login to send the post vars to the script, but instead of echoing the username and pass in the DB, it echos and i quote "Resource id #5" and i am not sure why. Now, i am new to php, so please explain it in non "industry" language.Thank you. Link to comment Share on other sites More sharing options...
rotwyla98 Posted November 25, 2006 Share Posted November 25, 2006 You are eching the wrong variable.You need to echo out $row['column_name']; for the variable you are tyring to get Link to comment Share on other sites More sharing options...
mansuang Posted November 25, 2006 Share Posted November 25, 2006 To check the result, you may use 'while' loop.[code]<?phpsession_start(); $user = $_POST['user'];$pass = $_POST['pass'];include('includes/dbconnector.php');$connector = new DbConnector();$query = $connector->query("SELECT user,pass FROM members WHERE user=' $user '");while($row = $connector->fetchArray($query)){print_r($row);}[/code]You have to show class in "dbconnector.php" for more info. Link to comment Share on other sites More sharing options...
Pyro4816 Posted November 25, 2006 Author Share Posted November 25, 2006 that does'nt work either, when i try echoing a row all it does is come up blank.... Link to comment Share on other sites More sharing options...
onlyican Posted November 25, 2006 Share Posted November 25, 2006 ok, this is kinda hard not seeing the full code from the classbut You normally get Resorce 5 by echoing the queryWhich I can see your doing thereYou want a while loop for the $rowwhile($row = $connector-:fetchArray($query){$fieldname = $row["DBFIeldName"];} Link to comment Share on other sites More sharing options...
Pyro4816 Posted November 25, 2006 Author Share Posted November 25, 2006 while loop does'nt work either. Link to comment Share on other sites More sharing options...
Pyro4816 Posted November 25, 2006 Author Share Posted November 25, 2006 onlyican, i tryed it like this:[code]<?phpsession_start(); $user = $_POST['user'];$pass = $_POST['pass'];include('includes/dbconnector.php');$connector = new DbConnector();$query = $connector->query("SELECT user,pass FROM members WHERE user=' $user '");while($row = $connector->fetchArray($query)){$fieldname = $row["user"];}[/code] but still no change, it still comes up blank, and i am 100% sure that the user in the post var is in the database, i checked it myself. Link to comment Share on other sites More sharing options...
mansuang Posted November 25, 2006 Share Posted November 25, 2006 We can not see the code from your class.It's kinda hard to help Link to comment Share on other sites More sharing options...
Pyro4816 Posted November 25, 2006 Author Share Posted November 25, 2006 [code]function DbConnector(){ $settings = SystemComponent::getSettings(); $host = $settings['dbhost']; $db = $settings['dbname']; $user = $settings['dbusername']; $pass = $settings['dbpassword']; $this->link = mysql_connect($host, $user, $pass); mysql_select_db($db); register_shutdown_function(array(&$this, 'close'));}[/code]this is what you mean, right? Link to comment Share on other sites More sharing options...
Pyro4816 Posted November 25, 2006 Author Share Posted November 25, 2006 i figured out why, i know im a noob....... the vars are both defined, ........ CRUDDD it is stillllll not working right..... Link to comment Share on other sites More sharing options...
onlyican Posted November 25, 2006 Share Posted November 25, 2006 Try this hombre[code]<?php$query = $connector->query("SELECT user,pass FROM members WHERE user = '".$user."'");if(mysql_num_rows($query) != 0){while($row = $connector->fetchArray($query)){echo $row["user"]."<br />\n";}}else{echo "There are no results in the DB";}?>[/code] Link to comment Share on other sites More sharing options...
Pyro4816 Posted November 25, 2006 Author Share Posted November 25, 2006 OMG TY, that worked, i cannot begin to tell you how much this frustrated me. TY TY TY TY Link to comment Share on other sites More sharing options...
Recommended Posts