- Joined
- Jun 5, 2015
- Messages
- 1
- Reaction score
- 0
I have all my code written for a uni assignment due tomorrow and ive been slapped round the face by [mucks edit] my 'host' as the code which works really well on my localhost machine doesnt on their server. I think it mayhave somthing to do witht 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');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<!-- Include Modernizr in the head, before any other Javascript -->
<script src="includes/js/modernizr-2.6.2.min.js"></script>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link href='http://fonts.googleapis.com/css?family=Ubuntu:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="bootstrap.css">
<link rel="stylesheet" href="stylez.css">
<title>Login Form</title>
</head>
<body style="color:#68748D; background-color:black; text-align:center">
<!-- Navbar creation - Code adapted from http://www.w3schools.com/bootstrap/bootstrap_case_navigation.asp -->
<nav class="navbar">
<div id="custom-bootstrap-menu" class="navbar navbar-static-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header"><a href="main.php"><img src="logo1.png" alt="logo" title="logo" style="width:140px; height:50px" class="navbar-brand"></a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
</button>
</div>
<!-- Collapsable navbar for smaller devices -->
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="main.php">Browse</a>
</li>
<li>
<a href="upload.php">Upload Event</a>
</li>
<li>
<a href="logout.php?">Logout</a><!-- If session is set display logout -->
</li>
</ul>
</div>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<?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://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
}
?>
<p></p>
</div>
</div>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
</body>
</html>
$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');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<!-- Include Modernizr in the head, before any other Javascript -->
<script src="includes/js/modernizr-2.6.2.min.js"></script>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link href='http://fonts.googleapis.com/css?family=Ubuntu:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="bootstrap.css">
<link rel="stylesheet" href="stylez.css">
<title>Login Form</title>
</head>
<body style="color:#68748D; background-color:black; text-align:center">
<!-- Navbar creation - Code adapted from http://www.w3schools.com/bootstrap/bootstrap_case_navigation.asp -->
<nav class="navbar">
<div id="custom-bootstrap-menu" class="navbar navbar-static-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header"><a href="main.php"><img src="logo1.png" alt="logo" title="logo" style="width:140px; height:50px" class="navbar-brand"></a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
</button>
</div>
<!-- Collapsable navbar for smaller devices -->
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="main.php">Browse</a>
</li>
<li>
<a href="upload.php">Upload Event</a>
</li>
<li>
<a href="logout.php?">Logout</a><!-- If session is set display logout -->
</li>
</ul>
</div>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<?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://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
}
?>
<p></p>
</div>
</div>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
</body>
</html>
Last edited by a moderator: