/    Sign up×
Community /Pin to ProfileBookmark

can somebody fix my php script??…

i have set up a php script, that asks the database jokes to show all of its data… i want to be able to add a joke. so everytime you click on the link to add a joke, you are supposed to see a form where to put your joke into! here is the script (but it doesnt work):

<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=windows-1250″>
<meta name=”generator” content=”PSPad editor, [url]www.pspad.com[/url]“>
<title></title>
</head>
<body>
<?php
if(isset($addjoke)):
?>

<form action=”<?=$PHP_SELF?>” method=”post”>
<p>Geben Sie hier ihren Witz ein: <br />
<textarea name=”joketext” rows=”5″ cols=”30″ wrap>
</textarea><br />
<input type=”submit” name=”submitjoke” value=”Speichern” />
</p>
</form>

<?php
else:

$dbcnx=mysql_connect(“localhost”, “root”);
if(!$dbcnx){
echo(“<p>cant connect</p>”);
exit();
}

if(!mysql_select_db(“jokes”)){
echo(“<p>auswahl der witzebank zur zeit nicht möglich</p>”);
exit();
}

if($submitjoke == “Speichern”){
$sql = “INSERT INTO Jokes SET
JokeText=’$JokeText’,
JokeDate=CURDATE()”;
if(mysql_query($sql)){
echo(“<p>witz wurde hinzugefügt</p>”);
}else{
echo(“<p>FEHLErhaft das ganze</p>”);
}
}

echo(“<p>hier sind alle witze:</p>”);

$result = mysql_query(“SELECT JokeText FROM Jokes”);
if(!$result){
echo(“<p>alles scheisse man</p>”);
exit();
}

while($row=mysql_fetch_array($result)){
echo(“<p>”.$row[“JokeText”].”</p>”);
}

echo(“<p><a href=’$PHP_SELF?addjoke=1′>”.”einen witz hinzufuegen!</a></p>”);

endif;

?>
</body>
</html>

thanks,
daniel

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@jacen6678Sep 07.2004 — What doesnt work? What errors are you getting? Can you post a link so that we can see the webpage that gets generated?
×

Success!

Help @danielOne spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...