Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]MYSQL na MYSQLI czyli przejscie z wersji php 5 na php 7
Zenobiusz
post
Post #1





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 17.05.2019

Ostrzeżenie: (0%)
-----


Pojawiają się błędy:

Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in /pistolet.php on line 34

Warning: mysqli_query() expects parameter 1 to be mysqli, string given in /pistolet.php on line 36

Warning: mysqli_error() expects exactly 1 parameter, 0 given in /pistolet.php on line 36

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

<?php require_once('Connections/pistolet.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 5) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysqli_real_escape_string($theValue) : mysqli_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysqli_select_db($database_pistolet, $pistolet);
$query_Recordset1 = "SELECT * FROM pistolety";
$Recordset1 = mysqli_query($query_Recordset1, $pistolet) or die(mysqli_error());
$row_Recordset1 = mysqli_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysqli_num_rows($Recordset1);


if(isset($_POST['search']))
{
$valueToSearch = $_POST['valueToSearch'];
// search in all table columns
// using concat mysql function
$query = "SELECT * FROM `pistolety` WHERE CONCAT(`ID`, `pistolet`, `marka`, `ilosc`) LIKE '%".$valueToSearch."%'";
$search_result = filterTable($query);

}
else {
$query = "SELECT * FROM `pistolety`";
$search_result = filterTable($query);
}

// function to connect and execute the query
function filterTable($query)
{
// $connect = mysqli_connect("localhost", "XXXXX", "XXXXX", "XXXXX");
$filter_Result = mysqli_query($connect, $query);
return $filter_Result;
}

?>

<!DOCTYPE html>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<html>
<head>
<title>PHP HTML TABLE DATA SEARCH</title>
<style>
table,tr,th,td
{
border: 1px solid black;
}
</style>
</head>
<body>

<form action="pistolet.php" method="post">
<input type="text" name="valueToSearch" placeholder="Value To Search"><br><br>
<input type="submit" name="search" value="Filter"><br><br>

<table width="60%" align="center">
<tr>
<th width="12%">ID</th>
<th width="28%">pistolet</th>
<th width="28%">marka</th>
<th width="32%">ilość</th>
<th width="32%"></th>
</tr>

<!-- populate table from mysql database -->
<?php while($row = mysqli_fetch_array($search_result)):?>
<tr>
<td align="center"><?php echo $row['ID'];?></td>
<td align="center"><?php echo $row['pistolet'];?></td>
<td align="center"><?php echo $row['marka'];?></td>
<td align="center"><?php echo $row['ilosc'];?></td>
<td align="center"><a href="rekordd.php?ID=<?php echo $row['ID']; ?>"><img src="image/delete.png" width="20" height="16"></a></td>
</tr>
<?php endwhile;?>
</table>
</form>

</body>
</html><?php
mysql_free_result($Recordset1);
?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 28.09.2025 - 07:51