Erreur PHP
Posté : 08 oct. 2012, 20:08
Bonjour, j'ai un erreur php et le script ne marche pas, pouvez vous m'aider ?
<?php
error_reporting(E_ALL ^ E_NOTICE);
// This is originally based on code from
// http://www.lerdorf.on.ca/nameit.php3
// I have modified and abstracted some of the code to make it easier
// to use. But all the rest of the code is by lerdorf ([email protected]>
// In lieu of any license by the original author, I'm placing my modifications
// under the GPL.
//
// I was looking all over the place to find something like this. I'm happy
// someone was nice enough to write one in PHP3, and not use friggin' perl.
// Later all,
// Aubin <[email protected]>
// http://www.punknews.org/
// ----------------------------------------------------------------------------
// Some variables used by the script
$mysqlserver = "xxxxx"; // hostname of mysql server
$mysqldb = "xxxx"; // database containing table
$mysqluser = "xxxxxxx"; // user with priveledges to add/modify table
$mysqlpass = "xxxxxxx"; // password for above user
$mysqltable = "names"; // table containing data (default: names)
// for basic functions, you won't need to change
// anything after this, though you might want to. It's pretty butt ugly
// as it stands.
if($vote && !$already_voted) SetCookie("already_voted","1");?>
<html><head><title>Vote for Stuff...</title></head>
<body bgcolor="#ffffff" text="#032F5B" link="#537492" vlink="#000000">
<FONT FACE="Verdana, Arial, Helvetica">
<h3>Vote for Stuff...</h3>
Please give me some suggestions or vote for an existing one.
</font>
<?php echo "<form action=\"$PHP_SELF\" method=\"POST\">"; ?>
Suggestion: <input type=text name=new_name size=25 maxlength=29><P>
<input type=submit value="Submit Suggestion">
<input type=reset><P>
<?
mysql_pconnect($mysqlserver,$mysqluser,$mysqlpass);
if($new_name) {
if(!mysql_db_query($mysqldb,"insert into $mysqltable values
('$new_name',0)")) {
print mysql_errno().": ".mysql_error()."<BR>";
}
}
if($vote && $already_voted) {
print "<font color=#ff0000>Hey, you voted already! Vote
ignored.</font><P>\n";
}
else if($vote) {
if(!mysql_db_query($mysqldb,"update $mysqltable set votes=votes+1 where
name='$vote'")) {
print mysql_errno().": ".mysql_error()."<BR>";
}
}
$result=mysql_db_query($mysqldb,"select sum(votes) as sum from $mysqltable");
if($result) {
$sum = (int) mysql_result($result,0,"sum");
mysql_free_result($result);
}
$result=mysql_db_query($mysqldb,"select * from $mysqltable order by votes DESC");
print "<table border=0><tr><th>Vote</th><th>Suggestion</th><th
colspan=2>Votes</th></tr>\n";
while($row=mysql_fetch_row($result)) {
print "<tr><td align=center><input type=radio name=vote value=\"$row[0]
\"></td><td>";
print $row[0]."</td><td align=right>".$row[1]."</td><td>";
if($sum && (int)$row[1]) {
$per = (int)(100 * $row[1]/$sum);
print "<img src=\"bline.gif\" height=12 width=$per> $per %</td>";
}
print "</tr>\n";
}
print "</table>\n";
mysql_free_result($result);
?>
<input type=submit value="Vote">
<input type=reset>
</form>
<?php // Please keep this intact ?>
<CENTER><A HREF="http://www.punknews.org/"><IMG SRC="punknewsmini.gif" BORDER=1></A><BR>
<FONT FACE="helvetica,arial" SIZE=1><A HREF="http://www.punknews.org/">punknews.org</A></FONT>
<?php // thanks ?>
</body></html>
Et la base de données est :
# MySQL dump 5.13
#
# Host: localhost Database: votedb
#--------------------------------------------------------
# Server version 3.22.22
#
# Table structure for table 'names'
#
CREATE TABLE names (
name varchar(30) DEFAULT '' NOT NULL,
votes int(4),
PRIMARY KEY (name)
);
Merci par avance.