Hi all,
I am getting the error "Fatal error: Call to undefined method mysqli::fetch_assoc() in {file} on line 38"
I'm getting quite annoyed because I cannot see what is wrong with it.
Here is my code:
<?php
//load DB and CONFIG
require_once("./config.php");
//load theme
$html = file_get_contents("./theme.html");
//start classes
$db = new db();
//replace valued variables on tpl
//note: you MUST use this if you wish to use PHP on your template!!!!!!
$html = str_replace('{sitename}', $sitename, $html);
$html = str_replace('{copyright}', $copyright, $html);
//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();
}
//
//main body
$content = '<p><strong>Select your Event</strong></p>
<p>Please select an event from below:</p>
<table cellspacing="1" cellpadding="1" border="1" align="center" width="50%">
<tbody>';
//perform DB query
$query = 'SELECT * from `tickets` WHERE `open` = 1 ORDER by id';
// Perform Query
$result = $sql->query($query);
// Loop Through Result
while ($row = $sql->fetch_assoc($result)) {
//this is the content
$content .= ' <tr>
<td style="text-align: center;">
<p>Event: <strong>'.$row['event_name'].'</strong></p>
<p>Venue: <strong>'.$row['location'].'</strong></p>
<p>Date: <strong>'.$row['date'].'</strong></p>
<hr />
<p><strong>PRICING</strong></p>
<p>Adult (regular): <strong>'.$currency.''.$row['adult_price'].'</strong></p>
<p>Concession: <strong>'.$currency.''.$row['concession_price'].'</strong></p>
<hr />
<p><a href="order.php?event='.$row['id'].'"><img border="0" src="images/order_btn.gif" alt="" /></a></p>
</td>
</tr>';
}
$content .= ' </tbody>
</table>
<p> </p>';
//set page title
$html = str_replace('{pagename}', 'Select Event', $html);
//replace for the content
$html = str_replace('{content}', $content, $html);
/*QUERY TO ADD NEW EVENTS
INSERT INTO `tickets` (
`id` ,
`event_name` ,
`location` ,
`date` ,
`adult_price` ,
`concession_price`
)
VALUES (
NULL , 'Glasgow United vs Rangers', 'rydgroup Stadium', '2009-07-19', '12.00', '9.99'
) */
//provide content - packs up all the above changes and adds it to your theme. important!!!!
echo $html;
?>
What's wrong with it?
Thanks