Trying to update a database table so a user can "edit" what they already have input. I used the keyword Update instead of select or insert in my sql code but I come up with error:
Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* from OrdersLists where uname = 'Test', 'Test', 'Beer', '', '123 spooner street' at line 1 in /home/spemulli/public_html/Presentation3/EditOrder.php:84 Stack trace: #0 /home/spemulli/public_html/Presentation3/EditOrder.php(84): PDOStatement->execute() #1 {main} thrown in /home/spemulli/public_html/Presentation3/EditOrder.php on line 84
Any advice??
<?php
if (isset($_POST['enter']))
{
//always initialized variables to be used
$uname = "";
$pwd = "";
$cpwd = "";
$fn = "";
$ln = "";
$gender = "";
$addy = "";
$quanity = "";
$agree = "";
$unameok = false;
$pwdok = false;
$agreeok = false;
//take the information submitted and verify inputs
$uname = trim($_POST['userName']);
$pwd = trim($_POST['pwd']);
$cpwd = trim($_POST['confirmPwd']);
$fn = trim($_POST['firstName']); //always trim the user input to get rid of the additiona white spaces on both ends of the user input
$ln = trim($_POST['lastName']);
$gender = trim($_POST['gender']);
$addy = trim($_POST['address']);
$quantity = trim($_POST['quantity']);
if (!spamcheck($uname))
$msg = $msg . '<br/><b>Email is not valid.</b>';
else $unameok = true;
if (!pwdValidate($pwd))
$msg = $msg . '<br/><b>Password is not in the required format.</b>';
else {
if ($pwd != $cpwd)
$msg = $msg . '<br/><b>Passwords are not the same.</b>';
else $pwdok = true;
}
if (!isset($_POST['agree'])) {
$msg = $msg . "<br/><b> You must agree to the terms and conditions </b><br />";
$term = '<span style="color:red">You must agree to the terms and conditions</span>';
}
else $agreeok = true;
if ($unameok && $pwdok ) {
//enter data into the database
$stmt = $con->prepare("UPDATE * from OrdersLists where uname = ?, ?, ?, ?, ?, ?");
if ($stmt->execute(array($fn, $ln, $gender, $agree, $addy, $quantity ))==TRUE)
$msg = '<font color = "red">Thank you for your Order.login.</font><br/>';
//$stmt = $con->prepare("select * from OrderLists where name = ?"); $stmt->execute(array($_uname));
else $msg = "Your information cannot be entered this time. Please try again later.";
}
}
?>
form action="EditOrder.php" method="post">
<h1>Order Form</h1>
<?php
print $msg;
$msg = "";
?>
<br />
Username (email): <input type="text" maxlength = "50" value="[email protected]" name="userName" id="userName" /> <br />
Password: <input type="text" maxlength = "50" value="123456asdfgh" name="pwd" id="pwd" />(Must be longer than 12 characters and contains at least 1 digit) <br />
Confirm Password: <input type="text" maxlength = "50" value="123456asdfgh" name="confirmPwd" id="confirmPwd" /> <br />
First Name: <input type="text" maxlength = "50" value="Test" name="firstName" id="firstName" /> <br />
Last Name: <input type="text" maxlength = "50" value="Test" name="lastName" id="lastName" /> <br />
Address: <input type="text" maxlength ="50" value="123 spooner street, Indianapolis, Indiana" name="address" id="address" />(Enter Street, City, State) <br />
Liquor Type:
<input type = "radio" name = "gender" value = "Beer" checked = "checked" />Beer
<input type = "radio" name = "gender" value = "Wine" />Wine <br />
Amount: <br />
<input type = "text" maxlength = "50" value="quantity, be descriptive" name="quantity" id="quantity" /> <br />
<br />
<input type="checkbox" name = "agree" value="y" />
<?php print $term; ?>
<br />
<input name="enter" class="btn" type="submit" value="Submit" />
</form>
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
DBMS is a database management system. It is designed to change, search, add and delete information in the database. There are many DBMSs designed for similar purposes with different features. One of the most popular is MySQL.
It is a software tool designed to work with relational SQL databases. It is easy to learn even for site owners who are not professional programmers or administrators. MySQL DBMS also allows you to export and import data, which is convenient when moving large amounts of information.
https://www.mysql.com/
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.