Hi all,
I'm in the process of creating a script (one file to go), but PHP is throwing up the error "Fatal error: Call to a member function fetch_assoc() on a non-object in file/locatio.php on line 54"
Here is my code:
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
require_once("aconfig.php");
$eid = $_GET["event"];
echo '<html>
<head>
<title>Admin Control Panel :: PRINT TICKETS</title>
<style type="text/css">
body {
font-family: Helvetica, Arial;
}
</style>
</head>
<body>';
//start classes
$db = new db();
//connect to DB
//attempt it
$sql = new mysqli(db::$config['host'], db::$config['user'], db::$config['pass'], db::$config['db']);
//check for ERR
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
//
if($eid == "edit"){
echo '<h1>SELECT EVENT</h1>
<p>Select an event to print tickets for</p>
<p>';
$query = 'SELECT * from `tickets` ORDER by id';
$query = $sql->real_escape_string($query);
// Perform Query
$result = $sql->query($query);
// Loop Through Result
while ($row = $result->fetch_assoc()) {
echo '− <a href="ptickets.php?event='.$row[id].'">'.$row[event_name].'</a> <br />';
}
echo '</p>';
}else {
$query2 = 'SELECT * from `orders` WHERE `id` = '.$eid.', paid = "1"';
$query2 = $sql->real_escape_string($query2);
// Perform Query
$result2 = $sql->query($query2);
// Loop Through Result
while ($row2 = $result2->fetch_assoc()) {
echo '<table cellspacing="1" cellpadding="1" border="1" width="400">
<tbody>
<tr>
<td colspan="2"><strong>Online Ticket</strong></td>
</tr>
<tr>
<td width="300">
<p>Event: <strong>'.$row2[eventname].'</strong></p>
<p>Holder Name: <strong>'.$row2[name].'</strong></p>
<p>No. Adult tickets: <strong>'.$row2[adult_tix].'</strong><br />
No. Concession tickets: <strong>'.$row2[concess_tix].'</strong></p>
</td>
<td>
<p><u>STAFF</u></p>
<p><em>Rip this side off once ticket holder has entered.</em></p>
</td>
</tr>
</tbody>
</table>
<p> </p>';
}
}
echo '</body></html>';
?>
Error reporting is on.
Can anyone see what's wrong?
Thanks