I want to get 'name' value from my database. How do I do this? This is what I've been trying. PHP code: $rdata = mysql_query("SELECT NAME FROM User_Database WHERE PASS= '$inputpass'", $databasename) or die(mysql_error()); $row = mysql_fetch_assoc($rdata); $name = $row['NAME']; echo($name); Code (markup): Why won't it work, it doesn't give an error but $name = null Thanks. ~imozeb
lets change your code to $inputpass = addslashes($inputpass); $sql = "SELECT `NAME` FROM `User_Database` WHERE `PASS`= '{$inputpass}'"; $rdata = mysql_query($sql, $databasename) or die(mysql_error().'<br />'.$sql); $row = mysql_fetch_assoc($rdata); $name = $row['NAME']; echo($name); var_dump($rdata); Code (markup): Are you sure those column names are meant to be uppercase? I echo out the sql if there is an error because it can then be pasted right into phpMyAdmin and tested. Visually you might also see the problem. `NAME` tells mysql not to consider name to be a reserved word but to look for a column called name. {$inputpass} with {} around it tells PHP to parse the variable. Its supposedly faster and certainly safer.
Thanks. It worked. And thanks for explaining what you did instead of just giving me the code. I'll remember that curly bracket thing.