Php – Undefined Variable in php

phpundefined

I have inherited some code for a custom CMS that is a little out of my league and keep stumbling over the same errors, Notice: Undefined variable: media in /Applications/MAMP/htdocs/Chapman/Chapman_cms/admin/team-2.php on line 48. This is supposed to create new users and edit old users. However, it does not work when I try and add a new user.

Below is the pertinant code:

$db = new database("mysql",$dbHost,$dbName,$dbUser,$dbPass);
$target = 'add';
if ($_GET['task'] == 'edit') {
$media = $db->get_row(edit_media_item($db, $_GET['team_id']));
$target = 'update';

<p><label for="copy">Full Name:</label>
    <input type="text" name="title" value="<?=$media['title']?>" />
    <textarea name="media" id="media" cols="30" rows="5" style="width: 100%"><?=$media['copy']?></textarea></p>
    <input type="hidden" name="process" value="<?=$target.",copy,4,team-1,".$media['id'].""?>">
    <p><input type="submit" name="save" value="Submit" />
    <input type="reset" name="reset" value="Reset" /></p>
    </form>

Any help would be much appreciated.

Best Solution

To remove the notice in the right way is to do this with the code

<?php if(isset($media['copy'])){ echo $media['copy']; } ?>