PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$fname = $HTTP_POST_VARS["fname"];
$sname = $HTTP_POST_VARS["sname"];
echo $fname;
echo $sname;
$db = mysql_connect("localhost", "root");
mysql_select_db("tester",$db);
$personid = mysql_query("select personid
from people where
$fname = fname and $sname = sname",$db);
fname and sname exist but it doesnt assign the personid from the table to
$personid.
I have switched fname = $fname and sname = $sname as well, used '' and "" around the variables. It doesnt want to get the id.
this is the file after submission from a form. AS i want to get the id created in the dB of the entry i just made to use. Is there another way to get the id?
you have an error in you SQL. echoing mysql_error() will give you a hint.
I'll give you one too: you need to quote something. (and sanitize it)
once the query is correct, $personid will be a resource identifier to the database's result set. You will need to use a fetch function such as mysql_fetch_assoc() to get the record found.
I have removed the syntax error (I think), all it returns is 'Resource id #3' for the echo of $personid no matter how many entries in the table and nothing for $id.
I think that 'Resource id #3' refers to the column number which in this case is fname.
single quotes in mysql, are string markers (typically). The query you posted previously has mysql compare the string 'fname' to '$fname', not the field fname to the string $fname.