Part of the EllisLab Network
pMachine Pro has been replaced by ExpressionEngine, our full featured web publishing solution. Please consider upgrading.
You can download pMachine Pro here: Download pMachine Pro  |  Download Language Packs
   
 
Trying to create a new function : weblog_OFE
Posted: 19 July 2004 06:42 PM   [ Ignore ]  
Research Assistant
RankRankRank
Total Posts:  326
Joined  2003-12-21

Hi,

I would like my users to have a place on the index of their blog where they could write a text or make a menu with a list of links to permalinks,
I mean some personalized content without accessing the templates.
That place would be somewhere in the sidebar.

Now, to my mind, the best way to do this, is to simply display the body of the very first entry of the blog.

There’s a function quite similar to this : weblog_title_list

So I based the code below on that function,
I removed all the unnecessary stuff and tried to make it displays the body.
Then I added the new function in acrchives.fns.php

The whole code is not displaying correctly here on the forum,
so I put the code in a txt file

And here’s the code I from my template :

<?php
$wtl[
'limit'] = "1";
$wtl['orderby'] = "oldest";
$wtl['weblog'] = "weblog";
?>
<?php weblog_OFE
($wtl); ?>


But unfortunately that gives an error :

MySQL Error: 1064  You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ' 1' at line 6

which I’m not likely able to fix unless I learn PHP.
Could someone help please ?
Thanks by advance.

Profile
 
 
Posted: 20 July 2004 11:19 PM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  2002-06-19

Right before the “$query = new DB_query($db, $q);” line, echo out the SQL query:

echo $q;

$query = new DB_query($db, $q);

That way you can see what the actual SQL query is and we’ll hopefully be able to find the problem.


Also, I would suggest not placing this function in the archives.fns.php file.  Instead, create a new PHP file (named whatever you want) with your new function and place it in the pm/scripts/ directory.  The function will then be accessible but it won’t require you to hack a backend file and thus you won’t have problems when you try to upgrade.

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 21 July 2004 02:58 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
RankRankRank
Total Posts:  326
Joined  2003-12-21

Here’s th echo of the query :

select weblog,body from pM_weblog where status = ‘open’ and preview =‘0’ and t_stamp <= ‘1090407158’ and x_stamp >= ‘1090407158’ and weblog = ‘weblog’ order by t_stamp asc limit , 1

I moved the script to the scripts/ folder and it generage that warning :

Warning: Cannot modify header information - headers already sent by (output started at /home/.sites/65/site113/web/pMachine/pm/scripts/weblog_OFE.php:1) in /home/.sites/65/site113/web/pMachine/pm/inc.lib.php on line 206

Profile
 
 
Posted: 21 July 2004 03:05 PM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  2002-06-19

1. It looks as though you may need to specify an “offset” in addition to the “limit”.  Simply set it to zero (0) if you don’t need one.

2. You probably have some space or blank lines at the beginning or end of the new file.  There can’t be any space before the opening “<?php” or after the closing “?>”.

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 21 July 2004 06:13 PM   [ Ignore ]   [ # 4 ]  
Research Assistant
RankRankRank
Total Posts:  326
Joined  2003-12-21

Thanks, it’s working now, but I couldn’t resolved the header issue.

The file with instructions on how to use is kept there.

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 233, on December 18, 2007 12:04 AM
Total Registered Members: 64508 Total Logged-in Users: 0
Total Topics: 81067 Total Anonymous Users: 0
Total Replies: 436294 Total Guests: 24
Total Posts: 517361    
Members ( View Memberlist )
Active Members: