Hy,
This piece of code worked local, but as soon as i uploaded it to an test server, it was buggy. I'm new to wordpress plugins, but i know how php works.
I get this error:
Fatal error: Cannot access empty property
And this is the line that gives the error (the last line):
global $wpdb;
$wpdb -> show_errors();
$dbPrefixHere = $wpdb -> $prefix;
Am i'm doing something wrong here? Or is there en better / nicer way to get the db prefix?
edit 1 alright, i've got that working, but now there is no db table created...
I'm using this part of code for that:
$sQueryCheckProjectDB = "CREATE TABLE ".$dbPrefixHere."automaticthesiswriter_projects (
projectID int(11) NOT NULL AUTO_INCREMENT,
userID int(11) NOT NULL,
shareID int(11) NOT NULL,
projectName mediumtext NOT NULL,
projectDescription mediumtext NOT NULL,
PRIMARY KEY (projectID)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
dbDelta($sqlUseOnPageSQLCreate);
But the table isn't created, and there is no error showed...
try changing:
$dbPrefixHere = $wpdb -> $prefix;
to:
$dbPrefixHere = $wpdb->prefix;
Additional answer: (incorrect variable used?)
$sQueryCheckProjectDB = "CREATE TABLE ".$dbPrefixHere."automaticthesiswriter_projects (
projectID int(11) NOT NULL AUTO_INCREMENT,
userID int(11) NOT NULL,
shareID int(11) NOT NULL,
projectName mediumtext NOT NULL,
projectDescription mediumtext NOT NULL,
PRIMARY KEY (projectID)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
dbDelta($sQueryCheckProjectDB);
refernce: http://codex.wordpress.org/Creating_Tables_with_Plugins