php mysql code not working on server
Hi. I have all my code written for a uni assignment due tomorrow and ive been slapped round the face by hostforlife as the code which works really well on my localhost machine doesnt on their server. I think it may have something to do with the
$result = mysqli_stmt_get_result($stmt);
line of code. This is the new error message:
Fatal error: Call to undefined function mysqli_stmt_get_result() in /home/hear2see/public_html/index.php on line 90
But im really unsure and would be greatful of any help. I have made sure the mysqlnd driver is ticked in the PHP modules.
example of complete code for login page:
<?php
session_start();
header('Cache-Control: no cache'); //no cache
session_cache_limiter('private_no_expire');
?>
Login Form
<?php
$okay = TRUE;
$con = mysqli_connect('localhost','root','','python');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}//Establish connection
$query = "SELECT * FROM login WHERE email= ? AND password = ?"; //Check password and email
$crypt = crypt($_POST['email'],'$1$asdf1234$');
$cryptp = crypt($_POST['password'], '$1$asdf1234$');//Encrypt both entered username and passowrd to match with database content
$_SESSION['email'] = $crypt;//If email and passwords match, initiate session
$_SESSION['password'] = $cryptp;
$stmt = $con->prepare($query);
$stmt ->bind_param('ss', $_SESSION['email'], $_SESSION['password']);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$row = mysqli_fetch_array($result);
if (empty($row)){ //If results list empty display error
echo "<h2>Wrong username or password!<br></h2>";
echo "<a href=index.html>Login</a>";
$okay = FALSE;
} else {
$_SESSION['currentUser'] = ($row['user']);
if(isset($_SESSION['currentUser'])){
echo "<h1 style='text-align:center'>Welcome back ".$_SESSION['currentUser']. "!</h1>";//Display username logged in
print '<h3><p>Your Events<br><br></h3></p>';
//Display events logged in user has listed already. Union selects from multiple tables
$sql="SELECT * from london where user = ? UNION SELECT * from manchester where user = ? UNION SELECT * FROM bristol where user = ? UNION SELECT * FROM yorkshire where user = ? UNION SELECT * FROM newcastle where user = ? UNION SELECT * FROM lancashire where user = ? UNION SELECT * FROM glasgow where user = ? UNION SELECT * FROM liverpool where user = ? UNION SELECT * FROM edinburgh where user = ? UNION SELECT * FROM surrey where user = ? UNION SELECT * FROM birmingham where user = ? "; $stmt2 = $con -> prepare($sql);
$stmt2 -> bind_param('sssssssssss', $_SESSION['currentUser'], $_SESSION['currentUser'], $_SESSION['currentUser'], $_SESSION['currentUser'], $_SESSION['currentUser'], $_SESSION['currentUser'], $_SESSION['currentUser'], $_SESSION['currentUser'], $_SESSION['currentUser'], $_SESSION['currentUser'], $_SESSION['currentUser']);
mysqli_stmt_execute($stmt2);
$result1 = mysqli_stmt_get_result($stmt2);
if($stmt2){ //If $stmt exectuted, display results in Bootstrap hover table
echo "<table class='table table-hover'><thead>
<tr>
<th><h3>Artist</th>
<th><h3>Location</th>
<th><h3>Date</th>
<th><h3>Genre</th>
<th><h3>Preview</th>
</tr></thead>";
//While $row contains result, execute the while loop
while($row = mysqli_fetch_array($result1)) {
echo "<tr>";
echo "<td>" . $row['artist'] . "</td>";
echo "<td> <b>Venue: </b>" . $row['venue'] . "<p><b>Location: </b>" . $row['location'] . "</td>";
echo "<td>" . $row['datez'] . "</td>";
echo "<td>" . $row['genre'] . "</td>";
//Dispay Soundcloud link to a track by artist in $row['artist']
echo "<td>" . '<iframe width="100%" height="100" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/' . $row['link'] . '&color=000000&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false"></iframe>' . "</td>";
echo "</tr>";
}
echo "</table>";
} else echo "error";//If theres no $stmt display error
}
mysqli_close($con); //Close Connection
}
?>