View Full Version : Very simple Im new

03-13-2009, 07:41 AM
First ill just past what im looking at so you know

function verify_Username_and_Pass($un, $pw) {
$conn = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die("there was a problem connection to the database");

$query = "SELECT *
FROM users
WHERE username = ? AND password = ?

if($stmt = $conn->prepare($query)) {
$stmt->bind_param('ss', $un, $pw);

if($stmt->fetch()) {
return true;

ok i get the $conn and the $query

now the part i could figure out from google or from the little knowlege I alredy have :p
its this part i do not get:

$conn->prepare($query)) {
$stmt->bind_param('ss', $un, $pw);

what is this -> is it like an array? can array's be -> and =>

sorry for the very noobie question. i di look on google but its not really something you can ask a search engine.


03-13-2009, 08:01 AM
Its part of using mysql prepared statements.


03-13-2009, 08:05 AM
-> indicates an object member or method access.
=> indicates key / value combinations, often used in array declarations and foreach statements.

You're code however will not work, prepare, bind_param, and execute are all based through the MySQLi class, not through the mysql library. They are not compatible together.
Prepare's purpose is to provide a mysqli_stmt object. Bind_param will allow a mysql_stmt object to dynamically bind parameters to the given ? values. This allows for dynamic switching using a single statement, and is really handy especially for batch uses.

03-13-2009, 08:19 AM
Ahh now im with you. thank you for that. I no most of the basic code but as soon as it all comes together i get a massive headace:( i hope this is normal for all programers