Re: DOH I dont have a clue
| From: | gstrein andreas | Date: | Wed, 16 Aug 2000 07:04:29 +0000 |
| Subject: | Re: DOH I dont have a clue | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-2075@lists.php.net to get a copy of this message | ||
hi,
your code returns the
Resource id #2
cause $sql_id holts the result of the query and thats a pointer to the
result
so you have to use this pointer $sql_id to retrieve the result as shown
below:
$sql_id = mysql_query($get_ID,$db);
$myRow = mysql_fetch_row($sql_id);
setcookie("userID","$myRow[0]");
echo "<center><h6>debugging text is printed here</h6></center>";
echo "<br> you are user number $myRow[0]";
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/_/ viva technologies
_/ gstrein andreas
"Always listen to the experts; they'll tell you what can't be done and why.
Then do it."
- Robert A. Heinlein
#Please explain why this code sets the value "2" into the cookie
#"userID"REGARDLESS of the values entered into the first two variables?
#In the table (MySQL) 'users' the field 'id' is a unique key,
#auto-incrementing but even if I change it to search for a different non
#interger field like first_name the value returned is 2 when I use this code
#the same query syntax
#select id from users
#where username = 'darkjedi'
#and password = 'lightsaber';
#seems to produce the correct 'id' data (when I issue it directly ( not via
#PHP)
#but the value is ALWAYS 2 regardless of what username and password I put
#into the code
#I'm totally stumped
#########################
#<SCRIPT language=php>
#$username ="darkjedi";
#$password ="lightsaber";
### store SQL in variable get_ID
#$get_ID = "select id from users
#where username = '$username'
#and password = '$password'";
## open database connection
#$db = mysql_connect("localhost","secret","verysecret")or
die("<br>Died at
#connect, please try later");
## select database
#mysql_select_db(retrieversports_net,$db)or die("<br>Croaked at database
#selection.");
## do query
#$sql_id = mysql_query($get_ID,$db) or die ("<center><h4>dead at query.
#</h4></center>");
#setcookie("userID","$sql_id",time()+800,"/",".retrieversports.net",0);
#echo "<center><h6>debugging text is printed here</h6></center>";
#echo "<br> you are user number $sql_id";
</SCRIPT>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
For additional commands, e-mail: php-db-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net