I'm simply trying to get a value from the user_password from my database and display it, but it won't display the variable! <?php require "header.php"; ?> <body> <?php // Make a MySQL Connection mysql_connect("localhost", "admin", "password"); mysql_select_db("booo_db"); $query="SELECT user_password FROM users WHERE user_name='Herb'"; $result=mysql_query($query); $row=mysql_fetch_array($result); print $row['user_password']; ?> <?php require "footer.php"; ?> PHP: Here's the URL
replace the line with : mysql_connect("localhost", "admin", "password") or die ( mysql_error() ); mysql_select_db("booo_db") or die ( mysql_error() ); $query="SELECT user_password FROM users WHERE user_name='Herb'"; $result=mysql_query("$query") or die ( mysql_error() ); $row=mysql_fetch_assoc($result); PHP: and see whats the error
have access to the mysql information schema database? Otherwise you would not be able to return the selected information. more stuff at: mcloide.wordpress.com
your site is showing an error not related to db so posting the whole code if its not that big can help a lot
true values need a quotation around them I usually do something like this: <?php require "header.php"; ?> <body> <?php // Make a MySQL Connection mysql_connect("localhost", "admin", "password"); mysql_select_db("booo_db"); $user_name = $_POST['user']; // Or can be $_GET['user'] to get from the url $query = "SELECT user_password FROM users WHERE user_name='{$user_name}'"; # Then I echo my line to make sure Im getting the proper var to pass: echo "SELECT user_password FROM users WHERE user_name='{$user_name}'"; $result=mysql_query($query); $row=mysql_fetch_assoc($result); <----- NOTICE THE assoc and not array print $row['user_password']; ?> <?php require "footer.php"; ?>