Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Very simple Im new

    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 = ?
    LIMIT 1";

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

    if($stmt->fetch()) {
    $stmt->close();
    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
    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.


  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Its part of using mysql prepared statements.

    http://dev.mysql.com/tech-resources/...tatements.html
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    -> 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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #4
    New Coder
    Join Date
    Mar 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •