<?php //include database connection $servername = "localhost"; $username = "root"; $password = ""; $dbname = "system"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { } // if the form was submitted/posted, update the record if($_POST){ //write query $stmt = $conn->prepare("UPDATE booking VALUES car = ?, date = ?, time = ?, number = ?, name = ?, type = ?, price = ? WHERE id = ?"); // you can bind params this way, // if you want to see the other way, see our add.php $stmt->bind_param( 'sssissii', $_POST['$car'], $_POST['$date'], $_POST['$time'], $_POST['$number'], $_POST['$name'], $_POST['$type'], $_POST['$price'], $_GET['$id'] ); // execute the update statement if($stmt->execute()){ // close the prepared statement $stmt->close(); }else{ } } /* * select the record to be edited, * you can also use prepared statement here, * but my hosting provider seems it does not support the mysqli get_result() function * you can use it like this one http://php.net/manual/fr/mysqli.prepare.php#107568 * so it I'm going to use $mysqli->real_escape_string() this time. */ $sql = "SELECT id, car, date, time, number, name, type, price FROM booking WHERE id = \"" . $conn->real_escape_string($_GET['id']) . "\" LIMIT 0,1"; // execute the sql query $result = $conn->query($sql); //get the result $row = $result->fetch_assoc(); // php's extract() makes $row['firstname'] to $firstname automatically //disconnect from database $result->free(); $conn->close(); ?> <!--we have our html form here where new user information will be entered--> <fieldset> <dl> <dt><label for="car" >Car Make:</label></dt> <dt><label for="date">Date:</label></dt> <dt><label for="time">Arrive Time:</label></dt> <dt><label for="number">Tel. No.:</label></dt> <dt><label for="name">Name:</label></dt> <dt><label for="type" style="width:450px;">Type:</label></dt> <option value="0">Select</option> <option value="Wash + Vac">Wash + Vac</option> <option value="Mini Valet">Mini Valet</option> <option value="Full Valet">Full Valet</option> <option value="Detar">Detar</option> <option value="Other">Other</option> </select></dd> <dt><label for="price">Price:</label></dt> <option value="0">Select</option> <option value="10">? 10</option> <option value="15">? 15</option> <option value="20">? 20</option> <option value="25">? 25</option> <option value="30">? 30</option> <option value="35">? 35</option> <option value="40">? 40</option> <option value="45">? 45</option> <option value="50">? 50</option> <option value="55">? 55</option> <option value="60">? 60</option> <option value="65">? 65</option> <option value="70">? 70</option> <option value="75">? 75</option> <option value="80">? 80</option> <option value="85">? 85</option> <option value="90">? 90</option> <option value="95">? 95</option> <option value="100">? 100</option> <option value="105">? 105</option> <option value="110">? 110</option> <option value="115">? 115</option> <option value="120">? 120</option> <option value="125">? 125</option> <option value="130">? 130</option> </select></dd> <dt><input type="submit" name="submit" value="Add"></dt></dl> </fieldset> </form> </body> </html>
Szukalem w google, siedze 3 dzien i nie moge nic wyyslic. id, number, price to jest INT w bazie
Zapomnialem, przepraszam: Fatal error: Call to a member function bind_param() on a non-object in C:\wamp\www\edit.php on line 35
Wiem co znaczy blad, nie wiem jak naprawic. tak w razie w to pisze