Jump to content

Previously Working Code Not Working in WordPress


flattened

Recommended Posts

I am in the process of integrating my current site into WordPress. Because I do a lot of hand coding I downloaded the Exec-PHP plugin.

 

This is the current page I am moving : http://www.snookumz.com/you/graphics/swatches.php and here is the code:

 

include("cookiecheck.php"); 
include("http://www.snookumz.com/top.php"); 
include($headervar.$skin.$extension);
$sw= array();
require("swatch-list.php");
$count = count($sw);
$per_page = 45;
if (!isset($_GET['page']) || !is_numeric($_GET['page'])) {
	$page = 1;
}
$from = (($page * $per_page) - $per_page);
$x=$from; 
$show = $from+$per_page;
$total_results = $count;
$total_pages = ceil($total_results / $per_page);
echo "<div class='right'> Page ";
for($x=1;$x<$page;$x++){
	echo "<a href=\"?page=$x\">".$x."</a> ";
}
echo " <b>$page</b> ";
for($x=($page+1);$x<=$total_pages;$x++){
	echo "<a href=\"?page=$x\">".$x."</a> ";
}
echo "</div>";
echo "<div class='center'>";
while ($x<$show){
if($sw[$x])echo "$sw[$x] \n";
$x++;
}	echo "</div>";
echo "<div class='right'> Page ";
for($x=1;$x<$page;$x++){
	echo "<a href=\"?page=$x\">".$x."</a> ";
}
echo " <b>$page</b> ";
for($x=($page+1);$x<=$total_pages;$x++){
	echo "<a href=\"?page=$x\">".$x."</a> ";
}
echo "</div>";
include($footervar.$skin.$extension); 

The above code works perfectly.

 

 

After stripping the header and footer tags, I have this left, and moved it to WordPress:

$sw= array();
include("/URL/snookumz/you/graphics/swatch-list.php");
$count = count($sw);
$per_page = 45;
if (!isset($_GET['page']) || !is_numeric($_GET['page'])) {
	$page = 1;
}
$from = (($page * $per_page) - $per_page);
$x=$from; 
$show = $from+$per_page;
$total_results = $count;
$total_pages = ceil($total_results / $per_page);
echo "<div class='right'> Page ";
for($x=1;$x<$page;$x++){
	echo "<a href=\"&page=$x\">".$x."</a> ";
}
echo " <b>$page</b> ";
for($x=($page+1);$x<=$total_pages;$x++){
	echo "<a href=\"&page=$x\">".$x."</a> ";
}
echo "</div>";
echo "<div class='center'>";
while ($x<$show){
if($sw[$x])echo "$sw[$x] \n";
$x++;
}	echo "</div>";
echo "<div class='right'> Page ";
for($x=1;$x<$page;$x++){
	echo "<a href=\"&page=$x\">".$x."</a> ";
}
echo " <b>$page</b> ";
for($x=($page+1);$x<=$total_pages;$x++){
	echo "<a href=\"&page=$x\">".$x."</a> ";
}
echo "</div>";

 

But it returns the following error:

 

Parse error: syntax error, unexpected ‘<' in /URL/snookumz/wordpress/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()’d code on line 1

 

I went to the plugin's site and read everything so I know it's my code,  but I don't know where.  :shrug: I'd be less confused if it didn't work the first time, but it just doesn't work on the WordPress page.

 

Any help is greatly appreciated.  :-\ Thank you.

 

try not doing any <? at all.

The plugin is trying to eval your code. It already knows it's code, so you don't have to include <? before it.

What you're doing now is like this:

<?php
   <?php
      [code]
   ?>
?>

 

EDIT: wow, did you see how that screwed up the code and

 blocks? That's kinda what's happening on your pages.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.