php - Can connect to database using mysqli, but cannot get even the simplest query to execute
Get the solution ↓↓↓Solution:
Try adding the code below, and also add the global variable global $con; to your function as per below and then test ....
THE TOP OF THE DOCUMENT SHOULD LOOK LIKE THIS
<?php
include_once 'includes/searchtmysqli2.php';
$con = mysqli_connect("YOUR_HOST","YOUR_USERNAME","YOUR_PASSWORD","YOUUR_DB");
if (mysqli_connect_errno()) {
echo"
Failed to connect to the MySQL DB:".mysqli_connect_error();
}
?>
THEN EDIT YOUR FUNCTION TO LOOK LIKE THIS
<?php
global $con;
$sql = "SELECT * FROM records";
$results = mysqli_query($con, $sql);
$resultCheck = mysqli_num_rows($results);
if ($resultCheck > 0) {
while ($row = mysqli_fetch_assoc($results)) {
echo "<li>$row['Artist']</li>";
}
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the process class relies on proc_open, which is not available on your php installation.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.