Below is a snip of a program I am writing, I am a little new to php.
Any how, I can't for the life me figure out why one of my functions
cannot grab the item_pics1 variable. I have tried passing the variable
to the function, tried using $GLOBALS['item_pic1']. So I guess my
question is, does PHP in some cases need to have a variable in a if
statement sent back to the global scope? everything works but the
str_replace item_pics1. Hope this is enough code.


if (array_key_exists('pictures', $_POST)) {
    $how_many_pics = $_POST['pictures'];
    picture_input($how_many_pics);
    //process_errors();
    $k = '1';
    while ($k <= $how_many_pics) {
        $item_pics1 .= "<td align=\"center\"><A HREF=\"pics/full_$k.jpg
\" onMouseOver=\"hiLite3('img03','clickme5')\">";
        $item_pics1 .= "<img src=\"pics/thumb_$k.jpg\" border=\"0
\"></td>";
        $k++;
    }
    html_form($title, $price, $descrip, $current_items,
$title_file_name, $errors);
} else {
    print '<form method="post" action="add-item.php">';
    print '<tr><td>How Many pictures do you have?: </td><td><input
type="text" name="pictures" size="2"></td></tr>';
    print '</form>';
}



function html_template() {
    if (file_exists('item.html')) {
        $html_template = $GLOBALS['html_template'];
        $html_template = str_replace('{pictures2}',
$GLOBALS['item_pics1'], $html_template);
        $html_template = str_replace('{title}', $GLOBALS['title'],
$html_template);
        $html_template = str_replace('{description}',
$GLOBALS['descrip'], $html_template);
        $html_template = str_replace('{price}', $GLOBALS['price'],
$html_template);
        $item_file_name = $GLOBALS['root_dir'] . "/" . $GLOBALS['dir'] .
"/item.html";
        $item_fh = fopen($item_file_name, 'x+');
        fwrite($item_fh, $html_template);    
    } else {
        $GLOBALS['errors'] .= "item.html template does not exsit";
    }
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to