Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/286863-connecting-to-my-database-newbie/
Share on other sites

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.

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 :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.