JBuss1503 Posted March 10, 2014 Share Posted March 10, 2014 Hi there, newbie to this forum and newbie to PHP (infact I only started "attempting" to use it today) I have a contact form on https://scm-intranet.tees.ac.uk/users/l1071039/bobbin/order.html And I have a table set up on MySQL named "orderform" According to my order.html, the form data should be posted to order.php (code can be seen below) <?php $product = $_POST['product']; $productcomments = $_POST['productcomments']; $name = $_POST['name']; $address = $_POST['address']; $age = $_POST['age']; $delivery = $_POST['delivery']; ?> <?php $host=”mysql.scm.tees.ac.uk”; $user_name=”l1071039”; $pwd=”+i^RR9b7”; $database_name=”l1071039”; $db=mysql_connect($host, $user_name, $pwd); if (mysql_error() > “”) print mysql_error() . “<br>”; mysql_select_db($database_name, $db); if (mysql_error() > “”) print mysql_error() . “<br>”; ?> <?php $query = “insert into orderform (product, productcomments, name, address, age, delivery) values (‘” . $product . “‘, ” . $productcomments . “, ‘” . $name . “‘, ‘” . $address . “. $age . “. $delivery . “‘)”; $qresult = mysql_query($query); ?> However when I fill the form in I get a snippet of code? How do I get it so when the submit button is clicked, it returns to the Home Page, and how can I view the data that was inputted? Many Thanks in advance Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 10, 2014 Share Posted March 10, 2014 the first thing that is apparent is, wherever you copy/pasted the code from originally, it was published using curly/smart-quotes and is invalid php code. quotes inside of php code must be straight " quotes. I get a snippet of code? it would probably help if you showed us what you got, as that would narrow down some of the possible causes. Quote Link to comment Share on other sites More sharing options...
JBuss1503 Posted March 10, 2014 Author Share Posted March 10, 2014 Hi, thanks for your quick response. I was getting parse errors on the lines in which I had the curly quotations. I changed those to straight " ones and got the following message when I submitted the form: Notice: Use of undefined constant ”mysql - assumed '”mysql' in /web/users/l1071039/bobbin/order.php on line 11 Notice: Use of undefined constant scm - assumed 'scm' in /web/users/l1071039/bobbin/order.php on line 11 Notice: Use of undefined constant tees - assumed 'tees' in /web/users/l1071039/bobbin/order.php on line 11 Notice: Use of undefined constant ac - assumed 'ac' in /web/users/l1071039/bobbin/order.php on line 11 Notice: Use of undefined constant uk” - assumed 'uk”' in /web/users/l1071039/bobbin/order.php on line 11 Notice: Use of undefined constant ”l1071039” - assumed '”l1071039”' in /web/users/l1071039/bobbin/order.php on line 12 Notice: Use of undefined constant ” - assumed '”' in /web/users/l1071039/bobbin/order.php on line 13 Notice: Use of undefined constant i - assumed 'i' in /web/users/l1071039/bobbin/order.php on line 13 Notice: Use of undefined constant RR9b7” - assumed 'RR9b7”' in /web/users/l1071039/bobbin/order.php on line 13 Notice: Use of undefined constant ”l1071039” - assumed '”l1071039”' in /web/users/l1071039/bobbin/order.php on line 14 Warning: mysql_connect(): Unknown MySQL server host '”mysqlscmteesacuk”' (1) in /web/users/l1071039/bobbin/order.php on line 15 Unknown MySQL server host '”mysqlscmteesacuk”' (1)Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /web/users/l1071039/bobbin/order.php on line 17 Unknown MySQL server host '”mysqlscmteesacuk”' (1)Warning: mysql_query(): Access denied for user 'apache'@'localhost' (using password: NO) in /web/users/l1071039/bobbin/order.php on line 24 Warning: mysql_query(): A link to the server could not be established in /web/users/l1071039/bobbin/order.php on line 24 Thanks again Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 10, 2014 Share Posted March 10, 2014 the current list of undefined constant... errors indicate you have a mix of quotes or no quotes around the values being mentioned. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.