Admin page loading content

#1

Okay here is my problem
When ever I want to add new image I log into an admin page where I load the content to a template where I load the information Name of product, what section it goes to, under what categories, size. I noticed I have a section that shows clean url. so the template which is suppose to pull that clean url is coming up with a page error that only shows code when clicking on the product. All the products show but when you click on a product to get info thats when the page breaks and shows code. I am trying to figure out which page I need to update to pull everything together. Don’t know if any of this makes sense to you all.

#2

Without having the code and a sample of the data needed to reproduce the problem, we cannot help. A dozen different people could have written your statement above, and each person could have a different problem that produces the exact same symptom.

We don’t have any idea how your code is accomplishing tasks, if you are copy/pasting and editing a template, if this is a database driven design, what a url looks like normally on your site, or what the broken url looks like.

Also, what kind of code is shown on the ‘broken’ page? Is it php code or html markup?

#3

This is the page http://www.nitrousgarage.com/BMW-Wheels

below is the code that in created by template if you click on any of the wheels. I understand the code is old and have to re-write the page but the code is generated from the admin template so trying to figure where its pulling from

<?
include_once("mysql_nitrousgarage.inc");

$clean_url = substr($PHP_SELF,1);
$clean_url = substr($clean_url,0,-5);
$q = "SELECT * from NG_product where active='Y' and clean_url='$clean_url'";
$results = mysql_query($q);
$row = mysql_fetch_array($results);
$product_id = $row["product_id"];
$product_name = $row["product_name"];
$sku = $row["sku"];
$description = $row["description"];
$meta_title = $row["meta_title"];
$meta_description = $row["meta_description"];

$magiczoomplus = "Y";
include_once("topnav.inc") 
?>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=400, user-scalable=no">

<div class="box-border">
	<a href="index.php">Home</a> &rsaquo; 
<?
if ($saved_category_id || !$saved_brand_id)
{
	if ($saved_category_id)
	        $q = "SELECT * from NG_category where category_id='$saved_category_id'";
	else
	        $q = "SELECT * from NG_product_category as pc, NG_category as c where pc.product_id='$product_id' and pc.category_id=c.category_id order by c.order_placement limit 1";
	$results = mysql_query($q);
	$row = mysql_fetch_array($results);
	$category_id = $row["category_id"];
	$category = $row["category"];
	$category_clean_url = $row["clean_url"];
	echo "<a href='$category_clean_url'>$category Wheels</a>";
}
else
{
	$q = "SELECT * from NG_brand where brand_id='$saved_brand_id'";
	$results = mysql_query($q);
        $row = mysql_fetch_array($results);
	$brand_id = $row["brand_id"];
	$brand = $row["brand"];
	$brand_clean_url = $row["clean_url"];
	echo "<a href='$brand_clean_url'>$brand Wheels</a>";
}
?>
 &rsaquo; <?echo $product_name?>
	<div class="page-numbers">
		<a href="<?echo $category_clean_url?>">&lsaquo; Back to <?echo $category?> Wheels</a>
	</div>
</div>

<div class="space20"></div>

<?
$image_id_arr = array();
$q1 = "SELECT * from NG_finish as f, NG_product_finish as pf, NG_finish_image as fi where f.active='Y' and f.finish_id=pf.finish_id and pf.active='Y' and pf.product_id='$product_id' and pf.product_finish_id=fi.product_finish_id and fi.active='Y' order by f.order_placement,fi.order_placement";
$r1 = mysql_query($q1);
while ($row1 = mysql_fetch_array($r1))
{
        $image_id = $row1["image_id"];
	$product_finish_name = $row1["product_finish_name"];
        if (!$main_image)
	{
                $main_image = "finish-$image_id.jpg";
		$selected_finish = $product_finish_name;
	}
        $image_id_arr[] = $image_id;
	$product_finish_name_arr[] = $product_finish_name;
}
?>

<div class="simpletable">
<div class="row">
	<div class="simplecell details-cll1">
		<div id="m-container">
			<img class="maxwidth" id="m-img" src="productphotos/<?echo $main_image?>" width=488>
		</div>
	</div>
	<div class="simplecell" style="width: 3%"></div>
	<div class="simplecell details-cll2">
		<!--<div class="details-share">
			<a href="#"><img src="images/facebook.jpg"></a>
			<br class="nomobile">
			<a href="#"><img src="images/twitter.jpg"></a>
			<br class="nomobile">
			<a href="#"><img src="images/mail.jpg"></a>
			<br class="nomobile">
			<a href="#"><img src="images/plus.jpg"></a>
		</div>-->
		<span class="details-title"><?echo $product_name?></span>
		<div class="style-number">Style: <?echo $sku?></div>
		<div class="selected-finish">Selected Finish: <span id=finish_layer><?echo $selected_finish?></span></div>

		<div class="space30"></div>
		<br>
		<div class="simpleinline">
			<div class="like-wheel">Like this Wheel?</div>
			<div class="more-info-via">GET MORE INFO VIA</div>
		</div>
		<div class="simpleinline">
			&nbsp; <a class="like-buttons" href="wheel-inquiry.php?product_id=<?echo $product_id?>&contact=C">CALL/TEXT</a> &nbsp; <a class="like-buttons" href="wheel-inquiry.php?product_id=<?echo $product_id?>&contact=E">EMAIL</a>
		</div>

		<div class="space50 nomobile"></div>
		<div class="space30"></div>
<?
while(list($k,$v) = each($image_id_arr))
{
	$product_finish_name = $product_finish_name_arr[$k];
	echo "<a href=\"javascript:void(0);\" onClick=\"pick('productphotos/finish-$v.jpg');document.getElementById('finish_layer').innerHTML='$product_finish_name';\"><img class='maxwidth' src='productphotos/finish-$v.jpg' width=145></a>";
}
?>
	</div>
</div>
</div>

<div class="space20"></div>

<div class="box-border">
	<div class="simpletable">
	<div class="row">
		<div class="simplecell product-desc">
<?echo $description?>
		</div>
		<!--<div class="simplecell price-notshow">
			<b>Why are prices not shown?</b>
			<br><br>
			Many of our customers frequently ask us why are the prices not show.
		</div>-->
	</div>
	</div>
</div>

<div class="space20"></div>
<?
$q = "SELECT * FROM NG_gallery WHERE active='y' and product_id='$product_id' ORDER BY featured desc, orderplacement limit 3";
$results = mysql_query($q);
if (mysql_num_rows($results) > 0) { ?>

<b><?echo $product_name?></b> Vehicle Gallery

<div class="page-numbers">
	CLICK IMAGE TO <b>ENLARGE | <a href="vehiclegallery.php?category_id=<?echo $category_id?>&product_id=<?echo $product_id?>">VIEW MORE</a></b>
</div>

<?
while ($row = mysql_fetch_array($results))
{
	$gallery_id = $row["gallery_id"];
	$gallery_title = $row["gallery_title"];
	$gallery_pics .= "<a href='productphotos/gallery_$gallery_id-l.jpg' class='MagicZoomPlus' id='Zoomer$gallery_id' rel='zoom-position: inner; zoom-width:400px;zoom-height:500px;' title='$gallery_title'><img class='maxwidth' src='productphotos/gallery_$gallery_id-l.jpg' width=380 border=0></a>";
}
?>


<div class="details-img-container">
<nobr>
<?echo $gallery_pics?>
</nobr>
</div>
<div class="details-img-container2">
<?echo $gallery_pics?>
</div>

<?}?>

<? include_once("footer.inc") ?>
#4

The code you are seeing on the page is the raw php code. The reason you are seeing it is because of the short opening php <? tags. All the opening php tags need to be changed to full <?php tags.

When posting code on the forum, please use bbocode code tags around it so that is it not mangled when displayed.

#5

okay trying to figure out what page is parsing this content. Will have to go one by one in the admin folder

#6

okay this is the page template

    <?
include('mysql_nitrousgarage.inc');

if ($add_category)
{
	if ($category_id)
	{
		$q = "UPDATE NG_category set on_display='$on_display',category='$category',description_top='$description_top',description_bottom='$description_bottom',meta_title='$meta_title',meta_description='$meta_description' where category_id='$category_id'";
		mysql_query($q);

		$q = "DELETE from NG_category_finish where category_id='$category_id'";
		mysql_query($q);
	}
	else
	{
		$q = "INSERT into NG_category set on_display='$on_display',category='$category',parent_category_id='$parent_category_id',clean_url='$clean_url',description_top='$description_top',description_bottom='$description_bottom',meta_title='$meta_title',meta_description='$meta_description'";

		mysql_query($q);
		$category_id = mysql_insert_id();
		symlink("shop.php","../$clean_url");

		$fp = fopen('../.htaccess', 'a+');
		fwrite($fp, "\n<Files $clean_url>\nForceType application/x-httpd-php\n</Files>\n");
		fclose($fp);
	}

	if ($image)
		copy($image,"productphotos/cat-$category_id.jpg");

	while(list($k,$v) = each($finish_array))
	{
		$q1 = "INSERT into NG_category_finish set category_id='$category_id',finish_id='$v'";
		mysql_query($q1);
	}

	header("Location: editcategory.php?category_id=$parent_category_id");
	exit();
}

if ($category_id)
{
	$q = "SELECT * from NG_category where category_id='$category_id'";
	$results = mysql_query($q);
	$row = mysql_fetch_array($results);
	while(list($k,$v) = each($row))
		$$k = $v;

	$q = "SELECT * from NG_category_finish where category_id='$category_id'";
	$results = mysql_query($q);
	while ($row = mysql_fetch_array($results))
		$db_finish_array[] = $row["finish_id"];
}
include('topnav.inc');
?>
<script>
function checkForm(signup)
{
        var flag       = 0;
        var warningMsg = "The following ERRORS have occured:\n\n";
        /* check that each required field has something in it */

        if (form1.clean_url.value == "")
        {
                warningMsg += "You must enter a clean url.\n";
                flag = 1;
        }

        /* if there are any warnings, output error message and stop submission */
        if (flag == 1)
        {
                warningMsg += "\n\nPlease correct these problems and resubmit";
                alert(warningMsg);
                return(false);
        }
        return(true);
}
</script>
<form action="<?echo $PHP_SELF?>" name=form1 method=POST enctype="multipart/form-data" <?if (!$category_id) { ?>onSubmit="return checkForm(this);"<?}?>>
<input type=hidden name=category_id value="<?echo $category_id?>">
<input type=hidden name=parent_category_id value="<?echo $parent_category_id?>">
<input type=hidden name=add_category value=Y>
<table>
<?
if (is_file("productphotos/cat-$category_id.jpg"))
	echo "<tr><td bgcolor=#e5e6e0><font size=-1>Category Icon:</td><td><img src=productphotos/cat-$category_id.jpg></td></tr>";
?>
<tr><td bgcolor=#e5e6e0><font size=-1>Add Icon</td><td><input type=file name=image></td></tr>
<tr>
<td bgcolor=#e5e6e0><font size=-1>Category</td>
<td><input type=text name=category value="<?echo $category?>"></td>
</tr>
<tr><td bgcolor=#e5e6e0><font size=-1>Clean URL</td>
<td>
<?if (!$category_id) { ?>
<input type=text name=clean_url value="<?echo $clean_url?>">
<?}else{?>
<?echo $clean_url?>
<?}?>
</td>
</tr>
<tr><td bgcolor=#e5e6e0 valign=top><font size=-1>Description Top</td>
<td>
<textarea id="description_top" name="description_top"><?echo $description_top?></textarea>
<script type="text/javascript">
CKEDITOR.replace( 'description_top',
    {
        filebrowserImageUploadUrl : 'twc-upload.php',

        filebrowserBrowseUrl : 'twc-chooser.php',
        filebrowserImageBrowseUrl : 'twc-chooser.php',
        width: '750',
        height: '350'
    });
</script>
</td></tr>
<tr><td bgcolor=#e5e6e0 valign=top><nobr><font size=-1>Description Bottom</td>
<td>
<textarea id="description_bottom" name="description_bottom"><?echo $description_bottom?></textarea>
<script type="text/javascript">
CKEDITOR.replace( 'description_bottom',
    {
        filebrowserImageUploadUrl : 'twc-upload.php',

        filebrowserBrowseUrl : 'twc-chooser.php',
        filebrowserImageBrowseUrl : 'twc-chooser.php',
        width: '750',
        height: '350'
    });
</script>
</td></tr>
<tr>
<td bgcolor=#e5e6e0><font size=-1>On Display</td>
<td>
<input type=radio name=on_display value="Y" <?if($on_display == "Y") echo "checked";?>> Yes
<input type=radio name=on_display value="N" <?if($on_display == "N") echo "checked";?>> No
</td>
</tr>
<tr>
<td bgcolor=#e5e6e0 valign=top><font size=-1>Finish</td>
<td>
<?
$q = "SELECT * from NG_finish where active='Y' order by order_placement";
$results = mysql_query($q);
while ($row = mysql_fetch_array($results))
{
	$finish_id = $row["finish_id"];
	$finish = $row["finish"];
	echo " <input type=checkbox name=finish_array[] value='$finish_id'";
	if (in_array($finish_id,$db_finish_array))
		echo " checked";
	echo "> $finish";
}
?>
</td></tr>

<tr><td bgcolor=#e5e6e0><font size=-1>Title Tag</td>
<td><input type=text name=meta_title value="<?echo $meta_title?>" size=63></td>
</tr>

<tr><td bgcolor=#e5e6e0 valign=top><font size=-1>Meta Description</td>
<td><textarea name=meta_description rows=4 cols=65><?echo $meta_description?></textarea></td>
</tr>


<tr><td colspan=2 align=center><input type=submit value="Add/Edit Category"></td></tr>

</table>
</form>
</body>
</html>