PDA

View Full Version : Urgent Help!!


sleekfx
03-16-2004, 04:34 PM
Trouble is im sort of a novice to PHP MYSQL and im doing a project in it as part of my third year Multimedia course in Ireland. I need the form as part of the site but im having a lot of trouble with it really.

Ive been working on it for about the last two weeks now and while i have learned a lot i still dont have this working. This is mainly what i have so far. I am going to post up the link to the form page and if anyone could help me by giving me the code to complete it so at least i would have something to learn off. Thanks in advance.

By the way its the signup form i am interested in, not the log in form.

www.fitorfoul.com/signup.php



<HTML>
<BODY>
<? $hostname = "localhost";
$username = "fitorfou_sleekfx"; // The username you created for this database.
$password = "password11"; // The password you created for the username.
$usertable = "details"; // The name of the table you made.
$dbName = "fitorfou_fitorfoul"; // This is the name of the database you made.

MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");
@mysql_select_db($dbName) or die( "Unable to select database");
?>

Spookster
03-16-2004, 04:36 PM
What does section 2 of our posting guidelines state?

http://www.codingforums.com/postguide.htm

Nightfire
03-16-2004, 04:41 PM
You say you want help, but haven't said what you need help with? What trouble are you having? What's not working? What errors you getting?

missing-score
03-16-2004, 04:51 PM
firstly could you take a look at this about putting your PHP code in PHP tags:

http://www.freeipb.net/phptags

2. What errors, if any, are you getting?

3. Put error_reporting(E_ALL) at the top of your script, to show all errors.

4. Why use capital letters for functions, use:
mysql_connect($hostname, $username, $password) or die("DB connection unavailable");

5. You have an @ symbol in front of mysql_select_db, which will hide all errors, take this out for testing.

raf
03-16-2004, 06:43 PM
Welcome here !


Please tell us how we can help you .

sleekfx
03-16-2004, 10:30 PM
Hey,

Ok ive read over the rules and yeah i admit i might been a little hasty in what i wrote. Anyway ive been working on this for the last two hours and ive come up with a new form, similar to my own but easier (hopefully) so if you would mind taking a look at it for me and give me some suggestions.

Thanks in advance.

Im also getting this: Parse error: parse error, unexpected T Variable on line 5


