WordPress.org

Ready to get started?Download WordPress

Forums

CSS & JavaScript Toolbox
[resolved] Error with wpdb::prepare (4 posts)

  1. gMagicScott
    Member
    Posted 1 year ago #

    On this page: options-general.php?page=cjtoolbox there is a PHP error showing twice within each block. See screenshot.

    The error is:
    Warning: Missing argument 2 for wpdb::prepare(), called in <em>[removed]</em>/wp-content/plugins/css-javascript-toolbox/css-js-toolbox.php on line 895 and defined in <em>[removed]</em>/wp-includes/wp-db.php on line 990

    From the source:

    /**
    		* Get code template selection list.
    		*
    		* @param string Type of template. It could be 'css' or 'js';
    		* @param string Unique identified for the block list.
    		* @return void
    		*/
    		function show_dropdown_box($type, $boxid) {
    			global $wpdb;
    			$query = $wpdb->prepare("SELECT id, title FROM {$wpdb->prefix}cjtoolbox_cjdata WHERE type = '{$type}'");
    			$list = $wpdb->get_results($query);
    			if(count($list)) {
    				echo '<select id="cjtoolbox-'.$type.'-'.$boxid.'" class="cjtoolbox-'.$type.'">';
    				foreach($list as $def) {
    					echo '<option value="' . $def->id . '">'. $def->title . '</option>';
    				}
    				echo '</select>';
    			}
    		}

    The line is:
    $query = $wpdb->prepare("SELECT id, title FROM {$wpdb->prefix}cjtoolbox_cjdata WHERE type = '{$type}'");

    My proposed solution:
    $query = $wpdb->prepare("SELECT id, title FROM {$wpdb->prefix}cjtoolbox_cjdata WHERE type = %s", $type);

    Let me know what you think.

    http://wordpress.org/extend/plugins/css-javascript-toolbox/

  2. wipeoutmedia
    Member
    Plugin Author

    Posted 1 year ago #

    Hi gMagicScott,

    Thanks for your message Scott.
    This is so cool of you to not only let us know about this error but also providing a solution for it. Thank you so much!!! We appreciate those screenshots too.
    We will be working on a big update to CSS & JavaScript Toolbox and any issues such as this error will be addressed. Leave it with us and hope to roll an update out in the near future.

    Kind Regards,
    Damian

  3. wipeoutmedia
    Member
    Plugin Author

    Posted 1 year ago #

    Just a heads up on the recent error (or more-so latest warning).
    This is has been forced in the latest version of WordPress 3.5 for more security.
    You may already know this, but for other users experiencing this warning error with CJT, you can read more about it in Andrew Nacin's latest post.

    We'll take care of this in the next update.

    Regards,
    Damian

  4. wipeoutmedia
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for reporting!

    This issue has fixed in version 6.0.

    Regards,
    Ahmed

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic