[Solved] Database Connection not working after migrating from PHP7.4 to PHP8.0

Looks like you’ve been relying on the ancient, long-deprecated behaviour that methods named the same as the class act as the constructor. This behaviour has finally been thrown out in PHP 8: Methods with the same name as the class are no longer interpreted as constructors. The __construct() method should be used instead. 0 solved … Read more

[Solved] PHP insert into not inserting any data

$sql = “INSERT INTO tasks (taskName, requestedBy, details, dateAdded) VALUES (‘$taskname’ ,’$requestedby’ ,’$details’, ‘$datenow’)”; // Removed quotes from columns, and added missing quote on datenow Please note, this technique for adding values into the database is very insecure, and is prone to SQL injection attacks. 5 solved PHP insert into not inserting any data

[Solved] PHP insert into not inserting any data

Introduction If you are having trouble getting your PHP insert into statement to work, you are not alone. Many developers have encountered this issue and have had difficulty finding a solution. This article will provide an overview of the problem and offer some tips and tricks to help you get your PHP insert into statement … Read more

[Solved] How to store users transactions history on database and how to show the transaction history whenever a user wants to view their transactions

How to store users transactions history on database and how to show the transaction history whenever a user wants to view their transactions solved How to store users transactions history on database and how to show the transaction history whenever a user wants to view their transactions

[Solved] What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such

TL;DR Always have mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); in your mysqli connection code and always check the PHP errors. Always replace every PHP variable in the SQL query with a question mark, and execute the query using prepared statement. It will help to avoid syntax errors of all sorts. Explanation Sometimes your MySQLi code produces an error … Read more

[Solved] This update query won’t update record

<?php if (isset($_GET[‘edit’])) { ?> <form action=”index.php” method=”post”> <input type=”text” name=”id” value=”<?=$id;?>”> <input type=”text” name=”nieuweprijs” placeholder=”vul nieuwe prijs in”> <input type=”submit” name=”submitnieuweprijs” value=”verzenden”><form> <?php } if (isset($_POST[‘submitnieuweprijs’])) { $nieuweprijs = Safesql($_POST[‘nieuweprijs’]); $id = Safesql($_GET[‘id’]); if(!$mysqli->query(“UPDATE prijzen SET prijs=””.$nieuweprijs.”” WHERE id='”.$id.”‘”)) { echo $mysqli->error;} Laden(0); } } ?> $id is the value obtained from the query … Read more

[Solved] php ‘ISSET’ function not working. OR the code skips my if statements

In addition to the supplied answer(s), I would like to suggest doin the following: // Before anything else, start your session if (!isset($_SESSION)) { session_start(); } // Next, check if your form is actually submitted if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) { if (isset($_POST[‘…’])) { } elseif (isset($_POST[‘…’])) { } } ?> <!– Keep PHP and html … Read more

[Solved] I want to access another server database in PHP

Just read errors and correct it.. <?php $server2 = ‘192.168.1.211’; $con = mysqli_connect($server2,’root’,’password’,’vvani’); // here, $server2 is variable, not constant if (mysqli_connect_errno()) { echo “Failed to connect to MySQL: ” . mysqli_connect_error(); } 2 solved I want to access another server database in PHP

[Solved] Use of global for mysqli_insert_id()

class MySQLiConnection { private static $conn = null; private function __construct() { } public static function getConnection() { if (static::$conn === null) { static::$conn = mysqli_connect(/* your params go here */); } return static::$conn; } } Then you can replace all global $conn with $conn = MySQLiConnection::getConnection() 4 solved Use of global for mysqli_insert_id()

[Solved] Pagination data

You need to study their code more, dont just copy&paste. You told the program to echo those variables and it echoed them for you. In the tutorial they seem to store all the ‘paginatable’ data in the $list, so you need to look into that. $id = $row[“id”]; prints id column from the current table … Read more

[Solved] php pull field with variable+string

Context: OP posted his code within the comments; https://pastebin.com/LM1ecp13 Solution: This line;$fetch = mysqli_fetch_array(mysqli_query($conn,”SELECT id, name, price FROM stock WHERE id=’$cart[wid]'”)); Is the problem. You are selecting id, name, price but you are missing 28price hence why you are getting the undefined index error… Your query should be “SELECT id, name, price, 28price FROM stock … Read more

[Solved] Connect to Database and Insert data – Php & MySQL –

Try die() like following in your php file: $connection = mysqli_connect($host,$user,$password,$database); /* check connection */ if (mysqli_connect_errno()) { die(“Connect failed: “, mysqli_connect_error()); } $query=”insert into users(firstname, lastname)VALUES(‘”.$_REQUEST[‘nome’].”‘,'”.$_REQUEST[‘cognome’].”‘)”; if ($result = mysqli_query($connection ,$query)) { print(“Success!”); } 3 solved Connect to Database and Insert data – Php & MySQL –