Page 1 of 1

Help, get error (php5.5)

Posted: Tue Mar 24, 2015 7:57 pm
by adjaya
I love the theme but get error,
pls advise my friend here:

Code: Select all

Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/themes/jobboard/plugin/includes/stats.php on line 24 and defined in /public_html/wp-includes/wp-db.php on line 1152
For reference, the script here:
stats.php on line 24,

Code: Select all

return $wpdb->get_var($wpdb->prepare($query));
and wp-db.php on line 1152,

Code: Select all

public function prepare( $query, $args ) {
		if ( is_null( $query ) )
			return;
Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/themes/jobboard/plugin/includes/ext/jb_stats.php on line 82 and defined in /public_html/wp-includes/wp-db.php on line 1152
jb_stats.php on line 82:

Code: Select all

$ret = $wpdb->get_var($wpdb->prepare("SELECT id FROM ".$wpdb->prefix."jobboard_stats WHERE postid = $this->post_id AND ip = INET_ATON('$this->clientip') AND date >= '$date'"));
Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/themes/jobboard/plugin/includes/ext/jb_stats.php on line 149 and defined in /public_html/wp-includes/wp-db.php on line 1152
jb_stats.php on line 149:

Code: Select all

return $wpdb->get_var($wpdb->prepare("SELECT id FROM ".$wpdb->prefix."jobboard_stats WHERE ip = INET_ATON('$ip') AND date >= '$date';"));
Warning: mysql_query(): Access denied for user 'root'@'localhost' (using password: NO) in /public_html/wp-content/themes/jobboard/plugin/includes/ext/jb_stats.php on line 126
Warning: mysql_query(): A link to the server could not be established in /public_html/wp-content/themes/jobboard/plugin/includes/ext/jb_stats.php on line 126
jb_stats.php on line 126:

Code: Select all

$result = mysql_query('INSERT INTO '.$wpdb->prefix.'jobboard_stats (`postid`, `ip`, `date`) VALUES("'.$postid.'", "'.ip2long($this->clientip).'", "'. current_time('mysql').'")');

Re: Help, get error (php5.5)

Posted: Tue Mar 24, 2015 10:17 pm
by requinix
->prepare() is for prepared statements only, and it involves setting up a query with placeholders; you pass both the query template and the query values to the method.
If you want to execute a plain query then use ->query() instead.

For the last error, don't use the mysql_* functions directly. Use what WordPress provides.

Re: Help, get error (php5.5)

Posted: Sun Jun 07, 2015 5:26 am
by adjaya
Thank you for your advise.