[php] gebruiken van class

Pagina: 1
Acties:

Onderwerpen


Acties:
  • 0 Henk 'm!

  • Vulpecula
  • Registratie: April 2001
  • Laatst online: 15-09 13:20
Ik ben al ongeveer 2 jaar bezig met php, maar heb nog nooit iets met classes gedaan. Toen ik op phpfreakz een artikel las over oop toen wilde ik het toch eens gaan proberen. Ik stuit nu op het volgende probleem. Ik krijg telkens deze foutmelding.

Warning: Bad arguments to implode() in D:\www\class1.php on line 31

Dit is de code

PHP:
1
2
3
4
5
6
7
  function printRecords()
  {
    $selectfield = implode(", ",$this->record); // regel met de error
    $query = "SELECT " . $selectfield . " FROM " . $this->table . 
    " ORDER BY " . $this->orderfield . " " . $this->orderrange;
    $result = mysql_query($query) or die(mysql_error());
  }


Weet iemand waarom ik $this->record niet in implode mag gebruiken? Dit is een variabele in de class. Die wordt van te voren eerst geset.

[ Voor 0% gewijzigd door Vulpecula op 07-11-2002 14:40 . Reden: Query aangepast, pas beter in layout ]


Acties:
  • 0 Henk 'm!

  • D2k
  • Registratie: Januari 2001
  • Laatst online: 02-09 11:02

D2k

bestaat het wel?

Doet iets met Cloud (MS/IBM)


Acties:
  • 0 Henk 'm!

  • sjroorda
  • Registratie: December 2001
  • Laatst online: 15:28
Is $this->record wel een array?

Acties:
  • 0 Henk 'm!

  • Vulpecula
  • Registratie: April 2001
  • Laatst online: 15-09 13:20
ja want hij wordt van te voren eerst geset.

[ Voor 0% gewijzigd door Vulpecula op 07-11-2002 14:46 . Reden: Spellingschek ]


Acties:
  • 0 Henk 'm!

  • Config
  • Registratie: Januari 2000
  • Laatst online: 06-01 00:49
Ik ben geen class expert, maar moet het geen record() zijn :?

Acties:
  • 0 Henk 'm!

  • Janoz
  • Registratie: Oktober 2000
  • Laatst online: 16-09 09:15

Janoz

Moderator Devschuur®

!litemod

hmm .. iemand was me voor...

Met die set methode.. Wordt daar dan wel een array aan meegegeven?

Ken Thompson's famous line from V6 UNIX is equaly applicable to this post:
'You are not expected to understand this'


Acties:
  • 0 Henk 'm!

  • Vulpecula
  • Registratie: April 2001
  • Laatst online: 15-09 13:20
Dit is een gedeelte van mijn class. De rest is niet echt belangrijk.
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class Survey
{   
  var $record;
  var $description;

  function setRecord($record, $description)
  {
    $this->record = $record;
    $this->description = $description;
  }
  function printRecords()
  {
    $selectfield = implode(", ",$this->record);
    $query = "SELECT " . $selectfield . " FROM " . $this->table . 
    " ORDER BY " . $this->orderfield . " " . $this->orderrange;
    $result = mysql_query($query) or die(mysql_error());
    
    echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
    //hier komt nog iets
    echo "</table>";
  }
}

$survey = new Survey;
$survey->setRecord("title", "Titel");

Acties:
  • 0 Henk 'm!

  • Vulpecula
  • Registratie: April 2001
  • Laatst online: 15-09 13:20
Oke stom van me was dus geen array moest [] wel erbij zetten. |:(

Acties:
  • 0 Henk 'm!

  • Janoz
  • Registratie: Oktober 2000
  • Laatst online: 16-09 09:15

Janoz

Moderator Devschuur®

!litemod

"title" is natuurlijk geen Array he :)

Probeer daarvoor in de plaats eens Array("title")

Ken Thompson's famous line from V6 UNIX is equaly applicable to this post:
'You are not expected to understand this'

Pagina: 1