The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

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

  1. Scott Lesovic
    Posted 3 years 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.


  2. wipeoutmedia
    Plugin Author

    Posted 3 years 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,

  3. wipeoutmedia
    Plugin Author

    Posted 3 years 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.


  4. wipeoutmedia
    Plugin Author

    Posted 3 years ago #

    Thanks for reporting!

    This issue has fixed in version 6.0.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • CSS & JavaScript Toolbox
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic