PDA

View Full Version : Hoping someone can point me in the right direction (SQL Error)


fuse3k
09-15-2004, 11:53 PM
I'm using Acido's trick to run an external php script through a module. I ran into a few errors but with the help of the community I've been able to get most of them resolved. I'm currently stuck on one, however.


Fatal error: Cannot redeclare construct_phrase() (previously declared in /home2/fuse3k/public_html/forum/includes/functions.php:36) in /home2/fuse3k/public_html/forum/includes/functions.php on line 34


This one strikes me as odd because it makes reference to a PHP file that is part of VB3, one in which I did not edit. No files were editted during this mod install with the exception of the external script (all I did was replace "./includes" with the full path from the root: "/home2/fuse3k/public_html/downloads/includes")


Anyone have any ideas? I've spent most of the day trying to figure this out but with my limited knowledge of PHP and MySQL I'm not really getting anywhere.

Brian
09-15-2004, 11:56 PM
Do you have a construct_phrase() function somewhere in that module, or perhaps somehow have that function twice in your functions.php file?

Our Sponsors
 

fuse3k
09-16-2004, 12:46 AM
Thanks for responding Brian.

I checked functions.php and it make reference to construct_phrase() only once.

Functions.php, Lines 30-35


// ###################### Start construct phrase #######################
// this function is actually just a wrapper for sprintf
// but makes identification of phrase code easier
// and will not error if there are no additional arguments
function construct_phrase()
{

...and here's the module (nothing about construct_phrase())


<?php
ob_start();
require("/home2/fuse3k/public_html/downloads/pafiledb.php");
$output = ob_get_contents();
ob_end_clean();
eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('adv_portal_test') . '";');

?>


Hope this is helpful as I don't understand half of it.

fuse3k
09-16-2004, 12:49 AM
I'm not sure where "<?php BEGIN__VBULLETIN__CODE__SNIPPET " is coming from. That's not part of the code I pasted. Must be a VB3 bug(?).

Our Sponsors
 

Brian
09-16-2004, 01:23 AM
That bit of code shouldn't be in your functions.php file. Try uploading a fresh, un-hacked version of that file and see if that solves the problem. If so, afterwards you will need to reapply the change to that file.

fuse3k
09-16-2004, 01:52 AM
The only two times I've ever modified the functions.php file was for the vBa install and the v3Arcade install. Since I made backups of the functions.php file prior to both installs I first tried the pre-v3Arcade file, then the pre-vBa file, and both had no effect on the error in any way. The pre-vBa functions.php file was the original, unaltered copy.

Brian
09-16-2004, 02:03 AM
What do you have in your 'pafiledb.php' file?

fuse3k
09-16-2004, 02:20 AM
<?php
/*
paFileDB 3.1
)2001/2002 PHP Arena
Written by Todd
todd@phparena.net
http://www.phparena.net
Keep all copyright links on the script visible
Please read the license included with this script for more information.
*/
if (file_exists("./install.php")) { die("Error: The file install.php (paFileDB installer) still exists on the server! This is a security risk! Please delete the file to continue using paFileDB."); }
/*---------------------
If register_globals is off, we'll extract all of the superglobals so they can be used.
---------------------*/
if (!@ini_get('register_globals')) {
extract($_GET);
extract($_POST);
extract($_COOKIE);
extract($_SERVER);
}
$starttime = microtime();
$starttime = explode(" ",$starttime);
$starttime = $starttime[1] + $starttime[0];
$authmethod = "cookies"; //Set this to 'cookies' to use cookies to log you in (recommended.) If you're having problems with cookies, set this to 'sessions' and make sure a 'sessions' directory exists and is CHMODed to 777 (on *nix servers)
if ($authmethod == "sessions") {
session_save_path("./sessions");
session_start();
}
require "/home2/fuse3k/public_html/downloads/includes/mysql.php";
require "./includes/functions.php";
$pafiledb_sql->connect($db);
$config = $pafiledb_sql->query($db,"SELECT * FROM $db[prefix]_settings",1);
require "./lang/$config[13].php";
if ($login == "do") { include "./includes/$action/login.php"; exit; }
if ($ad == "logout") { include "./includes/admin/logout.php"; exit; }
if ($tm == "logout") { include "./includes/team/logout.php"; exit; }
$logged = "";
require "./includes/admin/auth.php";
require "./includes/team/auth.php";
if ($action == "download") {
include "./includes/download.php";
exit();
}
if ($logged == 1 && $ad == "backupdb") {
include "includes/admin/backupdb.php";
exit();
}
?>
<html>
<head>
<!--Download database powered by paFileDB 3.1. Visit http://www.phparena.net/pafiledb for your own free copy!-->
<!--If you're actually reading these comments, then you need a life....................-->
<title>paFileDB 3.1</title>
<style type="text/css">
<?php include "./styles/$config[11]/style.css"; ?>
</style>
<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<center>
<!--Begin main table-->
<table width="100%" height="99%" border="0" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF" class="table">
<tr>
<td width="100%" height="100%" valign="top">
<!--Begin header table-->
<table width="100%" height="100" border="0" cellpadding="2" cellspacing="0" class="table">
<tr>
<td width="25%" valign="center" align="center">
<a href="pafiledb.php"><img src="styles/<?php echo $config[11]; ?>/images/logo.gif" border="0"></a>
</td><td width="75%" valign="center" align="right">
<a href="pafiledb.php?action=search"><img src="styles/<?php echo $config[11]; ?>/images/search.gif" border="0"></a>&nbsp;&nbsp;<a href="pafiledb.php?action=stats"><img src="styles/<?php echo $config[11]; ?>/images/stats.gif" border="0"></a>&nbsp;&nbsp;<a href="<?php echo $config[5]; ?>"><img src="styles/<?php echo $config[11]; ?>/images/homepage.gif" border="0"></a>
</td></tr></table>
<!--End header table-->
<!--Begin page table-->
<?php
if ($logged == 1 && $ad != "logout") {
$width = 100;
} else {
$width = 80;
}
?>
<table width="<?php echo $width; ?>%" height="30" border="0" cellpadding="2" cellspacing="0" class="table" align="center">
<tr>
<td width="100%" valign="top" align="left" colspan="2">
<?php
$disable = $config[16];

if ($logged)
$disable = 0;
if ($action == "admin")
$disable = 0;
if ($teamlogged == 1 && $action !== "team")
tmlocbar("",$tuser,$str);
if ($teamlogged == 1 && $action == "team")
tmlocbar("<a href=\"pafiledb.php\" class=\"small\">$config[1]</a> :: $str[teamcenter]",$tuser, $str);
if (!$disable) {
switch ($action) {
case category:
include "./includes/category.php";
break;
case file:
include "./includes/file.php";
break;
case viewall:
include "./includes/viewall.php";
break;
case search:
include "./includes/search.php";
break;
case license:
include "./includes/license.php";
break;
case rate:
include "./includes/rate.php";
break;
case admin:
include "./includes/admin.php";
break;
case team:
include "./includes/team.php";
break;
case email:
include "./includes/email.php";
break;
case stats:
include "./includes/stats.php";
break;
default:
include "./includes/main.php";
break;
}
} else {
?>
<table width="100%" border="1" cellpadding="2" cellspacing="0" class="headertable" bordercolor="#000000">
<tr><td width="100%" colspan="2" class="headercell"><center><b>paFileDB</b></center></td></tr>
<tr><td width="5%" class="datacell" align="center" valign="middle"><img src="styles/<?php echo $config[11]; ?>/images/error.gif" border="0"></td><td width="95%" class="datacell"><?php echo $str[isdisabled]; ?>
</td></tr></table>
<?php
}
?>
</td></tr>
<tr>
<td width="50%" align="left">
<?php jumpmenu($db,$HTTP_SERVER_VARS['REQUEST_URI'],$pafiledb_sql,$str); ?>
</td><td width="50%" align="right"><?php echo "$str[time] $config[8]"; ?></td></tr></table>
<!--End page table-->
<!--Begin footer table-->
<table width="100%" height="30" border="0" cellpadding="2" cellspacing="0" class="footer">
<tr>
<td width="100%" valign="center" align="center">
<?php echo $str[power]; ?> paFileDB 3.1<br>2002 <a href="http://www.phparena.net" class="small" target="phparena">PHP Arena</a>
</td></tr>
<tr><td width="100%" valign="center" align="center">
<?php
$endtime = microtime();
$endtime = explode(" ",$endtime);
$endtime = $endtime[1] + $endtime[0];
$stime = $endtime - $starttime;
if ($config[12] == 1) {
?>
<table width="30%" border="1" cellpadding="2" class="stats" bordercolor="#000000">
<tr><td width="50%" align="left"><?php echo $str[exectime]; ?>:</td><td width="50%" align="right"><?php echo round($stime,4); ?> Seconds</td></tr>
<tr><td width="50%" align="left"><?php echo $str[numqueries]; ?>:</td><td width="50%" align="right"><?php echo $query_count; ?> Queries</td></tr>
</table>
<?php
if ($showqueries == 1) {
?>
<p>
<table width="100%" border="1" cellpadding="2" class="headertable" bordercolor="#000000">
<tr><td width="100%" class="headercell" align="center"><b>Queries Used</b></td></tr>
<?php echo $queries_used; ?>
</table>
<?php
}
}
?>
</table>
<!--End footer table-->
<!--End main table-->
</td></tr></table>



Btw, I appreciate you taking the time to help me with this. :) :)

-fuse3k (Brian)

Brian
09-16-2004, 03:43 AM
That file seems to be including quite a few other files, so I would suggest searching through the rest of them for 'construct_phrase'.

fuse3k
09-16-2004, 09:42 AM
I did a full search for files containing the phrase "construct_phrase" and all it found was these (all unmodified VB3 files): :mad:

vbulletin_cpcolorpicker.js
vbulletin_global.js
vbulletin_stdedit.js
vbulletin_templatemgr.js
vbulletin_wysiwyg.js

Is there a simplier way to display an external script though a module? is IFrame's an option? :confused:

Brian
09-16-2004, 11:42 AM
Actually, I think I see what the problem is... In the file you posted it looks like many of the files it's trying to include have the same name/location as vBulletin files and that may be what's messing it up. Try this... At the top of the file, right after <?php add this code:

chdir('/home2/fuse3k/public_html/downloads');

Then near the bottom, just Above this line:

?>
</table>
<!--End footer table-->
<!--End main table-->
</td></tr></table>

Add this:

chdir('/home2/fuse3k/public_html/name_of_forum_folder');

Let me know if that helps at all.

fuse3k
09-16-2004, 07:54 PM
Okay, I did that, no longer getting the previous error. How I get:


There seems to have been a slight problem with the Fuse3k.net Forum database.
Please try again by pressing the refresh button in your browser.

An E-Mail has been dispatched to our Technical Staff, who you can also contact if the problem persists.

We apologise for any inconvenience.


Here's the pafiledb.php file after those changes (I'm pretty sure I followed your instructions correctly:


<?php
chdir('/home2/fuse3k/public_html/downloads');
/*
paFileDB 3.1
©2001/2002 PHP Arena
Written by Todd
todd@phparena.net
http://www.phparena.net
Keep all copyright links on the script visible
Please read the license included with this script for more information.
*/
if (file_exists("./install.php")) { die("Error: The file install.php (paFileDB installer) still exists on the server! This is a security risk! Please delete the file to continue using paFileDB."); }
/*---------------------
If register_globals is off, we'll extract all of the superglobals so they can be used.
---------------------*/
if (!@ini_get('register_globals')) {
extract($_GET);
extract($_POST);
extract($_COOKIE);
extract($_SERVER);
}
$starttime = microtime();
$starttime = explode(" ",$starttime);
$starttime = $starttime[1] + $starttime[0];
$authmethod = "cookies"; //Set this to 'cookies' to use cookies to log you in (recommended.) If you're having problems with cookies, set this to 'sessions' and make sure a 'sessions' directory exists and is CHMODed to 777 (on *nix servers)
if ($authmethod == "sessions") {
session_save_path("./sessions");
session_start();
}
require "/home2/fuse3k/public_html/downloads/includes/mysql.php";
require "./includes/functions.php";
$pafiledb_sql->connect($db);
$config = $pafiledb_sql->query($db,"SELECT * FROM $db[prefix]_settings",1);
require "./lang/$config[13].php";
if ($login == "do") { include "./includes/$action/login.php"; exit; }
if ($ad == "logout") { include "./includes/admin/logout.php"; exit; }
if ($tm == "logout") { include "./includes/team/logout.php"; exit; }
$logged = "";
require "./includes/admin/auth.php";
require "./includes/team/auth.php";
if ($action == "download") {
include "./includes/download.php";
exit();
}
if ($logged == 1 && $ad == "backupdb") {
include "includes/admin/backupdb.php";
exit();
}
?>
<html>
<head>
<!--Download database powered by paFileDB 3.1. Visit http://www.phparena.net/pafiledb for your own free copy!-->
<!--If you're actually reading these comments, then you need a life....................-->
<title>paFileDB 3.1</title>
<style type="text/css">
<?php include "./styles/$config[11]/style.css"; ?>
</style>
<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<center>
<!--Begin main table-->
<table width="100%" height="99%" border="0" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF" class="table">
<tr>
<td width="100%" height="100%" valign="top">
<!--Begin header table-->
<table width="100%" height="100" border="0" cellpadding="2" cellspacing="0" class="table">
<tr>
<td width="25%" valign="center" align="center">
<a href="pafiledb.php"><img src="styles/<?php echo $config[11]; ?>/images/logo.gif" border="0"></a>
</td><td width="75%" valign="center" align="right">
<a href="pafiledb.php?action=search"><img src="styles/<?php echo $config[11]; ?>/images/search.gif" border="0"></a>&nbsp;&nbsp;<a href="pafiledb.php?action=stats"><img src="styles/<?php echo $config[11]; ?>/images/stats.gif" border="0"></a>&nbsp;&nbsp;<a href="<?php echo $config[5]; ?>"><img src="styles/<?php echo $config[11]; ?>/images/homepage.gif" border="0"></a>
</td></tr></table>
<!--End header table-->
<!--Begin page table-->
<?php
if ($logged == 1 && $ad != "logout") {
$width = 100;
} else {
$width = 80;
}
?>
<table width="<?php echo $width; ?>%" height="30" border="0" cellpadding="2" cellspacing="0" class="table" align="center">
<tr>
<td width="100%" valign="top" align="left" colspan="2">
<?php
$disable = $config[16];

if ($logged)
$disable = 0;
if ($action == "admin")
$disable = 0;
if ($teamlogged == 1 && $action !== "team")
tmlocbar("",$tuser,$str);
if ($teamlogged == 1 && $action == "team")
tmlocbar("<a href=\"pafiledb.php\" class=\"small\">$config[1]</a> :: $str[teamcenter]",$tuser, $str);
if (!$disable) {
switch ($action) {
case category:
include "./includes/category.php";
break;
case file:
include "./includes/file.php";
break;
case viewall:
include "./includes/viewall.php";
break;
case search:
include "./includes/search.php";
break;
case license:
include "./includes/license.php";
break;
case rate:
include "./includes/rate.php";
break;
case admin:
include "./includes/admin.php";
break;
case team:
include "./includes/team.php";
break;
case email:
include "./includes/email.php";
break;
case stats:
include "./includes/stats.php";
break;
default:
include "./includes/main.php";
break;
}
} else {
?>
<table width="100%" border="1" cellpadding="2" cellspacing="0" class="headertable" bordercolor="#000000">
<tr><td width="100%" colspan="2" class="headercell"><center><b>paFileDB</b></center></td></tr>
<tr><td width="5%" class="datacell" align="center" valign="middle"><img src="styles/<?php echo $config[11]; ?>/images/error.gif" border="0"></td><td width="95%" class="datacell"><?php echo $str[isdisabled]; ?>
</td></tr></table>
<?php
}
?>
</td></tr>
<tr>
<td width="50%" align="left">
<?php jumpmenu($db,$HTTP_SERVER_VARS['REQUEST_URI'],$pafiledb_sql,$str); ?>
</td><td width="50%" align="right"><?php echo "$str[time] $config[8]"; ?></td></tr></table>
<!--End page table-->
<!--Begin footer table-->
<table width="100%" height="30" border="0" cellpadding="2" cellspacing="0" class="footer">
<tr>
<td width="100%" valign="center" align="center">
<?php echo $str[power]; ?> paFileDB 3.1<br>2002 <a href="http://www.phparena.net" class="small" target="phparena">PHP Arena</a>
</td></tr>
<tr><td width="100%" valign="center" align="center">
<?php
$endtime = microtime();
$endtime = explode(" ",$endtime);
$endtime = $endtime[1] + $endtime[0];
$stime = $endtime - $starttime;
if ($config[12] == 1) {
?>
<table width="30%" border="1" cellpadding="2" class="stats" bordercolor="#000000">
<tr><td width="50%" align="left"><?php echo $str[exectime]; ?>:</td><td width="50%" align="right"><?php echo round($stime,4); ?> Seconds</td></tr>
<tr><td width="50%" align="left"><?php echo $str[numqueries]; ?>:</td><td width="50%" align="right"><?php echo $query_count; ?> Queries</td></tr>
</table>
<?php
if ($showqueries == 1) {
?>
<p>
<table width="100%" border="1" cellpadding="2" class="headertable" bordercolor="#000000">
<tr><td width="100%" class="headercell" align="center"><b>Queries Used</b></td></tr>
<?php echo $queries_used; ?>
</table>
<?php
}
}
chdir('/home2/fuse3k/public_html/forum');
?>
</table>
<!--End footer table-->
<!--End main table-->
</td></tr></table>

Brian
09-16-2004, 09:11 PM
File looks right... What was the error that was emailed to you (or you can view the source of that page and that will show the full error)?

fuse3k
09-16-2004, 09:38 PM
Here is the error from the source code:


Database error in vBulletin 3.0.3:

Invalid SQL:
SELECT IF(votenum &gt;= 1, votenum, 0) AS votenum, IF(votenum &gt;= 1 AND votenum != 0, votetotal / votenum, 0) AS voteavg,
thread.threadid, thread.title, replycount, postusername, postuserid, thread.dateline AS postdateline, thread.lastposter, thread.lastpost, IF(views&lt;=replycount, replycount+1, views) AS views, forumid, post.postid, pagetext, allowsmilie

,thread.iconid AS threadiconid, iconpath AS threadiconpath
, avatarpath, NOT ISNULL(avatardata) AS hascustom, customavatar.dateline AS avatardateline, avatarrevision

, attachment.filename, attachment.filesize, attachment.visible, attachmentid, counter, thumbnail, LENGTH(thumbnail) AS thumbnailsize
FROM vb3_thread AS thread
LEFT JOIN vb3_post AS post ON (post.postid = thread.firstpostid)
LEFT JOIN vb3_icon USING (iconid)
LEFT JOIN vb3_attachment AS attachment ON (post.postid = attachment.postid)
LEFT JOIN vb3_user AS user ON (user.userid = post.userid)



LEFT JOIN vb3_avatar as avatar ON (avatar.avatarid = user.avatarid)
LEFT JOIN vb3_customavatar as customavatar ON (customavatar.userid = user.userid)


LEFT JOIN vb3_deletionlog AS deletionlog ON (thread.threadid = deletionlog.primaryid AND type = 'thread')
WHERE forumid IN(2) AND thread.visible = 1 AND thread.open != 10 AND deletionlog.primaryid IS NULL
GROUP BY post.postid
ORDER BY postdateline DESC
LIMIT 15
mysql error: Table 'fuse3k_filedb.vb3_thread' doesn't exist

mysql error number: 1146

Date: Thursday 16th of September 2004 09:17:50 PM
Script: http://server3.woolnet.net/~fuse3k/?page=downloads
Referer:
Username: Unregistered
IP Address: removed

Brian
09-17-2004, 12:15 PM
Just after that chdir() near the end, try adding this:

require_once('./includes/config.php');

fuse3k
09-17-2004, 03:30 PM
No change. :(