Will Shine wrote:
> <?php
> $up = 0;
> $topic = 14;
> $name = "testarticle";
> $title = "What's in a name";
> $abstract = "Learning Midgard from the manual is easy, but...";
> $content = "Learing Midgard from the manual is easy, but by actually
> trying "; $content .= "the examples yourself, you'll get a better feel
> for what is ";
> $content .= "the use of the various functions.";
> $author = 0;
> $url = "http://www.midgard-project.org/";
> $calstart = "0000-00-00";
> $caldays = 0;
> $icon = 0;
> $view = 0;
> $print = 0;
> $extra1 = "";
> $extra2 = "";
> $extra3 = "";
> $type = 0;
> mgd_errno();
There is no need to call this. Any call to a midgard function or method
first clears mgd_errno.
> $topic=mgd_get_topic(14);
> if($topic)
> {
> echo $topic->id;
> echo $topic->name;
So this prints '14news'
> }
> else
> {
> echo "bad news<br>";
> }
> $article=mgd_get_article();
> $article->up= 0;
> $article->topic=$topic->id;
> $article->name=$name;
> $article->title=$title;
> $article->abstract=$abstract;
> $article->content=$content;
> $article->author=$author;
which is 0. Setting author to 0 will yield an 'Object does not exist'...
> $article->create();
...here
> echo $article->id;
which prints nothing since the create failed.
> if(!$newid=$article->create())
Had the call above succeeded you would now have two copies with separate
IDs. But since author = 0...
> {
> echo mgd_errstr(mgd_errno());
... (I don't know why prints nothing), but you see...
> echo "problems";
...this, as expected.
> }
> if( ! $article )
This isn't right... $article exists, you explicitly created it. It isn't
invalidated by the failing 'create' call. Which explains...
> {
> echo "Creation of article '$name' failed.";
> echo "reason: " . mgd_errstr( mgd_errno() );
> } else
> {
> echo "Created article '$name' with id $article->id.";
... why you see this.
> }
> ?>
>
> If I change the user from 0 to something else, I get permission denied,
That means that you are not the topic owner.
Emile
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]