[Solved] Turning a SQL row into an array

If you only want specific associative properties from all columns queried from the MySQL call, just set them in an array with their respective properties: $categoriesTest = array(); $sql = “SELECT * FROM `respondent_data` WHERE `respondent_firstname` = ‘John'”; $result = mysqli_query($conn, $sql); while($row = mysqli_fetch_assoc($result)) { $categoriesTest[] = array( ‘respondent_sdo’ => $row[‘respondent_sdo’], ‘respondent_dcto’ => $row[‘respondent_dcto’], … Read more

[Solved] How can I avoid SQL injection in my code below? [duplicate]

As suggested, prepared statements are the best way to achieve good protection from SQL injection. Shortened Example You will need to add entries to fill in all columns you wish to insert. $email = $_POST[‘e-mail’]; $fn = $_POST[‘firstname’]; $ln = $_POST[‘lastname’]; if ($stmt = $mysqli->prepare(“INSERT INTO `newcartdb`.`orders`(Email,Firstname,Lastname) values(?,?,?)”) { $stmt->bind_param(“sss”, $email, $fn, $ln); “sss” – … Read more

[Solved] mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user ‘uname’@’localhost’ (using password: YES) in /all_pts.php on line 16 [duplicate]

mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user ‘uname’@’localhost’ (using password: YES) in /all_pts.php on line 16 [duplicate] solved mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user ‘uname’@’localhost’ (using password: YES) in /all_pts.php on line 16 [duplicate]

[Solved] How to loop table in php [duplicate]

There are multiple issues with your current code. You fetch the first row with $row = mysqli_fetch_array($select); (line 3), but you don’t do anything with it. This means that the first result is discarded. Your while loop attempts to loop over an incorrect variable ($query is a string, not the result-object), and you’ve quoted it … Read more

[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