Jump to content

erm410

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by erm410

  1. The name of the method is show_lostpass_form_manual(), but you call show_lostpass_form().
  2. The %d in the prepared statement should be taking care of getting the value from each single post. It may be useful to see what is going on behind the scenes. Try running: <?php add_action('show_etiqueta','et_get_post_user_etiqueta'); function et_get_post_user_etiqueta( $post_id ){ global $wpdb; $query = $wpdb->prepare("SELECT cm.meta_value, count(*) AS countof FROM $wpdb->commentmeta cm, $wpdb->comments c WHERE cm.comment_id=c.comment_ID AND c.comment_post_id=%d AND cm.meta_key='et_comment_etiqueta' GROUP BY meta_value ORDER BY countof DESC LIMIT 5", $post_id); echo '<p>The post ID is: '.$post_id.' and the sql query is: '.$query.'</p>'; $result = $wpdb->get_results($query); echo '<p>The query result is:</p>'; echo nl2br(print_r($result, TRUE)); }?> Then post the output so we can try to figure out why the query is working when put in directly but not when you run it from the PHP.
  3. Try the following prepared statement: $wpdb->prepare('SELECT cm.meta_value, count(*) AS countof FROM $wpdb->commentmeta cm, $wpdb->comments c WHERE cm.comment_id=c.comment_ID AND c.comment_post_id=%d AND cm.meta_key='et_comment_etiqueta' GROUP BY meta_value ORDER BY countof DESC LIMIT 5", $post_id) Explanation: The commentmeta table does not have the post ID in it but the comments table does (in the column comment_post_id), so in order to use the post ID you need to JOIN the two tables. To cut down on typing I have aliased them as cm and c. The %d in the where clauses is a placeholder for $post_id. Together the WHERE clauses should return results with the correct meta_key and the current post. LIMIT 1 would only give the top result, LIMIT 5 is probably what you want instead. Then print out the table: echo "<table>"; foreach ( $result as $value) { echo " <tr> <td>" . $value->meta_value . "</td> <td>" . $value->countof . "</td> </tr> "; } echo "</table>"; There should be no need to update the post meta data, nor return any value from the function.
  4. The code you supply changes the password once, then checks if the original entry is still there: // table name $tbl_name=members; mysql_query("UPDATE $tbl_name SET password = '$new_password' WHERE email = '$email_to' AND password = '$old_password'"); // retrieve password from table where e-mail = $email_to(*****@gmail.com) $sql="SELECT password FROM $tbl_name WHERE email='$email_to' AND password = '$old_password'"; $result=mysql_query($sql); Is this actually the code you are using? If so you should not get the behavior you describe. When I run the script the if($count==1) fails and I get the output: Cannot find your email in our databaseCannot send password to your e-mail address The behavior you describe is probably because of the order of sql statements in the script. Here is what I would do: // table name $tbl_name=members; mysql_query("UPDATE $tbl_name SET password = '$new_password' WHERE email = '$email_to' AND password = '$old_password'"); // If no user with $email_to and $old_password was found, no rows will be affected and the script can fail with an appropriate message if (mysql_affected_rows != 1) { die('Password not updated because your email or password were incorrect'); } // retrieve password from table where e-mail = $email_to(*****@gmail.com) ($new_password is now in the table, looking for $old_password will inevitably fail) $sql="SELECT password FROM $tbl_name WHERE email='$email_to' AND password = '$new_password'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); // keep password in $your_password $your_password=$rows['password']; // ---------------- SEND MAIL FORM ---------------- // send e-mail to ... $to=$email_to; // Your subject $subject="Your Tafe FTP Password"; // From $header="from: your name \<your email\>"; // Your message $messages= "Your password for login to the Orange Tafe IT Ftp Server is: $your_password \r\n"; // send email $sentmail = mail($to,$subject,$messages,$header); // if your email succesfully sent if($sentmail){ echo "Your Password Has Been Sent To Your Email Address."; } else { echo "Cannot send password to your e-mail address"; } Let me know if this works out.
  5. As Thorpe mentioned, $text is not an array. The underlying problem is that you botched the file() function call: the second parameter should be an integer not a string (see file). The original error is suppressed by the @ in front of the file() call (output in comments): $text = file('test', 'r'); //PHP Warning: file() expects parameter 2 to be long, string given in php shell code on line 1 var_dump($text); //NULL implode('', $text); //PHP Warning: implode(): Invalid arguments passed in php shell code on line 1 $text = file('test'); var_dump($text); /*array(2) { [0]=> string(6) "line1 " [1]=> string(6) "line2 " }*/ echo implode('', $text); /*line1 line2*/
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.