Please tell me what's wrong
| From: | Niels Schenk | Date: | Sun, 19 Nov 2000 08:57:46 +0000 |
| Subject: | Please tell me what's wrong | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-4547@lists.php.net to get a copy of this message | ||
Hi,
I am working on an assignment for school and I have written a piece of
php code to interact with a mysql database.
But it doens't work, when I load the script, it times out after a while.
Could anyone please help me out? I am totally new to php and have
written it by studying tutorials.
Thanks in advance,
Niels Schenk
The code:
<?php
$host = "host";
$user = "webmaster";
$wachtw = "webmaster";
$database = "systeembeheer";
/* functie show_form */
function show_form($soort) {
$lc = $PHP_AUTH_USER;
if($soort = 'storing') {
echo "<form action=\"leraar.php\" method=\"POST\">\n";
echo "<input type=\"hidden\" name='lc'
value=\"'$lc'\">\n";
echo "<input type=\"hidden\" name=\"action\"
value=\"nstoring_insert\">\n";
echo "<input type=\"text\" name=\"omschr\">\n";
echo "</form>";
}
else {
echo "<form action=\"leraar.php\" method=\"POST\">\n";
echo "<input type=\"hidden\" name='lc'
value=\"'$lc'\">\n";
echo "<input type=\"hidden\" name='action'
value=\"nsoftware_insert\">\n";
echo "<input type=\"text\" name=\"ns\">\n";
}
}
/* einde funtie show_form */
/* functie nstoring_insert */
function nstoring_insert($lc, $omschr){
global $host, $user, $wachtw;
$query = "INSERT INTO nieuwe_storing (da, lc, omschr) VALUES ('$lc',
'$omschr')";
mysql_connect($host, $user, $wachtw) or die ("<br>Foutmelding: het is
niet gelukt om uw storings melding in te voeren, probeer het
opnieuw.<br>\n");
$result = mysql_db_query($database,$query)
or die ("<br>Foutmelding: het is niet gelukt om uw software aanvraag
in te voeren, probeer het opnieuw.<br>\n");
mysql_close();
}
/* einde functie nstoring_insert */
/* functie: nsoftware_insert; stop software aanvraag van docenten in de
tabel */
function nsoftware_insert($ns, $lok, $afd, $licen, $sd, $lc) {
global $host, $user, $wachtw;
$query = "INSERT INTO nieuwe_software (ns, lok, afd, licen, sd, lc)
VALUES ('$ns', '$lok', '$afd', '$licen',
'$lc')";
mysql_connect($host, $user, $wachtw) or die ("<br>Foutmelding: kan geen
verbinding maken met de server.<br>\n");
$result = mysql_db_query($database,$query)
or die ("<br>Foutmelding: het is niet gelukt om uw software aanvraag
in te voeren, probeer het opnieuw.<br>\n");
mysql_close();
}
/* Einde functie nsoftware_insert */
if($action = 'nsoftware_insert') {
nsoftware_insert($ns, $lok, $afd, $licen, $sd, $lc);
}
elseif($action = 'nstoring_insert') {
nstoring_insert($lc, $omschr);
}
else {
show_form($soort);
}
?>