Login Register


Help with Updating database from PHP? filter_list
Author
Message
Help with Updating database from PHP? #1
Im still in the process of learning PHP. Here is what im trying to accomplish. I have a database table named users with 4 columns. user_name, user_rank, user_tag, list_order. I want the user to be able to select the user_name from the form and enter the value for the other 3 columns and it update into the database on the selected users row. This is what I have and the error I am getting. How do I go about fixing this.

error:
Fatal error: Call to a member function bind_param() on a non-object in /hermes/bosnaweb24a/b1321/ipg.darkgaminglivecom/panel/user_rank_change.php on line 17

user_change.php:
Code:
<form method='post' action='user_rank_change.php'> <!-- Gamertag Select --> <h3 for='select_gamertag' >Select GamerTag</h3> <select class="form-control" id='select_gamertag' type='text' name='select_gamertag'> <? while($row = mysqli_fetch_array($result6)) { echo "<option>" . $row['user_name'] . "</option>"; } ?> </select> <!-- Select Rank --> <h3 for='select_rank' >Type rank as it is shown below</h3> <input id='select_rank' type='text' name='select_rank' class="form-control" placeholder="Example: Recruit"> <!-- Select Tag --> <h3 for='select_tag' >Type tag as it is shown below</h3> <input id='select_tag' type='text' name='select_tag' class="form-control" placeholder="Example: [DSxR]"> <!-- Select Order --> <h3 for='select_order' >Type order as it is shown below</h3> <input id='select_order' type='text' name='select_order' class="form-control" placeholder="Example: 27"> <!-- Submit Form --> <button type="submit" class="btn btn-default">Change Rank</button> </form>

user_rank_change.php:
Code:
// Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // prepare and bind $stmt = $conn->prepare("UPDATE users (user_rank, user_tag, list_order) VALUES (?, ?, ?) WHERE user_name = '$gamertag'"); $stmt->bind_param("sss", $_POST['select_rank'], $_POST['select_tag'], $_POST['select_order']); // set parameters and execute $gamertag = $_POST['select_gamertag']; $rank = $_POST['select_rank']; $tag = $_POST['select_tag']; $order = $_POST['select_order']; $stmt->execute(); echo "New records created successfully"; $stmt->close(); $conn->close(); ?>
β€œI am thankful for all of those who said NO to me. It’s because of them I’m doing it myself.” – Albert Einstein

Reply





Messages In This Thread
Help with Updating database from PHP? - by mudrig - 07-27-2016, 07:50 PM



Users browsing this thread: