SimplePortal
Support => English Support => Topic started by: danzou on March 16, 2010, 08:46:56 PM
-
Hi,
First of yes i know the website is out of date, but i dont dare to upgrade before i know that the Theme and all the extra stuff ive done will be saved and transfered to the upgraded forum/portal
On to my error.
I'm trying to create a php-block on my portal.
the block code looks like this:
<?php
$db_host = '#############';
$db_user = '#####';
$db_pass = '#####';
$db_db = 'ulduar-dkp';
mysql_connect ($db_host, $db_user, $db_pass);
mysql_select_db ($db_db);
print "<head><link rel=stylesheet type=text/css href='http://############/lewt.css' /><script src='http://static.wowhead.com/widgets/power.js'></script></head><body>";
$items = array();
print "<table border=0 cellspacing=0 cellpadding=0>";
$result = mysql_query("SELECT item_ctrt_wowitemid, item_name, item_buyer, raid_date
FROM ulduar_items AS i
INNER JOIN ulduar_raids AS r ON i.raid_id=r.raid_id
ORDER BY raid_date DESC LIMIT 7") or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
$time = $row['raid_date'];
print "<tr><td class=left><a href='http://www.wowhead.com/?item=" . $row['item_ctrt_wowitemid'] . "' target=_blank>[" . $row['item_name'] . "]</a></td></tr><tr><td class=right>Lootad av: <a href='http://eu.wowarmory.com/character-sheet.xml?r=Quel%27Thalas&n=" . $row['item_buyer'] ."' target=_blank><b>" . $row['item_buyer'] ."</b></a></td></tr>";
}
print "</table></body>";
?>
The error i get when i create this block is:
Parse error: syntax error, unexpected '<' in /var/www/Sources/SPortal.php(1572) : eval()'d code on line 1
Cut out from my SPortal.php from row 1568 to 1573
function sp_php($content = null)
{
global $context, $scripturl, $txt;
eval($content);
}
I have no idea why this happens.
the php file works fine if i create it standalone:
http://bollklubben.mine.nu/test/senastlewt/senaste_lewten.php
Any Idea's
or do i have to upgrade my portal for this to work? (done some special stuff to my current portal's blocks, so I hate to have to do all thoose things again.)
-
Don't use mysql_query, use db_query
Upgrading to 1.1.10 won't change anything regarding the theme.
Make sure PHP validation is off.
-
Where do i find the PHP Validation option to check if its off?
I changed mysql_query to db_query still getting the same error.
and for some reason the SMF package manager wont let me do the modifications to upgrade the forum. need to do it manually. Do i have to upgrade the forum for this to work?
-
Just this code seems to work fine:
$db_host = '#############';
$db_user = '#####';
$db_pass = '#####';
$db_db = 'ulduar-dkp';
mysql_connect ($db_host, $db_user, $db_pass);
mysql_select_db ($db_db);
print "<head><link rel=stylesheet type=text/css href='http://############/lewt.css' /><script src='http://static.wowhead.com/widgets/power.js'></script></head><body>";
$items = array();
print "<table border=0 cellspacing=0 cellpadding=0>";
$result = mysql_query("SELECT item_ctrt_wowitemid, item_name, item_buyer, raid_date
FROM ulduar_items AS i
INNER JOIN ulduar_raids AS r ON i.raid_id=r.raid_id
ORDER BY raid_date DESC LIMIT 7") or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
$time = $row['raid_date'];
print "<tr><td class=left><a href='http://www.wowhead.com/?item=" . $row['item_ctrt_wowitemid'] . "' target=_blank>[" . $row['item_name'] . "]</a></td></tr><tr><td class=right>Lootad av: <a href='http://eu.wowarmory.com/character-sheet.xml?r=Quel%27Thalas&n=" . $row['item_buyer'] ."' target=_blank><b>" . $row['item_buyer'] ."</b></a></td></tr>";
}
print "</table></body>";
-
Yeah the code works fine standalone its when i put it in a php-block i get the error in that block as stated above.
-
Did you try the code I quoted? It's without php open/close tags.
-
Sorry for that missed that you removed the open/close tag.
The block works but now i get an error in the Recent Post Block.
Database error: Table 'ulduar-dkp.smff_messages' doesn't exist
File: /var/www/Sources/SPortal.php
Row: 902
Is there somthing i can do to only have the ulduar-dkp prefix in that one block?
-
im guessing its the mysql_select_db ($db_db) is the thing that makes all the blocks after this block add ulduar-dkp. in the prefix
is there a way to deselect a db?
or can i do like this so that the block is in its own php code.
?>
<php?
$db_host = 'bollklubben.mine.nu';
$db_user = 'Danzou';
$db_pass = 'jagaeger3r';
$db_db = 'ulduar-dkp';
mysql_connect ($db_host, $db_user, $db_pass);
mysql_select_db ($db_db);
print "<head><link rel=stylesheet type=text/css href='http://bollklubben.mine.nu/test/senastlewt/lewt.css' /><script src='http://static.wowhead.com/widgets/power.js'></script></head><body>";
$items = array();
print "<table border=0 cellspacing=0 cellpadding=0>";
$result = mysql_query("SELECT item_ctrt_wowitemid, item_name, item_buyer, raid_date
FROM ulduar_items AS i
INNER JOIN ulduar_raids AS r ON i.raid_id=r.raid_id
ORDER BY raid_date DESC LIMIT 7") or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
$time = $row['raid_date'];
print "<tr><td class=left><a href='http://www.wowhead.com/?item=" . $row['item_ctrt_wowitemid'] . "' target=_blank>[" . $row['item_name'] . "]</a></td></tr><tr><td class=right>Lootad av: <a href='http://eu.wowarmory.com/character-sheet.xml?r=Quel%27Thalas&n=" . $row['item_buyer'] ."' target=_blank><b>" . $row['item_buyer'] ."</b></a></td></tr>";
}
print "</table></body>";
?>
<php?
-
solved, added a mysql_select_db in the end of the code with the db name of my forum.