Im starting to get the hang of PHP OOP and MVC, what i cannot seem to prevent are Notices: Undefined Variables. I understand i can switch this off, but i just want to know why proper way to get this done. Does anyone know.
Here is my code:
From my model m_settings:
function siteSettings()
{
if ($stmt = $FS->Database->query("SELECT * FROM site_settings WHERE id='1'"))
$row = mysqli_fetch_array($stmt);
}
This is just grabbing the results from a database and relaying them onto the view... which is the following:
v_index.php:
<tr><td>Browser Title: <input type="text" name="browser_title" value="<?php echo $row['browser_title'];?>" placeholder="Enter your sites browser title here."> </td></tr> <tr><td>Site Meta-Tags: <input type="text" name="met_tag" value="<?php echo $row['meta_tag'];?>" placeholder="Site Meta-Tags go here."> </td></tr> <tr><td>Description: <input type="text" name="description" value="<?php echo $row['description'];?>" placeholder="Site Description."> </td></tr>
All the code above is placed within a table.
This is the controller
<?php
include('../init.php');
include("models/m_settings.php");
$Settings = new Settings();
$FS->Template->load(APP_PATH . 'settings/views/v_index.php');
I can't understand why I'm getting the following Notices :
<br /><b>Notice</b>: Undefined variable: row in <b>/Applications/MAMP/htdocs/ukmocks/app/settings/views/v_index.php</b> on line <b>26</b><br />
The above happens for every $row echoed out...
I know i can add some code to the top of the page that will get rid of the notices, but i love to learn and want to know why this si happening
If anyone can help give me a shout
Thanks again

Help












