Estoy intentando instalar un plugin de wordpress, el error que me aparece es el siguiente:
mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /homepages/20/d285323061/htdocs/Gananciascbk/wp-content/plugins/gananciascb/gananciascb.php
Lo que este plugin hace es insertar un iframe de 1x1 pixel dentro de cada post.
Podria ser algun problema del servidor? Un amigo me comento que en Hostgator funciona a la perfeccion. Yo uso 1and1.
Si alguien me puede ayudar porfavor, muchas gracias de antemano!
Este es el codigo completo:
Código HTML:
register_activation_hook(__FILE__,'cdb2'); function cdb2 () { global $wpdb; $table_name = $wpdb->prefix . "cookieposts"; if($wpdb->get_var("show tables like '$table_name'") != $table_name) { $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, postid text NOT NULL, url text NOT NULL, UNIQUE KEY id (id) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); } } add_action('admin_menu', 'caddpage'); function caddpage(){ add_options_page('options-general.php','Ganancias Encubiertas CB','administrator','enterhoplink','cdisplay'); } function cdisplay() { echo "<h2>Ganancias Encubiertas CB</h2><br>"; global $wpdb; $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); mysql_select_db(DB_NAME, $conn) or trigger_error('MySQL error: '.mysql_error(), E_USER_ERROR); if (isset($_POST['url'])) { $table_name = $wpdb->prefix . "cookieposts"; $post = $_POST['select']; $url = $_POST['url']; $wpdb->insert( $table_name, array( 'postid' => $post, 'url' => $url ), array( '%d', '%s' ) ); } echo '<form id="form2" name="form2" method="post" action=""> <table> <tr> <label>Enlace de Afiliado: <input style= "width:400px" input type="text" name="url" /> </label> </tr> <tr></tr> <label> </table><br><br> <select name="select">'; mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); mysql_select_db(DB_NAME); $table_name5 = $wpdb->prefix . "posts"; $sql8 = "SELECT `ID` , `post_title` FROM $table_name5 WHERE `post_status` = 'publish' "; $result2 = mysql_query($sql8) or trigger_error(mysql_error()); while($row = mysql_fetch_assoc($result2)){ echo '<option name="page" page="'.$row['ID'].'" value="'.$row['ID'].'">'.$row['post_title'].'</option>'; } echo '</select> <input type="submit" name="Submit" value="Agregar galleta" /> </label> </form>'; $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); mysql_select_db(DB_NAME, $conn) or trigger_error('MySQL error: '.mysql_error(), E_USER_ERROR); if (isset($_POST['row'])) { $row = mysql_real_escape_string($_POST['row']); $delete = mysql_query(" delete from wp_cookieposts where id = '{$row}' limit 1 "); } $query = "SELECT wc.id, wc.postid, wc.url, wp.post_title FROM wp_cookieposts wc, wp_posts wp WHERE wp.ID = wc.postid"; $result = mysql_query($query) or trigger_error(mysql_error()); while($row = mysql_fetch_assoc($result)){ echo '<form id="form1" method="post" action=""><input type="hidden" name="page" value="enterhoplink" />'; echo '<br><br><table width="650" border="1" cellpadding="10"> <tr> <td width="66" rowspan="2"><label> <input name="row" type="hidden" value="'.$row['id'].'" /> <input type="submit" name="Submit" value="Borrar galleta" /> </label></td> <td width="526"><strong>Galleta:</strong> '.$row['url'].'</td> </tr> <tr> <td><strong>En mensaje:</strong> '.$row['post_title'].'</td> </tr></table>'; echo '</form>'; } //print_r ($_POST); if (isset($_POST['submit'])){ global $wpdb; $url=$_POST['url']; $inputs = $_POST['input']; $outputs = array(); $i = 1; foreach($inputs as $input) { $outputs[$i] = explode(",",$input); //$outputs[$i] = array_unique($outputs[$i]); $i++; } $b=0; $i=1; $table_name = $wpdb->prefix . "cookieposts"; $wpdb->query("TRUNCATE $table_name"); $urls = $_POST['urls']; //$urls = array_unique($urls); while($i <= count($outputs)){ //echo "ran"; $j=0; while($j!=count($outputs[$i])){ $wpdb->insert( $table_name, array( 'postid' => $outputs[$i][$j], 'url' => $urls[$b] ), array( '%s','%s' ) ); $j++; } $i++; $b++; } //$wpdb->insert( $table_name, array( 'url' => $url ), array( '%s' ) ); $i=0; crefresh(); } } function crefresh(){ echo '<meta http-equiv="refresh" content="2">'; } add_filter( "the_content", "cframes" ); function cframes($content){ global $wpdb; $id = get_the_ID(); //by default mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); mysql_select_db(DB_NAME); $query = "SELECT * FROM `wp_cookieposts` WHERE `postid` = '$id' "; $result = mysql_query($query) or trigger_error(mysql_error()); while($row = mysql_fetch_assoc($result)){ echo '<iframe src="'.$row['url'].'" WIDTH=1 HEIGHT=1 FRAMEBORDER=1 style="display:none"></iframe>'; } //$content=$id.$content; $table_name = $wpdb->prefix . "cookieposts"; $mylink90 = $wpdb->get_var("SELECT COUNT(*) FROM $table_name WHERE postid = $id"); $numberoffields=$mylink90; if($numberoffields==NULL){ $numberoffields=0; } //echo $numberoffields; $i=0; while($i!=$numberoffields){ //echo "ran"; $mylink = $wpdb->get_row("SELECT * FROM $table_name WHERE postid = $id",ARRAY_N,$i); //print_r ($mylink); $content = '<IFRAME NAME='.$i.' SRC='.$mylink[2].' WIDTH=1 HEIGHT=1 FRAMEBORDER=1 style="display:none"></IFRAME>'.$content; $i++; } return $content; } ?>