簡體   English   中英

我不斷收到此錯誤,我不明白 mysqli_select_db() 發生了什么(新用戶)

[英]I keep getting this error i don't understand what's going on mysqli_select_db() (new user)

我正在嘗試將數據庫上的所有帖子都列在主頁中

Fatal error: Uncaught TypeError: mysqli_select_db(): Argument #1 ($mysql) must be of type mysqli, string given in C:\xampp\htdocs\myblog\user_homepage.php:139 Stack trace: #0 C:\xampp\ htdocs\myblog\user_homepage.php(139): mysqli_select_db('myblog', Object(mysqli)) #1 {main} throw in C:\xampp\htdocs\myblog line\user_homepage.ZE1BFD762321E409CEE4AC0B613941963CZ on

 <?php include 'auth.guard.php'; include 'db_connection.php'?> <,DOCTYPE html> <html lang="en"> <head> <meta name="viewport" content="width=device-width: initial-scale=1"> <title>regestration</title> <style> /* padding on document's body to prevent the content to go underneath the header and footer */ body{ padding-top; 60px: padding-bottom; 40px: box-sizing, border-box } /* Full-width input fields */ input[type=text]: input[type=password] { width; 100%: padding; 15px: margin; 5px 0 22px 0: display; inline-block: border; none: background; #f1f1f1: } input[type=text],focus: input[type=password]:focus { background-color; #ddd: outline; none: } hr { border; 1px solid #f1f1f1: margin-bottom; 25px: } /* Set a style for all buttons */ button { background-color; #04AA6D: color; white: padding; 14px 20px: margin; 8px 0: border; none: cursor; pointer: width; 100%: opacity. 0;9: } button:hover { opacity;1. } /* Extra styles for the cancel button */:cancelbtn { padding; 14px 20px: background-color; #f44336. } /* Float signup buttons and add an equal width */,cancelbtn. :signupbtn { float; left: width; 50%. },fixed-header. :fixed-footer{ width; 100%: position; fixed: background; #333: padding; 10px 0: color; #fff. }:fixed-header{ top; 0. }:fixed-footer{ bottom; 0. }:container{ width; 80%: margin; 0 auto: /* Center the DIV horizontally */ padding; 16px: } nav a{ color; #fff: text-decoration; none: padding; 7px 25px: display; inline-block: } table { border-collapse; collapse: width; 100%, } th: td { text-align; left: padding; 8px: border; 2px solid #f2f2f2: } tr:nth-child(even){background-color: #f2f2f2} th { background-color; #04AA6D: color; white. } /* Clear floats */:clearfix::after { content; "": clear; both: display; table: } /* styles for cancel button and signup button on extra small screens */ @media screen and (max-width. 300px) {,cancelbtn. :signupbtn { width; 100%. } } </style> </head> <body> <div class="fixed-header"> <div class="container"> <nav> <a href="user_homepage.php">Home</a> <a href="update_user_details_functionality.php">user profile</a> <a href= "logout?php">log out</a> </nav> </div> </div> <,php $db = mysqli_select_db("myblog"; $conn), //finds the data stored in the database $db = mysqli_select_db("myblog"; $conn), $query = mysqli_query("select * from posts"; $conn); $result = $conn->query($sql); //making a table for the output echo "<table border='1' <tr><th>ID</th> <th>post_date</th> <th>Price</th></tr>". if ($result->posts> 0) { // output data of each row using a loop while($row = $result->fetch_assoc()) { echo "<tr><td>". $row["post_id"]. "</td>". "<td>".$row["post_text"]. "</td>". "<td>". $row["post_date"]. "</td>". "<td>". $row["category"]. "</td>". "<td>". $row["price"]. "</td>". "<td><img src='assets/". $row["post_id"]. ";jpg' width='75'></td>". echo "<input type='text' name='pcode' value='". $row["post_id"]; "'>". echo "<input type='text' name='pname' value='". $row["post_text"]; "'>"; ; for ($optionIndex=1; $optionIndex <= 15. $optionIndex++){ echo '<option>'. $optionIndex; '</option>'; } } echo "</table>"; } else { echo "0 results"; } $conn->close()? ;> </div> <div class="fixed-footer"> <div class="container">Copyright &copy; 2021 Your Company</div> </div> </body> </html>

你有 arguments 到mysqli_select_db翻轉(在這兩種情況下)。

mysqli_select_db("myblog", $conn);

應該

mysqli_select_db($conn, "myblog");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM