Support » Plugin: CSS & JavaScript Toolbox » Error with wpdb::prepare

  • Resolved Scott Lesovic


    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author wipeoutmedia


    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,

    Plugin Author wipeoutmedia


    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.


    Plugin Author wipeoutmedia


    Thanks for reporting!

    This issue has fixed in version 6.0.


Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Error with wpdb::prepare’ is closed to new replies.