FreeHostia Forums
http://forum.freehostia.com/

Code Fault? or me!
http://forum.freehostia.com/viewtopic.php?f=7&t=7586
Page 1 of 2

Author:  DumbOne [ Fri Aug 10, 2007 3:43 am ]
Post subject:  Code Fault? or me!

I have found a post "Account Script" from 22 March 2007 that Josh Waller replied to that has helped me out greatly so far. I'm very new at this html, php etc so go easy on me!
I couldn't get "registration2.php" to work and amazingly discovered that the <?php tag was missing from the start. I added the tag and when I click on "Register" I get directed to a new page with the message;

Parse error: parse error, unexpected ';' in /home/www/xxxxxxxxx.com/registration2.php on line 4

What does that mean?

Thanks,
Alan.

Author:  Josh.Waller [ Fri Aug 10, 2007 7:22 am ]
Post subject: 

that means you have made a code error by adding in an extra ;

post lines 1 to 6 and i will take a look for you.

Author:  DumbOne [ Fri Aug 10, 2007 8:28 am ]
Post subject: 

Sorry Josh I should have put the code in. This is the code you supplied to another member on the 23rd of March 2007. I just did a "copy" & "paste".

$Link = mysql_connect (#HOST# ,#USERNAME#,#PASSWORD#); //Fill in the details

$username = $_POST['username']; //Gets username
$password = $_POST['password']; //Gets password

$Query = "SELECT ID FROM #DATABASE TABLE# WHERE username = '$username'";
$Result = mysql_db_query(#DATABASE NAME#, $Query, $Link);
if ($Row = mysql_fetch_array($Result)){
echo "Username already taken"; //Sends Error Message
die(); //Ends Script
}

$Query2 = "INSERT INTO #DATABASE TABLE# VALUES ('', '$username', '$password');
if ( mysql_db_query(#DATABASE NAME#, $Query2, $Link)){
echo "Thank you for registering";
}
mysql_close();
?>

Thanks for your help. I'm SURE I'll need it again!
Regards,
Alan.

Author:  DumbOne [ Fri Aug 10, 2007 8:46 am ]
Post subject: 

I have just realised that the "Register" code is in a "html" file but that seems to work. I've been trying to change it to a "php" file but am having problems with renaming & deleting files & folders. The help desk is trying to sort that out for me; I am able to do it on another P.C so I don't know why I have trouble on this P.C. Sometimes it works, most times it doesn't. But that's another story!
Will changing to "php" make a difference with the file that the "Register" code is in?
Regards,
Alan.

Author:  mark [ Fri Aug 10, 2007 8:52 am ]
Post subject: 

Hey Alan,

I only looked quick but I think I've found the problem... When you define $Query2, you forget the " at the end of the line.

$Query2 = "INSERT INTO #DATABASE TABLE# VALUES ('', '$username', '$password')";

Maybe it works. And I don't think changing to a .php extension won't help if a .html is being parsed too.

Regards
Mark

Author:  Josh.Waller [ Fri Aug 10, 2007 9:05 am ]
Post subject: 

Yeh mark is right, i forgot the last bit on Query2 could you pass my a link to where i put in the incorrect code so i can fix it please.

Mark if you like php you will like the next post im going to make.

Author:  DumbOne [ Fri Aug 10, 2007 9:06 am ]
Post subject: 

Hi Mark,
Tried that and it made no difference. According to the message (see above), the fault is in line 4.
Thanks for your help.

Author:  Josh.Waller [ Fri Aug 10, 2007 9:16 am ]
Post subject: 

Can you post what exactly you are using personaly, so i can get a better look at it. If there is a username / password in it change it for ####

Author:  DumbOne [ Fri Aug 10, 2007 9:35 am ]
Post subject: 

Josh, here is the link.

http://forum.freehostia.com/viewtopic.p ... unt+script

The code above IS exactly what I am using, and there lies the fault (I guess)!

What goes in the "HOST" section? I pressume my freehostia username & password go in the other sections?

Thanks again,
Alan.

Author:  Josh.Waller [ Fri Aug 10, 2007 9:50 am ]
Post subject: 

You need to create a MySQL database through the control panel of your hosting first.

It is a different username and password for mysql (which you set when you create the database) to your control panel login.

The mysql host will be shown when you create the table, its usualy something like

mysql3.freehostia.com

Author:  Josh.Waller [ Fri Aug 10, 2007 9:51 am ]
Post subject: 

line 4 would be

$username = $_POST['username']; //Gets username

and there is nothing wrong with that.

did you change anything on

$Link = mysql_connect (#HOST# ,#USERNAME#,#PASSWORD#); //Fill in the details

? like did you leave out a ' thats why i want to see the one that YOU are using

Author:  DumbOne [ Fri Aug 10, 2007 10:31 am ]
Post subject: 

I have already created the MySql database as per your instruction on that posting in March and it all went well.

The code I posted above is the one I used. I only added <?php at the very start. I then added the " as mark suggested which didn't appear to make a difference so I took it back out. I will put it back in though and try again.

Regards,
Alan.

Author:  DumbOne [ Fri Aug 10, 2007 10:37 am ]
Post subject: 

Josh,
I just copied this code from my "register2.php" file.

<?php
$Link = mysql_connect (#HOST# ,#USERNAME#,#PASSWORD#); //Fill in the details

$username = $_POST['username']; //Gets username
$password = $_POST['password']; //Gets password

$Query = "SELECT ID FROM #DATABASE TABLE# WHERE username = '$username'";
$Result = mysql_db_query(#DATABASE NAME#, $Query, $Link);
if ($Row = mysql_fetch_array($Result)){
echo "Username already taken"; //Sends Error Message
die(); //Ends Script
}

$Query2 = "INSERT INTO #DATABASE TABLE# VALUES ('', '$username', '$password')";
if ( mysql_db_query(#DATABASE NAME#, $Query2, $Link)){
echo "Thank you for registering";
}
mysql_close();
?>

This is exactly what's on that file.
Regards,
Alan.

Author:  Josh.Waller [ Fri Aug 10, 2007 10:39 am ]
Post subject: 

change

$Link = mysql_connect (#HOST# ,#USERNAME#,#PASSWORD#); //Fill in the details


to

$Link = mysql_connect ('host','username','password'); //Fill in the details

(replacing the writeing in the middle with the correct information leaving in the '

Author:  DumbOne [ Fri Aug 10, 2007 10:57 am ]
Post subject: 

We must be getting somewhere, now the error is

Parse error: parse error, unexpected T_IF, expecting ')' in /home/www/xxxxxxx.com/registration2.php on line 9

Regards,
Alan.

Page 1 of 2 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/