|
Posted by J.O. Aho on 01/29/07 23:24
Pafcio wrote:
> hi,
>
> I've got a problem that I cant deal with:
>
> I've got a a simple class in a file browse.inc:
You should name your include files so that they end with .php, this for
most web servers aren't configured to treat .inc files as php scripts
and will therefore show them as plain text if someone tries to access
the file directly in a browser, and that would be bad if you would have
your username and login for a database stored in a .inc file.
> <?php
> class Connection
> {
> public $conn;
> public $result;
> public $resultMeta = array();
> }
>
> ?>
Try this instead
<?php
class Connection {
public $conn;
public $result;
public $resultMeta;
Connection() {
$this->resultMeta = array();
}
}
?>
In the same way as in C++ classes you should define variables and then
init them in the constructor and each class needs a constructor. PHP
isn't as strict about this as C++, but doing so you will easier get
things to work.
> the file browse.php looks like this:
> <?php
>
> include "browse.inc";
> ?>
This really don't do much, you should create the class variable too
> <?php
> print "\n <a href=http://localhost\DB\browse.php> Browse table
> </a>";
> ?>
I can notice you are using microsoft, the path you have given isn't
really valid path, should have been
echo "\n <a href=\"http://localhost/DB/browse.php\">Browse table</a>";
you should always put html tag values inside double quotes, this will
save you from a lot trouble, you use the \ as an escape character, which
makes it possible to include double quotes as output inside a double
quote (hope that didn't confuse you).
You can alway use http://validator.w3.org/ to check your html output is
correct.
--
//Aho
Navigation:
[Reply to this message]
|