Support » Plugins » Success message for table creation

  • Hey, I have a plugin that creates a new table in the wordpress database. It is installed by browsing to a install.php file provided in the plugin. But how it is now, it will just give you a blank page if it installed correctly, and if it didn’t then it will throwup mysql errors. I’d like it to give a little “successfully installed” message.

    // Create table
    $sql[] = "CREATE TABLE ".$table_prefix."liveshoutbox (".
    "id mediumint(9) NOT NULL AUTO_INCREMENT, ".
    "time int(11) NOT NULL, ".
    "name tinytext NOT NULL, ".
    "text text NOT NULL, ".
    "UNIQUE KEY id (id))";

    // Run the query
    foreach($sql as $query) {

    There is my installation code. I’ve tried wrapping it in all sorts of if statements, but none of them turn up anything. I also looked through wordpress’s install.php file to see if there was anything I could use, but I didn’t find anything. Any ideas?

Viewing 1 replies (of 1 total)
  • try this:

    // dummy vars
    $sql = array(
    "SELECT bar FROM foo",
    "SELECT foo FROM bar",
    "SELECT foobar FROM foobar",
    "SELECT * FROM ". $wpdb->posts,

    // stop $wpdb from printing out error messages
    // $wpdb error array
    global $EZSQL_ERROR;
    // keep error count
    $cnt = 0;
    // run the query
    foreach($sql as $query) {
    if($cnt < @count($EZSQL_ERROR)) {
    $cnt = count($EZSQL_ERROR);
    // you can print the last error message
    echo $EZSQL_ERROR[$cnt-1][error_str];
    else {
    echo 'success message';

    this will print out:
    Table '' doesn't exist
    Table '' doesn't exist
    Table 'yourdb.foobar' doesn't exist
    success message

Viewing 1 replies (of 1 total)
  • The topic ‘Success message for table creation’ is closed to new replies.