25. oktober 2006 - 22:45
Der er
4 kommentarer og 1 løsning
Undefined index
Hej jeg har brug for lidt hjælp. Jeg har lavet en side der driller mig lidt, Her er koden ?PHP $db = new DB2(); $form = new Form(); $db->connect("localhost", "xxxx", "xxxx"); $db->SelectDb("xxxxx"); if(isset($_POST['submit'])) { $db->CreateWorkshop(); echo "db"; } define('link','start'); ?> <?php if($_GET['link'] == "CreateWorkshop")- LINE 26 { ?> <form method="post" name="CreateWorkshop" action="<?PHP $_SERVER['PHP_SELF']; ?>"> <table> <tr><td> Workshop name </td><td> <?PHP echo $form->Input("name"); ?> </td></tr><tr> <td> Workshop start </td><td> <?PHP echo $form->Date("Start");?> </td></tr><tr><td> Workshop end </td><td> <?PHP echo $form->Date("end");?> </td></tr><tr><td> Max lead </td><td> <?PHP echo $form->Input("maxlead");?> </td></tr><tr><td> Max fallow </td><td> <?PHP echo $form->Input("maxfallow");?> </td></tr><tr> <td colspan="2"> <?php echo $form->Submit("submit","Create");?> </td></tr> </table> </form> <?php } ?> Jeg for denne fejl når jeg prøver at køre siden Notice: Undefined index: link in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test\index.php on line 26
Annonceindlæg fra Kingston Technology
25. oktober 2006 - 22:46
#1
koden uden fejl <?php if($_GET['link'] == "CreateWorkshop")<- LINE 26 { ?> <form method="post" name="CreateWorkshop" action="<?PHP $_SERVER['PHP_SELF']; ?>"> <table> <tr><td> Workshop name </td><td> <?PHP echo $form->Input("name"); ?> </td></tr><tr> <td> Workshop start </td><td> <?PHP echo $form->Date("Start");?> </td></tr><tr><td> Workshop end </td><td> <?PHP echo $form->Date("end");?> </td></tr><tr><td> Max lead </td><td> <?PHP echo $form->Input("maxlead");?> </td></tr><tr><td> Max fallow </td><td> <?PHP echo $form->Input("maxfallow");?> </td></tr><tr> <td colspan="2"> <?php echo $form->Submit("submit","Create");?> </td></tr> </table> </form> <?php } ?>
Slettet bruger
25. oktober 2006 - 23:16
#2
?PHP $db = new DB2(); $form = new Form(); $db->connect("localhost", "xxxx", "xxxx"); $db->SelectDb("xxxxx"); if(isset($_POST['submit'])) { $db->CreateWorkshop(); echo "db"; } define('link','start'); ?> <?php if(isset($_GET['link'] && $_GET['link'] == "CreateWorkshop") { ?> <form method="post" name="CreateWorkshop" action="<?PHP $_SERVER['PHP_SELF']; ?>"> <table> <tr><td> Workshop name </td><td> <?PHP echo $form->Input("name"); ?> </td></tr><tr> <td> Workshop start </td><td> <?PHP echo $form->Date("Start");?> </td></tr><tr><td> Workshop end </td><td> <?PHP echo $form->Date("end");?> </td></tr><tr><td> Max lead </td><td> <?PHP echo $form->Input("maxlead");?> </td></tr><tr><td> Max fallow </td><td> <?PHP echo $form->Input("maxfallow");?> </td></tr><tr> <td colspan="2"> <?php echo $form->Submit("submit","Create");?> </td></tr> </table> </form> <?php } ?> Bør virke noget bedre. Du skal først tjekke om indexet findes, før du kan finde ud af, hvilken værdi det har.