farris Posted November 5, 2006 Share Posted November 5, 2006 this is for a login script...just letting you know so the variables make sense...im trying to access a database and pull out the column "usercode" when the username and userpassword on a row is found[code]<?php// Database connection informationinclude('../Connections/databaseconnect.php'); // Puts user input into variables$loginusername= $_POST[loginusername];$loginuserpassword= $_POST[loginuserpassword];//MySQL query string that points to the usercode information that we want so that we can put it into a cookie$finduser= "SELECT usercode FROM users WHERE username = '$loginusername' AND userpassword = '$loginuserpassoword'";//Selects database and returns an error if it doesn't workmysql_select_db($db_database,$conn) or die(mysql_error());//Puts MySQL query into a variable$result = mysql_query("$finduser");//Pulls information from the array and displays itwhile($row = mysql_fetch_array($result)) { echo $row['usercode'] . "<br>"; }?>[/code]i tried the query directly on mysql and it returns the variable that i want without any problemsi had originally tried to echo $result directly but i ran into the resource id #4 problem and when i researched that i found out about fetch arrayive been trying to learn php for about a month and mysql for about 3 weeks so this could be something i just keep looking right over and not paying attention Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted November 5, 2006 Share Posted November 5, 2006 try removing the talking marks from the $result variable. so it looks like this:[code=php:0]$result = mysql_query($finduser);[/code] Quote Link to comment Share on other sites More sharing options...
farris Posted November 5, 2006 Author Share Posted November 5, 2006 it still doesnt return anythingi tried echoing the 2 login variables and they came back correctly so all the information is being passed correctly from the previous page and the registration page uses the same database file to connect so that must be correct tojust thought id rule out those 2 sources of error Quote Link to comment Share on other sites More sharing options...
Kelset Posted November 5, 2006 Share Posted November 5, 2006 Did you try to echo your query to see what it looks like?I don't know much about select a db but I don't have the $conn when I do it.I just do it this waymysql_select_db("database_name");Other then tha I am not sure it all looks good to me :(Stephen 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.