-8

I'm quite new on PHP coding and would like to see If it's possible to get help of the code below. Apparently the error is only on line 6.

<?php
class DBWrapper
{   
    function DBWrapper($server,$db,$user,$pass)
    {        
        $this->Server = $server;
        $this->DB = $db;
        $this->User = $user;
        $this->Password = $pass;

        mysql_connect($this->Server, $this->User, $this->password) or
                    die("Can't connect, please check your settings. Here is the MySQL error: ".mysql_error());

        mysql_select_db($this->DB) or
                    die("Can't select DB, please check your settings. Here is the MySQL error: ".mysql_error());       
    }

I really hope to receive some help about this.

10
  • 4
    You should not post your username and password etc..
    – Matheno
    Commented Jan 5, 2015 at 16:22
  • 2
    Your code makes no sense at all!
    – Rizier123
    Commented Jan 5, 2015 at 16:23
  • 4
    Flagged for moderator attention to get a developer to remove the username/password: puu.sh/e6J9f/1bc72aeb79.png
    – AStopher
    Commented Jan 5, 2015 at 16:26
  • 1
    I advise you to change your password
    – Peter
    Commented Jan 5, 2015 at 16:31
  • 3
    I've deleted this question, pending removal of the edit history items by a Stack Exchange developer. It will likely be restored after that. I do still strongly recommend you change the login information on the server right away, @Bruno Commented Jan 5, 2015 at 17:50

2 Answers 2

3

This:

    $this->Server = $mysql3.000webhost.com;

You have no quotes on this "string", so it's being parsed as:

$this->Sever = somevariable concatenate with undefined/illegal constant concatenate with undefined constant

Perhaps

    $this->Server = '$mysql3.000webhost.com';

or something?

3
  • I think it should just be $this->Server = $Server e.d.
    – Peter
    Commented Jan 5, 2015 at 16:39
  • 2
    maybe, but that's up to OP to clarify.
    – Marc B
    Commented Jan 5, 2015 at 16:39
  • I've deleted this question, pending removal of the edit history items by a Stack Exchange developer. It will likely be restored after that. Commented Jan 5, 2015 at 17:50
1
    $this->Server = $#####;
    $this->DB = $#####;
    $this->User = $######;
    $this->Password = $#######;

Hmm, aren't those strings? If so, skip $ and put them into '.

    $this->Server = 'mysql3.000webhost.com';
    $this->DB = 'a3206525_ezmail';
    $this->User = 'a3206525_ezmail';
    $this->Password = 'belfegor666';

Also, it's not wise to publish your credentials ;)

And the most important advice, read some more about PHP. It'll really help you.

1
  • 1
    awesome! and thank you! (') this did the trick ;) thanks also for the advice, I got a bit stressed out and forgot to cleanup the credentials :/ Commented Jan 5, 2015 at 16:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.