
Concept explainers
Can you help me here !
I get this wrong in my PHP code when I open it in localhost.
Fatal error: Uncaught mysqli_sql_exception: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond in C:\xampp\htdocs\labb4\moment3.php:18 Stack trace: #0 C:\xampp\htdocs\labb4\moment3.php(18): mysqli->__construct('studentmysql.mi...', 'arkh2000', 'qc18cg6j', 'arkh2000') #1 {main} thrown in C:\xampp\htdocs\labb4\moment3.php on line 18
<?php $page_title = "Moment 3 - Linneas Gästbok"; ?>
<?php include("includes/header.php"); ?>
<?php include("includes/mainmenu.php"); ?>
<article class="mainContent">
<?php echo "<h1>$page_title</h1><br/>"; ?>
<article class="guestbook-container">
<div class="left-flexbox">
<?php
$db = new mysqli(DBHOST, DBUSER, DBPASS, DBDATABASE);
//$db = new mysqli(DBHOST, DBUSER, DBPASS, DBDATABASE);
if($db->connect_errno > 0) {
die("Fel vid anslutning: " . $db->connect_error);
}
if(isset($_POST['user'])) {
$user = $_POST['user'];
$content = $_POST['content'];
// Lägg till data
$sql = "INSERT INTO guestbook(user, content)VALUES('$user', '$content')";
$result = $db->query($sql);
}
?>
<h3>Lämna en kommentar</h3>
<form action="moment3.php" method="post">
<label for="user">Ditt namn: </label>
<input type="text" name="user" id="user">
<br/>
<br/>
<label for="content">Ditt meddelande:</label>
<textarea class="textrutan-message" name="content" id="content" rows="10" cols="30"></textarea>
<br/><br/>
<input type="submit" name="postMessage" value="Posta ditt inlägg"><br/>
</form>
</div>
<div class="right-flexbox">
<?php
// SQL-fråga
$sql = "SELECT * from guestbook ORDER BY created DESC";
$result = $db->query($sql);
while($row = $result->fetch_assoc()) {
?>
<div class='div-containing-message'><h3><?= $row['user']; ?></h3>
<p> <?= $row['content']; ?></p>
<h4> <?= $row['created']; ?></h4></div>
<?php
}
?>
</div>
</article>
<?php include("includes/footer.php"); ?>

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- Which of the following data structure works on the "LIFO" principle? A Stacks. B Queues. Deque. D Hash tables.arrow_forwardWhat is the meaning of following step? LINK[LOC]:=AVAIL & AVAIL :=LOc Select one: a. Non of Above b. Return deleted node to the AVAIL list c. Delete Node d. Take Node from the AVAIL listarrow_forwardWhat are a few benefits of utilizing a hash index table?arrow_forward
- What is the meaning of following Step LINK[LOCP]:=LINK[LOC] Select one: a. Non of above b. Delete node N c. Delete first node d. Insert last nodearrow_forwardUsing TKinter, display the Dictionary in the Dictionary Based Object streamed in question #4. question #4: import socketimport json def receive_co2_data(host, port): """ Connects to a CO2 data server at the specified host and port, receives and prints the CO2 data fields, and gracefully closes the connection. Args: - host (str): The hostname or IP address of the server. - port (int): The port number to connect to. """ # Initialize socket client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: # Connect to server client_socket.connect((host, port)) print(f"Connected to {host}:{port}") # Receive and print the CO2 data fields buffer = "" while True: data = client_socket.recv(1024).decode() if not data: break # Buffer data and split into JSON-encoded objects buffer += data objects = buffer.split("\n") buffer =…arrow_forwardNeed help with this computer science problemarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





