Jump to content


New Members
  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Tom18

  • Rank
  1. Hello i am trying to create a prepared statement with mysqli and php to see if the username entered in the HTML form already exists the in table. I am getting this error Fatal error: Uncaught Error: Call to a member function bind_param() on string My code: $sql_u = "SELECT user FROM users WHERE user=?"; $sql_u->bind_param('s', $user); $sql_u->execute(); if($result = $sql_u->fetch_array()) { if($result >= 1) { print "That username is taken!\n"; } else { //Do nothing } } The variable $user is equal to $_POST['user']; The code below is working it inserts records into the table with no problems but i would just like to check if the user is already existing. $stmt = $conn->prepare("INSERT INTO users (user, password, email) VALUES (?, ?, ?)"); $stmt->bind_param('sss', $user, $pass, $email); $stmt->execute(); if(!$stmt) { die("Something went wrong."); }
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.