![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
![]() Grupa: Zarejestrowani Postów: 3 Pomógł: 0 Dołączył: 11.04.2012 Ostrzeżenie: (0%) ![]() ![]() |
Witam,
Widzialem ze temat sie powtarza ale <?php i nawiasy wydaja sie wporzadku. Programuje od niedawna wiec wybaczcie jestli problem jest banalny. Na jednej stronie .php musze zrobic menu dropDown ktore dodaje osobe lub wyswietla osoby z bazy niby proste zaczelem "bawic" sie funkcjami ale niestety cos mnie przyblokowalo mianowicie dostaje error: Parse error: syntax error, unexpected $end in /Applications/XAMPP/xamppfiles/htdocs/contact/contacts.php on line 92 czyli linia na samym koncu kodu ktora zamyka </html> CODE <?php
//--database connection mysql_connect("localhost","root", "")or die("Could not connect : " . mysql_error()); mysql_select_db("contacts") or die("Could not select database"); ?> <html> <head> <title>Contacts</title> <meta http-equiv="Content-type" content="text/html; charset=UTF-8"/> </head> <body> <?php //--drop down menu display function dropDown(){ ?> <form action="contact.php" method="post"> <select name="do"> <option value="add">Add Contact</option> <option value="show">Show Contacts</option> </select> <input type="submit" value="Submit"/> </form> } <?php //--form to add contact function formAdd(){ ?> <form action="contact.php" method="post"> <input type="hidden" name="do" value="save"/> <label>Firstname<imput type="text" name=firstname</label> <label>Surname</label><imput type="text" name=surname</label> <label>Number<imput type="text" name=number</label> <imput type="submit" value="Save"/> </form> } <?php //--function that will validate fields i.e if field is null=error else insert sql function validateForm(){ $firsthname = ($_POST['firstname']); $surname = ($_POST['surname']); $number = ($_POST['number']); } //--pull records from database and show person table function showPersons(){ $query="SELECT * FROM contacts ORDER BY firstname ASC"; $result=mysql_query($query)or die("Query Error ".mysql_error()); print '<table width="400" border="0">'; while($record=mysql_fetch_array($result, MYSQL_ASSOC)){ print '<tr><td>'.$record['contact.id'].'</td>'; print '<td>'.$record['firstname'].'</td>'; print '<td>'.$record['surname'].'</td>'; print '<td>'.$record['phone'].'</td></tr>'; } print '</table>'; } //--always show drop down dropDown(); //--check what has been choosen if(isset($POST['do'])){ //--show input form if($POST['do']=='add'){ formAdd(); } //--add new person from form if ($POST['do']=='save'){ validateForm(); } //--show persons if ($POST['do']='show'){ showPersons(); } } ?> </body> </html> |
|
|
![]()
Post
#2
|
|
![]() Grupa: Moderatorzy Postów: 4 069 Pomógł: 497 Dołączył: 11.05.2007 Skąd: Warszawa ![]() |
Forum nie parser, zamykam.
|
|
|
![]() ![]() |
![]() |
Aktualny czas: 20.08.2025 - 12:08 |