php - Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in -


im beginner , diploma student... have created database using localhost... im having problem viewing database... please me... hope u can me full code... error...

warning: mysqli_select_db() expects 2 parameters, 1 given in c:\xampp\htdocs\slr\view s110 pc01.php on line 10 cannot select db 

this code...

<?php $host="localhost"; // host name  $username="root"; // mysql username  $password=""; // mysql password  $db_name="slr"; // database name  $tbl_name="s110_pc01"; // table name   // connect server , select databse. mysqli_connect("$host", "$username", "$password")or die("cannot connect");  mysqli_select_db("$db_name")or die("cannot select db");  $sql="select * $tbl_name"; $result=mysqli_query($sql);  $count=mysqli_num_rows($result); ?>  <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#cccccc"> <tr> <td bgcolor="#ffffff">&nbsp;</td> <td colspan="4" bgcolor="#ffffff"><strong>delete multiple rows in mysql</strong> </td> </tr> <tr> <td align="center" bgcolor="#ffffff">#</td> <td align="center" bgcolor="#ffffff"><strong>software id</strong></td> <td align="center" bgcolor="#ffffff"><strong>software name</strong></td> <td align="center" bgcolor="#ffffff"><strong>installed date</strong></td> <td align="center" bgcolor="#ffffff"><strong>expiry date</strong></td> <td align="center" bgcolor="#ffffff"><strong>product key</strong></td> </tr>  <?php while($rows=mysqli_fetch_array($result)){ ?>  <tr> <td align="center" bgcolor="#ffffff"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> <td bgcolor="#ffffff"><? echo $rows['soft_id']; ?></td> <td bgcolor="#ffffff"><? echo $rows['soft_name']; ?></td> <td bgcolor="#ffffff"><? echo $rows['installed_date']; ?></td> <td bgcolor="#ffffff"><? echo $rows['expiry_date']; ?></td> <td bgcolor="#ffffff"><? echo $rows['product_key']; ?></td> </tr>  <?php } ?>  <tr> <td colspan="5" align="center" bgcolor="#ffffff"><input name="delete" type="submit" id="delete" value="delete"></td> </tr>  <?php  // check if delete button active, start  if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "delete $tbl_name soft_id='$soft_id'"; $result = mysqli_query($sql); } // if successful redirect delete_multiple.php  if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;url=view s110 pc01.php\">"; } } mysqli_close(); ?>  </table> </form> </td> </tr> </table> 

if check php manual here: http://php.net/manual/fr/mysqli.select-db.php

you see function mysqli_select_db take 2 params in input.

bool mysqli_select_db ( mysqli $link , string $dbname )

so should have

// connect server , select databse. $conn = mysqli_connect($host, $username, $password) or die("cannot connect");  mysqli_select_db($conn, $db_name) or die("cannot select db"); 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -