Re: [PHP] A Starter has prob in blog script

2011-04-14 Thread Silvio Siefke
Hello,


i have it running now. For complete the thread, write here the code with
it run.

?php
require_once inc/common.php;
$blogid = ((!empty($_GET['blogid'])) ? $_GET['blogid'] : '' );

try {
$sql = SELECT blogid, content FROM `bloggen` WHERE id=.(int)$blogid;
$result = $DB-query($sql);
foreach ($result as $var)  {
echo $var['content'];
}
$DB = null;
}
catch (PDOException $e) {
echo Fehler:  . $e-getMessage();
exit ();
}
?

Regards
Silvio

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



RE: [PHP] A Starter has prob in blog script

2011-04-13 Thread HallMarc Websites
 
 
 Regards
 Silvio
 
Sprechen sie deutsch?


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



Re: [PHP] A Starter has prob in blog script

2011-04-13 Thread Daniel Brown
On Wed, Apr 13, 2011 at 17:06, Silvio Siefke li...@silvio-siefke.de 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



Re: [PHP] A Starter has prob in blog script

2011-04-13 Thread Silvio Siefke
Am 14.04.2011 01:35, schrieb Daniel Brown:
 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].

Yes thats right what u write. When i make bad code with copy and paste,
what is with a CMS System? What i know about this code, what i know
about the backdoors, what i know which door is open for the Publisher or
what is with the goverment? This website is not online, i know i must
learn, but with books and howtos u learn not in two weeks all, i think
before we normal write perfect for the masters it need more time.

I nothing has to do with writing programs but i like work with computer,
and my unix servers running perfect and something i must do.

Im sorry when the questions is stupid, but at one point we all must
start. I try that i only post the really hard questions, but what is
hard for me and hard for the masters?

Have nice day.


Silvio




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