Answers for "sql php"

PHP
17

query sql in php

$sql = "SELECT id, firstname, lastname FROM MyGuests";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
    }
} else {
    echo "0 results";
}
$conn->close();
Posted by: Guest on February-05-2020
0

mssql php

$dbh = new PDO ("mssql:host=$hostname;dbname=$dbname","$username","$pw");

$hostname may need to be configured as either...
$hostname.':'.$port;
Posted by: Guest on June-04-2021
0

mssql php

$hostname.','.$port;
Posted by: Guest on June-04-2021
1

php mysql

In order to send data to a databse securely use prepared statements otherwise 
you can get attacked by an SQL Injection easily.
----
https://www.w3schools.com/php/php_mysql_prepared_statements.asp
Posted by: Guest on October-28-2020

Browse Popular Code Answers by Language