Home > Archive > MySQL Server Forum > August 2005 > Still some issues









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Still some issues
Newsscanner

2005-08-17, 9:23 am

Hello,
Everything is beginning to work, but there are still a few issues left.
Please forgive my ignorance and hence stupid questions (Newbie).
I can now enter data with no problem, I get no errors, however, when I
check the contents of my DB, 2 fields display nothing.
The Fields PostCode (VARCHAR(10)) NOT NULL and
Email (VARCHAR(80)) NOT NULL
both remain empty in the database although I have entered data.
Like I said, I get no error messages after completion of the form.
If it helps, here is the PHP file to enter everything:
<html>
<head><title>Test MySQL</title></head>
<style>
body{
scrollbar-arrow-color: #00FF00;
scrollbar-3dlight-color: #333333;
scrollbar-highlight-color: #33FF33;
scrollbar-face-color: #000000;
scrollbar-shadow-color: #00CC00;
scrollbar-darkshadow-color: #000000;
scrollbar-track-color: #000000;


}
</style>
<body bgcolor="#000000" text="#00FF00" link="#FFFF00" vlink="#CCFFFF"
alink="#99CC00">
<!-- mysql_up.php -->
<?php
$host="everywebhost.com";
$user="radiokvo_enrol";
$password="**********";
mysql_connect($host,
$user,$password);
mysql_select_db($use
r);
$Name=$_POST['Name'];
$FirstNames=$_POST['FirstNames'];
$DOB=$_POST['DOB'];
$Sex=$_POST['Sex'];
$Address=$_POST['Address'];
$Town=$_POST['Town'];
$County=$_POST['County'];
$PostCode=$_POST['PostCode'];
$Telephone=$_POST['Telephone'];
$Mobile=$_POST['Mobile'];
$Fax=$_POST['Fax'];
$Email=$_POST['Email'];
$Course=$_POST['Course'];
$OtherCourse=$_POST['OtherCourse'];
$SessionType=$_POST['SessionType'];
$OtherDuration=$_POS
T& #91;'OtherDuration']
;
$NumberOfStudents=$_
POST& #91;'NumberOfStudent
s'];
$query = "INSERT into Names
(Name,FirstNames,DOB
,Sex,Address,Town,Co
unty,PostCode,Teleph
one,Mobile,Fax,Email
,Course,OtherCourse,
SessionType,OtherDur
ation,NumberOfStuden
ts)
VALUES
('$Name','$FirstName
s','$DOB','$Sex','$A
ddress','$Town','$Co
unty','$PostCode','$
Telephone','$Mobile'
,'$Fax','$Email','$C
ourse','$OtherCourse
','$SessionType','$O
therDuration','$Numb
erOfStudents')";
$result = mysql_query($query)
or die ("Couldn't execute query");
?>
</body>
</html>

And this is the form HTML code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<!-- Created with the CoffeeCup HTML Editor 2005 -->
<!-- http://www.coffeecup.com/ -->
<!-- Brewed on 15/08/2005 15:31:15 -->
<head>
<title>Enrolments</title>
<meta name="generator" content="CoffeeCup HTML Editor 2005D -
www.coffeecup.com">
<meta name="description" content="">
<meta name="keywords" content="">
<style>
body{
scrollbar-arrow-color: #00FF00;
scrollbar-3dlight-color: #333333;
scrollbar-highlight-color: #33FF33;
scrollbar-face-color: #000000;
scrollbar-shadow-color: #00CC00;
scrollbar-darkshadow-color: #000000;
scrollbar-track-color: #000000;
}
</style>
</head>
<body bgcolor="#000000" text="#00FF00" link="#FFFFFF" vlink="#33CCCC"
alink="#FF0000">
<div align="center"><font size="5">The Enrolment Page</font></div><br>
On this page you can enrol online, or, if you have already registered by
phone or other means, pass on your details so we can adjust our
database.<br>
Just fill in the fields in the form below, and you will get a
confirmation e-mail when it is
all done.<br>
<PRE><!-- Start of FORM -->
<form method="POST" action="http://enrolling.mybesthost.com/enrol.php">
Name: <input type="text" name="Name" Size="50"><br>
First Name(s): <input type="text" name="FirstNames" Size="60"><br>
Date of Birth: <input type="text" name="DOB" value=""> (YYYY-MM-DD)<br>
Sex: <select name="Sex">
<option value="Female">Female
<option value="Male">Male
</select><br>
Address: <input type="text" name="Address" Size="70"><br>
Town: <input type="text" name="Town" Size="40"><br>
County: <input type="text" name="County" Size="15"><br>
Postcode: <input type="text" name="Postcode" Size="15"><br>
Telephone: <input type="text" name="Telephone" Size="30"><br>
Mobile: <input type="text" name="Mobile" Size="30"><br>
Fax: <input type="text" name="Fax" Size="30"><br>
E-mail: <input type="text" name="E-mail" Size="70"><br>
Course: <input type="checkbox" name="Course" value="Piano"> Piano<br>
<input type="checkbox" name="Course" value="Keyboard">
Keyboard<br>
<input type="checkbox" name="Course" value="Singing"> Singing<br>
<input type="checkbox" name="Course" value="Other"> Other<br>
(If "Other", please specify:)<br>
<input type="text" name="OtherCourse" Size="60"><br>
Session: <select name="SessionType">
<option value="1 hour"> 1 hour
<option value="30 minutes"> 30 minutes
<option value="5 trial 1 hour"> 5 trial lessons @ 1 hour
<option value="5 trial 30 minutes"> 5 trial lessons @ 30 minutes
<option value="Other"> Other
</select><br>
(If "Other", please specify :)<br>
<input type="text" name="OtherDuration" Size="40"><br>
No of students:<input type="text" name="NumberOfStudents" Size="4"><br>
<input type="submit"> <input type="reset">
</form>
<!-- End of FORM --></pre>
<body>
</html>

In order not to be a pain, I will ask about the other issues later and
try to get this one sorted first.
All help will be much appreciated.
Newsscanner

2005-08-17, 1:23 pm

Gordon Burditt wrote:
> '' is a valid content of a VARCHAR(10) field.
>
> You have no input field for 'PostCode' in your form.
> You have no input field for 'Email' in your form.

Managed to miss that somehow.
Fixed it now.
Thanks.

> Add the statement:
> echo $query;
> right before the call to mysql_query. Show us what it prints
> when it does something you think is wrong. This will separate
> MySQL issues vs. PHP and HTML issues.
>
> Gordon L. Burditt

Here we go for the next one: I have one field with a choice via
checkboxes (where more than 1 choice is possible), I would like to see
all the fields (if users select multiple options of course) filling the
'Course' field, eg. if someone selects as their course Piano and also
Singing, I would like to see in my DB in the 'Course' field something
like "Piano, Singing".
I am not really sure where I am going wrong here.
The data type for this field is VARCHAR.

Thanks,
Newsscanner.

Bill Karwin

2005-08-17, 1:23 pm

Newsscanner wrote:
> Here we go for the next one: I have one field with a choice via
> checkboxes (where more than 1 choice is possible), I would like to see
> all the fields (if users select multiple options of course) filling the
> 'Course' field, eg. if someone selects as their course Piano and also
> Singing, I would like to see in my DB in the 'Course' field something
> like "Piano, Singing".


Here's an article with example on using PHP to accept input from form
fields that have multiple values:
http://www.apptools.com/phptools/forms/forms3.php

Once you have them in your PHP code as an array object, use implode() to
make a single comma-separated string out of the elements in the array.
See http://us3.php.net/implode

Then you have a string you can use to insert into your VARCHAR field.

Regards,
Bill K.
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com