Alright, I am running Apache, PHP Mysql on localhost. Wrote this script which process responses to a comments html page. Can get the input from the form as variables and I seem to be able to create a database and connect to it, but can't get the mysql_select("Insert... or mysql_query. How can I get a link to the DB and yet not be able to put anything into it.
here is the code...
<?php>
//create shortcuts for the from variables
$name = $HTTP_POST_VARS['name'];
$comment = $HTTP_POST_VARS['comment'];
$question = $HTTP_POST_VARS['question'];
$cartype = $HTTP_POST_VARS['cartype'];
$email = $HTTP_POST_VARS['email'];
$thoughts = $HTTP_POST_VARS['thoughts'];
echo "Your name is: $name<br />";
echo "Your comment is: $comment<br />";
echo "Your question is: $question<br />";
echo "Your Mini is a: $cartype<br />";
echo "Your email address is: $email<br />";
echo "Your thoughts are as follows: $thoughts<br />";
//Create a DB for the comments to be stored in.
$db="testdb";
$link = mysql_connect("localhost", "root");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Select DB Error: ".mysql_error());
//create table
mysql_query("CREATE TABLE feedback(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
name CHAR(30),
comment CHAR(7),
question CHAR(7),
cartype TEXT(30),
emailaddress TEXT(50),
commenttext TEXT(200))")
or die("Create table Error: ".mysql_error());
?>
All responses gratefully appreciated...