Mysql not connecting Giving HTTP 500 But Mysqli is Connecting

June 1, 2018 438 views
MySQL PHP Ubuntu 16.04 Ubuntu

Sir, i have created a droplet.

Now i wanna to use some of my php files. which are present on local.

Now i have uploaded on the Digital Ocean Server and they are Showing HTTP 500 Error.

I have changed the connection to Mysqli, which is working fine.

Some of my function like mail() is not working.

I don;t know why mysql connection or code is not working. So please let me know the solution for it if any body knows.

2 Answers

Solved whit this

<?php
$mysqli = new mysqli("localhost", "myuser", "mypassword", "world");

/* check connection */
if (mysqliconnecterrno()) {
printf("Connect failed: %s\n", mysqliconnecterror());
exit();
}

$query = "SELECT CURRENT_USER();";
$query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5";

/* execute multi query /
if ($mysqli->multi_query($query)) {
do {
/
store first result set /
if ($result = $mysqli->storeresult()) {
while ($row = $result->fetch
row()) {
printf("%s\n", $row[0]);
}
$result->free();
}
/
print divider */
if ($mysqli->moreresults()) {
printf("-----------------\n");
}
} while ($mysqli->next
result());
}

/* close connection */
$mysqli->close();
?>

Have another answer? Share your knowledge.