Ich entwickle ein WordPress-Plugin, das ein Formular an eine andere Seite sendet. Aber wenn ich versuche, das Formular an eine andere Seite zu senden, gibt diese Seite einen PHP-Fehler zurück. Mein Formularcode ist unten
echo "<form action='".plugins_url()."/wp_voting_poll/frontend_poll_process.php' method='post'>";
echo "<input type="hidden" name="hide" value="$ques" />";
$total_vote_count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_result WHERE question_uid='$ques'" );
if($ques!=""){
echo "<table>";
foreach($ans_data as $ans_res){
// $ans=$ans_res->answer;
$answer_id=$ans_res->id;
$type=$ans_res->answer_type;
$vote_count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_result WHERE answer_id='$answer_id'" );
if($vote_count==0){
error_reporting(0);
}
$vote_percent=($vote_count*100)/$total_vote_count;
echo "<tr> <td>";
echo "<div class="answer_div">";
if($type==1){
echo "<div class="input"><input type="radio" name="ans_name[]" value="$answer_id"/>".$ans_res->answer."<br/></div>";
}
elseif($type==0){
echo "<div class="input"><input type="checkbox" name="ans_name[]" value="$answer_id"/>".$ans_res->answer."<br/></div>";
}
if($backend==0){
echo "</td> <td>";
echo "<h4> total vote counted $vote_percent% </h4>";
// echo "<img src="https://stackoverflow.com/questions/19997913/$url" width="$width_img"/>";
$bar=$vote_percent*5.9;
echo "<img src="https://stackoverflow.com/questions/19997913/$url" height="10" width="$bar" />";
echo "</td></tr>";
}
}
echo "</table>";
echo "<input type="submit" value="Submit vote" />";
echo "</form>";
Und das ist mein Code einer anderen Seite, die das Formular verarbeiten soll. Aber leider gibt es einen PHP-Fehler zurück.
<?php
require_once("function_ip.php");
$vote_result=$_POST['ans_name'];
$uid=uniqid();
global $wpdb;
$table_vote=$wpdb->prefix."poll_answer_result";
$count=count($vote_result);
$hidden=$_POST['hide'];
$ans_data=$wpdb->get_results("SELECT * FROM $table_vote WHERE question_id='$hidden'" );
if($count>0){
foreach($vote_result as $vote_arr){
$wpdb->insert($table_vote,
array('answer_id' => $vote_arr,
'ip' =>get_client_ip(),
'question_uid' => $hidden
));
}
}
?>
Zeigt den PHP-Fehler an. Aktivieren Sie das Debuggen in wp-config und zeigen Sie diese Fehler ebenfalls an. Fügen Sie auch die Fehler aus Ihrer PHP-Fehlerprotokolldatei ein
– Anagio
15. November 2013 um 9:41 Uhr
Ich erhalte diesen Fehler, wenn ich das Formular gesendet habe, Hinweis: Versuchen, die Eigenschaft eines Nicht-Objekts in C:\wamp\www\wordpress_plugin\wp-content\plugins\wp_voting_poll\frontend_poll_process.php in Zeile 7 zu erhalten. Schwerwiegender Fehler: Aufruf an eine Member-Funktion get_results() auf einem Nicht-Objekt in C:\wamp\www\wordpress_plugin\wp-content\plugins\wp_voting_poll\frontend_poll_process.php in Zeile 11
– Mushfiqul Tuhin
15. November 2013 um 10:02 Uhr
Wenden Sie sich an den Plugin-Entwickler
– Anagio
15. November 2013 um 10:20 Uhr