Jump to content

Renato

New Members
  • Posts

    5
  • Joined

  • Last visited

Renato's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I figure out by myself, after looking at the code for hours. It happens to everyone thank you so much for the replies.
  2. Hello everyone, I'm create an application where I have member, admin, and superadmin What I'm try to do is superadmin update member to admin, so they can have more privilege. The name of the table is member where I have member, admin account, and i have row call 'rank'. Rank 1 is for member they have access basic stuff and rank 2 they have more privilege. Want the superadmin to type the name of the member and change to rank 2. This is what happening, if I dont put nothing on the text boxes, it said "Please check if you have put the right information." , if i put member and the rank i want to change is says ""User has upgrade to admin", but than when i check my database the member is still a member when i wanted to change to admin. Can anyone see where I'm going home, or what should I change. <form> </form> <form action='<?php htmlentities($_SERVER['PHP_SELF']); ?>' method='POST' enctype='multipart/form-data '> Username: <input class="fontsize" name='user' type='text'/> Rank: <input class="fontsize" name='rank' type='text' /> <br><br> <input class="button" type='submit' name='get' value='Upgrade' /> </form> </h2> <?php if(isset($_POST['get'])) { $username1 = $_POST['user']; $sql_user = mysqli_real_escape_string ($connection, $username1); $rank = $_POST['rank']; $rank = mysqli_real_escape_string ($connection, $rank); $query1 = mysqli_query($connection, "SELECT rank FROM member WHERE username='$sql_user'"); if ($row = mysqli_fetch_array($query1)) { if ($rank == '1') { $data1 = mysqli_query($connection, "UPDATE member SET rank= '1' WHERE username='sql_user'") or die (mysql_error($connection)); echo "User has downgrade to member"; } elseif ($rank == '2') { $data2 = mysqli_query($connection, "UPDATE member SET rank= '2' WHERE username ='sql_user'") or die (mysql_error($connection)); echo "User has upgrade to admin"; } else { echo "Please check if you have put the right information."; } } } ?>
  3. I have change to $squery; but i still get error -Warning: mysql_num_rows() expects parameter 1 to be resource, boolean And still get no results when search for username.
  4. I've try to, it didn't work. When I search it shows on URL, the word that has been input to the search box.
  5. I'm creating search box, to search users on my database this is the form <form action='' method='get' > <input type='text' name='search' /> <input type='submit' value='search'/> <br/> </form> php <?php $search = $_GET['search']; $terms = explode( " ", $search); $query = "SELECT * FROM login WHERE"; foreach ($terms as $each) { $i++; if ($i==0) $query .= "username like '%$each%' "; else $query .= "OR username like '%$each%' "; } mysql_connect("localhost", "renatov_admin", "password1!") or die (mysql_error()); mysql_select_db("renatov_database") or die ("could not find bd!"); $squery = mysql_query($query); $numrows = mysql_num_rows($query); if ($numrows > 0){ while($row = mysql_fetch_assoc($query)){ $username = $row['username']; $nationality = $row['nationality']; $age = $row['age']; $search = $row['search']; echo "<h2><a href='$link'>$username</a> </h2>"; } } else echo "No results found for \"<b>$search</b> \""; mysql_close(); ?> it comes with error: Warning: mysql_num_rows() expects parameter 1 to be resource, string given Is always "No result found for" Can someone tell me where I'm doing 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.