Re: newbie error, very strange



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
.



Relevant Pages

  • Re: [PHP] Optimized PHP
    ... quotes "s where needed as they are parsed by PHP and instead use single ... echo 'This is some text'. ... by PHP looking for variables or other escaped characters. ... In an application where I am having some different settings for each of the ...
    (php.general)
  • RE: [PHP] Cannot send a hyperlink
    ... Yes you do not need quotes in the mailfunction. ... [PHP] Cannot send a hyperlink ... Your problem is the Headers are missing which allows the html content to ...
    (php.general)
  • Re: nesting JS in echos
    ... from html to php. ... the conversion went well, it was to use a php session cookie to stop the ... single quotes and double quotes needed in the doc.write and variable ... my mistake was to leave the image path in single quotes; ...
    (comp.lang.php)
  • Re: nesting JS in echos
    ... i'm trying to bury a JS script to rotate a photo, ... converted from html to php. ... syntax of the single quotes and double quotes needed in the ...
    (comp.lang.php)
  • RE: [PHP] sloppy use of constants as strings. WAS: What does "<<<" mean?
    ... "A key may be either an integer or a string. ... heredoc, ... Those are raw PHP syntax strings, with no delimiters to set them off ... quotes and heredoc! ...
    (php.general)