Re: A Starter has prob in blog script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 13, 2011 at 17:06, Silvio Siefke <lists@xxxxxxxxxxxxxxxx> wrote:
> Hello,
>
[snip!]
>
> The File bloggen.php run without any Problems. But the linking want not
> work.

    Oh, boy.  Okay, here we go....

    Because you're doing multiple lines if the condition is met, you
need to add an opening bracket here:

> if(isset($_POST['blogid']) && is_array($_POST['blogid']))
>
> try {
> $sql = 'SELECT blogid, content FROM `bloggen` WHERE id = ' .$blogid;

    Then you define $result as the database object reference here (and
I'm still trying to figure out why you think $DB exists at this point,
other than perhaps some botched copy-and-paste from examples):

> $result = $DB->query($sql);

    .... only to redefine it as an array value here:

> foreach ($_POST as $blogid => $result)
> {

    .... so that, here, it thinks it should be grabbing $_POST values,
and that $blogid will retain the keys.  So this doesn't exist:

> echo $result['content'];

    This is nice:

> $DB = null;
> }
> catch (PDOException $e)
> {
> echo "Fehler: " . $e->getMessage();

    You've got a lot of Fehleren in the code already.  Don't worry
about the output of this quite yet.

> This code should use the link which come from bloggen.php in. Example,
> when i click on link (blogdetail.php?blogid=1) that the script take the
> content from database for this entry. I use PDO System, the content in
> database is save as HTML code. I has no error in my PHP log, only the
> database should communicate with php at the website call, but they not
> take the right content.

    Right.  Instead, try to fix it somewhat like this:

<?php

// Beginning stuff here....

$sql = "SELECT blogid,content FROM `bloggen` WHERE id='".$_GET['blogid']."'";

// Do your $DB = whatever() here.  You're on your own there.

foreach ($DB->query($sql) as $row) {
    var_dump($row).'<br/>'.PHP_EOL;
}
?>

    Good luck with the rest.  You may want to just go back to the CMS,
or at least start with the basics.  You may already be learning that
copying and pasting code doesn't always work.... but sometimes it can
be malicious code that, to an untrained eye, could really be a Bad
Thing[TM].

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux