View Single Post
Old 11-28-2008, 12:10 AM   #11 (permalink)
xenon
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

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:

PHP Code:
mysql_select_db($dbname); 
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 have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
The Following User Says Thank You to xenon For This Useful Post:
zxt3st (11-28-2008)