View Full Version : Writing installer for PHP-challenged friend, need help.

22 Apr 2004, 00:23
One of my friends just got a new script he wants to install, but since he has no clue how PHP/SQL work (just installed WinLAMP as an introduction) I've decided I'd write an installer script for this password-protection script. (Attachment 1 (http://www.vbulletin.org/forum/attachment.php?attachmentid=18280))

As for my code, I'm getting odd errors.The installer is now running the installation queries . .
Fatal error: Call to a member function on a non-object in c:\apache\htdocs\tst\install.php on line 88
My install.php file, hand coded (although the HTML was "borrowed" from the original script to keep a consistant "feel" :)) is attached (Attachment 2 (http://www.vbulletin.org/forum/attachment.php?attachmentid=18281)) and I would like some assistance.

PS - I know that to install this script, all that's needed is modify 1 PHP and run 1 query, but I would also like to expand my knowledge about PHP, and have decided to write this script as a practice. Help would be greatly appreciated. :D

22 Apr 2004, 04:33
The non-object error is referencing to this area of your code:

$query->query_mysql("CREATE TABLE $db_table_name(

$query is not declared as an object from any class.

I think you have your syntax mixed up, and are relating it to vBulletin's $DB_site.

vBulletin uses a class that $DB_site is originated from, see includes/init.php and includes/db_mysql.php.

Take a look at the mysql functions:

You need only run mysql_query() to run queries, no -> notation.

Although, I highly recommend for non-vB uses, to find yourself a good MySQL class to work by. There are many out there, from simple to highly sophisticated, from sites like PHP's PEAR (http://pear.php.net) or Eclipse (http://www.students.cs.uu.nl/people/voostind/eclipse/) (OO library).

Here is a simple example:


Although there are some critical design flaws in the code of that zip, and install.php. It's a good practice and standard not to combine HTML and PHP. Being this is for your friend, it's not that critical, but for larger projects I suggest getting a template engine like Smarty (http://smarty.php.net).

And, in "dbinc.php", there is no reason to separate each code chunk with <?php and ?>, unless you are escaping to place HTML. ;)