OOP - User System
View Single Post
11-28-2008, 03:17 PM
Join Date: Jun 2008
Originally Posted by
Drop the "var" keyword. It's deprecated as of PHP 5.0.0.
Now, about the problem with the table creation. Tables are assigned to databases. Therefore, you need to actually select a database before trying to create a table. In your do_connect method, after mysql_connect, you need to add another line:
Where $dbname is perhaps another parameter passed to the method. Also, you can easily remove the prefixes from the methods names. do_connect would become connect, do_query would become query and so on. That way you can easily remember the names later, while writing less code.
Also, try to add class properties (..or class variables, as some would call them) as you need them, not randomly across the code. And please, oh please, stop suppressing errors using the error suppression operator (@). Use error_reporting(E_ALL) combined with ini_set('display_errors', 'on') when debugging, and the opposite when going live. You MIGHT need to debug some problem later and you will not be able to tell what caused that problem, if you suppress all the errors/notices/warnings, what ever.
Enfernikus: creating tables cannot be enforced on that level. You can, or you can't create tables. End of story. It doesn't matter if you run a query in phpmyadmin or if you run your own php file that creates it. As long as a "create table" privilege is given on the user you're using to connect to the database, creating tables can be done from anywhere on that server (and in some cases, remotely - where the server accepts remote connections - not really the case with mysql).
I think I wrote my previous post in a mistaken fashion, what I meant was the accounts that you ordinarily make via web host control panel by default don't have the privilege to make tables such as Dreamhost.
View Public Profile
Send a private message to Enfernikus
Find More Posts by Enfernikus