PHP - mysqli_select_db() expects exactly 2 parameters, 1 given

   
Vista:

mysqli_select_db() expects exactly 2 parameters, 1 given

Publicado por OSVALDO (22 intervenciones) el 15/09/2017 00:58:43
hola amigos, espero me puedan ayudar, esto es jqgrid y no puedo llenar la grid pues tengo este error.
<b>Warning</b>: mysqli_select_db() expects exactly 2 parameters, 1 given in <b>E:\xampp\htdocs\ojojq\book.php</b> on line <b>17</b><br />
Error conecting to db.
el book.php es este.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
//database setting
$dbhost='localhost';
$dbuser='root';
$dbpassword='';
$database='jqpr';
$page = $_GET['page'];
// get the requested page
$limit = $_GET['rows'];
// get how many rows we want to have into the grid
$sidx = $_GET['sidx'];
// get index row - i.e. user click to sort
$sord = $_GET['sord']; // get the direction if(!$sidx)
$sidx =1;
// connect to the database
$db = mysqli_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysqli_error());
mysqli_select_db($database) or die("Error conecting to db.");
$result = mysqli_query("SELECT COUNT(*) AS count FROM buku");
$row = mysqli_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
if( $count > 0 ) {
     $total_pages = ceil($count/$limit);
}
else {
     $total_pages = 0;
}
if ($page > $total_pages) $page=$total_pages;
$start = $limit*$page - $limit; // do not put $limit*($page - 1)
$SQL = "SELECT * FROM book ORDER BY $sidx $sord LIMIT $start , $limit";
$result = mysqli_query( $SQL ) or die("Couldn t execute query.".mysqli_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0;
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
 $responce->rows[$i]['id']=$row[id];
 $responce->rows[$i]['cell']=array($row[id],$row[title],$row[author],$row[publisher],$row[year_published]);
 $i++;
}
echo json_encode($responce);
?>


y el html es este

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<html>
<head>
<title>jQGrid example</title>
<!-- Load CSS--><br />
<link rel="stylesheet" href="jqgrid/themes/ui.jqgrid.css" type="text/css" media="all" />
<!-- For this theme, download your own from link above, and place it at css folder -->
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/redmond/jquery-ui.css" type="text/css" media="all" />
<!-- Load Javascript -->
<script src="jqgrid/js/jquery.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js" type="text/javascript"></script>
<script src="jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
</head>
<body>
<table id="datagrid"></table>
<div id="navGrid"></div>
 
 
<script language="javascript">
jQuery("#datagrid").jqGrid({
   	url:'book.php',
    datatype: "json",
    colNames:['Id','Title', 'Author', 'Publisher','Year_published'],
    colModel:[
		{name:'id',index:'id', width:55,editable:false,editoptions:{readonly:true,size:10}},
		{name:'title',index:'title', width:80,editable:true,editoptions:{size:10}},
		{name:'author',index:'author', width:90,editable:true,editoptions:{size:25}},
		{name:'publisher',index:'publisher', width:60, align:"right",editable:true,editoptions:{size:10}},
		{name:'year_published',index:'year_published', width:60, align:"right",editable:true,editoptions:{size:10}}
	],
	rowNum:10,
	rowList:[10,15,20,25,30,35,40],
	pager: '#navGrid',
	sortname: 'no',
	sortorder: "asc",
	height: 210,
	viewrecords: true,
	caption:"Example"
});
jQuery("#datagrid").jqGrid('navGrid','#navGrid',{view:true,edit:true,add:true,del:true});
</script>
</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve

mysqli_select_db() expects exactly 2 parameters, 1 given

Publicado por xve (6649 intervenciones) el 15/09/2017 08:04:48
Hola Osvaldo, te falta un parametro en la instrucción: mysqli_select_db...

Tienes puesto:
1
mysqli_select_db($database);
prueba así:
1
mysqli_select_db($db, $database);

http://php.net/manual/es/mysqli.select-db.php
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Revisar política de publicidad