Re: Please tell me what's wrong

From: Date: Sun, 19 Nov 2000 14:49:45 +0000
Subject: Re: Please tell me what's wrong
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-4550@lists.php.net to get a copy of this message
Well, to start with, your first $query reads: > $query = "INSERT INTO nieuwe_storing (da, lc, omschr) VALUES ('$lc', '$omschr')"; You're telling MySQL to store 3 fields, but only supplying 2. Likewise, your second use of $query requests 6 fields to be updated, but you're only supplying 5 fields. If you're wanting one of these fields to default to something, then that should have been specified when you were creating the table, and the field should then not be specified in the INSERT. As a side note, you may find that embedding your HTML code may make it easier to debug it. For example, convert your code which reads > 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>"; > } to something like this: if ($$soort == 'storing') { ?> <form action = "leraar.php" method = "POST"> <input type = "hidden" name = "lc" value = "<?php echo($lc); ?>"> <input type = "hidden" name = "action" value = "storing_insert"> <input type = "test" name = "omschr"> </form> <?php } PHP is intelligent enough to handle this as well as the php code inside the quotation marks. I find doing this just sometimes makes things easier to follow. Hope all this helps "Niels Schenk" <niels@accept.demon.nl> wrote in message news:3A17960A.85011102@accept.demon.nl... > 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); > } > > ?> > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#4550) next »