1<HTML>
2<BODY>
3
4<?php
5$hostname = "localhost";
6$username = "fitorfou_sleekfx"; // The username you created for this database.
7$password = "password1"; // The password you created for the username.
8$usertable = "users"; // The name of the table you made.
9$dbName = "fitorfou_fitorfoul"; // This is the name of the database you made.
10?>
11
12<?php
13
14
15
16if ($submit) {
17
18 // process form
19
20MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");
21@mysql_select_db($dbName) or die( "Unable to select database");
22
23$sql = "INSERT INTO users (firstname, email, gender, country, confirm) VALUES ('$firstname','$email','$email','$gender','country', 'confirm')";
24
25 $result = mysql_query($sql);
26
27 echo "Thank you! Information entered.\n";
28
29} else{
30
31
32
33
34?>
35
36<form method="post" action="details.php">
37
38 First name:
39<input type="Text" name="first"><br>
40
41<p>Email:
42<input type="Text" name="address"></p>
43<p>Gender:
44Male <input type="radio" value="type" checked name="Male">
45Female<input type="radio" value="type" checked name="Female">
46<p>Date of Birth 0000-00-00&nbsp;&nbsp; <input type="Text" name="address"><br>
47
48<br>
49
50Age:
51<input type="Text" name="address"></p>
52<p>Country:<select size="1" name="country"> <OPTION value="" selected>
53<OPTION VALUE=1>Ireland<OPTION value=2>Wales<OPTION VALUE=3>Endland</OPTION></SELECT>
54</p>
55<p>By Checking this i aggree to
56T&amp;C <input type="checkbox" name="confirm" value="ON"></p>
57<p></form>
58<p><input type="submit" value="Submit" name="submit"></p>
59</BODY>
60
61</HTML>

missing-score
03-16-2004, 10:34 PM
hmm... line 5 doesnt look like a problem :confused:

Anyway, could you edit your post and use tags. Just put at the top of your code and at the end. check http://www.freeipb.net/phptags for more help. I know it sounds like we're constantly going on, but it really does help, and will make members more keen to help with your problem. cheers :)

sleekfx
03-16-2004, 10:50 PM
Hey i dont think youre going on ata ll, i did not even know such things existed. I think it should come up in colour now.
Also i tried to edit the subject bar but it did not change.
Anyway...

Unexpected T_VARIABLE in C:\FoxServ\www\form.php on line 5. Here is my code:


1<HTML>
2<BODY>
3
4<?php
5$hostname = "localhost";
6$username = "fitorfou_sleekfx"; // The username you created for this database.
7$password = "password1"; // The password you created for the username.
8$usertable = "users"; // The name of the table you made.
9$dbName = "fitorfou_fitorfoul"; // This is the name of the database you made.
10?>
11
12<?php
13if ($submit) {
14
15MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");
16@mysql_select_db($dbName) or die( "Unable to select database");
17
18$sql = "INSERT INTO users (firstname, email, gender, country, confirm) VALUES ('$firstname','$email','$email','$gender','country', 'confirm')";
19$result = mysql_query($sql);
20
21echo "Thank you! Information entered.\n";
22} else{
23
24?>
25
26
27 <form method="post" action="details.php">
28
29First name: <input type="Text" name="first"><br>
30<p>Email: <input type="Text" name="address"></p>
31<p>Gender:
32Male <input type="radio" value="type" checked name="Male">
33Female<input type="radio" value="type" checked name="Female">
34<p>Date of Birth 0000-00-00&nbsp;&nbsp; <input type="Text" name="address"><br>
35<br>
36Age: <input type="Text" name="address"></p>
37<p>Country:<select size="1" name="country"> <OPTION value="" selected>
38<OPTION VALUE=1>Ireland<OPTION value=2>Wales<OPTION VALUE=3>Endland</OPTION></SELECT></p>
39
40<p>By Checking this i aggree to T&amp;C <input type="checkbox" name="confirm" value="ON"></p>
41<p><input type="submit" value="Submit" name="B1"></p>
42</form>
43</BODY></HTML>

missing-score
03-16-2004, 10:57 PM
Like i said, i cant see anything wrong with line 5. Your not actually leaving the line numbers in there when you test it are you?

just done a quick test, and when i copy the code and run it, i get:

Parse error: parse error, unexpected T_VARIABLE in c:\apache\htdocs\scripts\form-error.php on line 5

Try this:

... Html code ...

<?php
$hostname = "localhost";
$username = "fitorfou_sleekfx"; // The username you created for this database.
$password = "password1"; // The password you created for the username.
$usertable = "users"; // The name of the table you made.
$dbName = "fitorfou_fitorfoul"; // This is the name of the database you made.

// no need for php tags close/open here

if ($submit) {

mysql_connect($hostname, $username, $password) or die("DB connection unavailable");
@mysql_select_db($dbName) or die( "Unable to select database");

$sql = "INSERT INTO users (firstname, email, gender, country, confirm) VALUES ('$firstname','$email','$email','$gender','country
', 'confirm')";
$result = mysql_query($sql);

echo "Thank you! Information entered.\n";
} else{

?>

...

I dont know if this will solve it but it just seems funny that I get an identical error when the line numbers are present.

sidney
03-16-2004, 11:21 PM
<?php } ?>

need to close else tag after form

sleekfx
03-17-2004, 11:02 PM
alright lads thanks very much for the help. Ive finally got it working and to be honest ive learned absolutey loads. (Now available as freelance PHP MYSQL programmer) Ireland only though i must tell you before the offers start rolling in. Anyway im going to give gold membership to all of you who helped me once i have www.fitorfoul.com up and running.

Thanks again
Des