renatovieita Posted January 16, 2015 Share Posted January 16, 2015 Hello guys, this is my first post so sorry if I made any mistake I need select record from one table and move to another table But I get this message saying "Warning: mysqli_query() expects at least 2 parameters, 1 given in" I had that on line 158, but now i get on line 156 I start to do PHP and mysql few weeks ago, only respond i get from teacher is search and search. <?php if (isset($_POST['username'])) { $searchq = $_POST['username']; mysqli_query("SELECT * FROM login WHERE username='$searchq'")or die ("could not search"); while($row = mysqli_fetch_array($con, $query)) { $username = $row['username']; $password = $row['password']; $age = $row['age']; $phonenumber = $row['phonenumber']; $nationality = $row['nationality']; mysqli_query("INSERT INTO admin SET username ='$username', password='$password', age='$age', phonenumber='$phonenumber', nationality='$nationality'" ) ; echo"Data successfully inserted"; } } ?> When i search i see this type of code "$data = mysqli_query" add variable before mysqli What should I do, to make it work. And send record from one table to another. Thank you Quote Link to comment Share on other sites More sharing options...
Barand Posted January 16, 2015 Share Posted January 16, 2015 1. You need to assign the results of a SELECT query to a result object 2. mysqli_query requires the db connection object as the first argument 3. mysqli_fetch_xxxxx requires the result object as the argument. All you need is a single INSERT ... SELECT query. INSERT INTO admin (username, password, age, phonenumber, nationality) SELECT username, password, age, phonenumber, nationality FROM login WHERE username='$searchq' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.