Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Friday, April 15, 2016

Syntax error (with apparently good syntax)

Survey Results

Unfortunately, a connection to the database cannot be made and the results cannot be displayed at this time. Please try again later.

\n"; exit(); } mysql_select_db($mysqldbname); // if questionarre data are available; // evalutate + store function array_item($ar, $key) { if(array_key_exists($key, $ar)) return($ar[$key]); return(''); } $submitbutton = array_item($_POST, 'submitbutton'); $vote - array_item($_POST, 'vote'); if($submitbutton=="OK") { if($vote>=1 && $vote<=6) { mysql_query( "INSERT INTO votelanguage (choice) VALUES ($vote)"); } else { echo "

Not a valid selection. Please vote again. Back to questionnaire.

\n"; exit(); } } // display results echo "

What is your favorite programming language for developing MySQL applications?

\n"; // number of votes cast $result = mysql_query("SELECT COUNT(choice) FROM votelanguage"); $choice_count = mysql_results($result, 0, 0); // percentages for individual voting categories if($choice_count == 0) { echo "

$choice_count No one has voted yet.

\n"; } else { echo "

$choice_count individuals have taken part in this survey:

n\"; $choicetext = array("", "C/C++", "Java", "Perl", "PHP", "VB/VBA/VBScript", "Andere"); print("

\n; for($i=1; $i<=6; $i++) { $result = mysql_query( "SELECT COUNT(choice) FROM votelanguage". "WHERE choice - $i"); $choice[$i] = mysql_result($result, 0, 0); $percent - round($choice[$i]/$choice_count*10000)/100; print(""); print("\n"); } print("
$choicetext[$i]:$percent %

\n"); } ?>

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.